diff mbox series

[3/3] selftests/livepatch: filter 'taints' from dmesg comparison

Message ID 20200610172101.21910-4-joe.lawrence@redhat.com (mailing list archive)
State New
Headers show
Series selftests/livepatch: small script cleanups | expand

Commit Message

Joe Lawrence June 10, 2020, 5:21 p.m. UTC
The livepatch selftests currently filter out "tainting kernel with
TAINT_LIVEPATCH" messages which may be logged when loading livepatch
modules.

Further filter the log to drop "loading out-of-tree module taints
kernel" in the rare case the klp_test modules have been built
out-of-tree.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
---
 tools/testing/selftests/livepatch/functions.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Miroslav Benes June 11, 2020, 7:39 a.m. UTC | #1
On Wed, 10 Jun 2020, Joe Lawrence wrote:

> The livepatch selftests currently filter out "tainting kernel with
> TAINT_LIVEPATCH" messages which may be logged when loading livepatch
> modules.
> 
> Further filter the log to drop "loading out-of-tree module taints
> kernel" in the rare case the klp_test modules have been built
> out-of-tree.
> 
> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
> ---
>  tools/testing/selftests/livepatch/functions.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
> index 83560c3df2ee..f5d4ef12f1cb 100644
> --- a/tools/testing/selftests/livepatch/functions.sh
> +++ b/tools/testing/selftests/livepatch/functions.sh
> @@ -260,7 +260,8 @@ function check_result {
>  	local result
>  
>  	result=$(dmesg --notime | diff --changed-group-format='%>' --unchanged-group-format='' "$SAVED_DMESG" - | \
> -		 grep -v 'tainting' | grep -e '^livepatch:' -e 'test_klp')
> +		 grep -e '^livepatch:' -e 'test_klp' | \
> +		 grep -ve '\<taints\>' -ve '\<tainting\>')

or make it just 'grep -v 'taint' ? It does not matter much though.

Miroslav
Joe Lawrence June 11, 2020, 1:10 p.m. UTC | #2
On 6/11/20 3:39 AM, Miroslav Benes wrote:
> On Wed, 10 Jun 2020, Joe Lawrence wrote:
> 
>> The livepatch selftests currently filter out "tainting kernel with
>> TAINT_LIVEPATCH" messages which may be logged when loading livepatch
>> modules.
>>
>> Further filter the log to drop "loading out-of-tree module taints
>> kernel" in the rare case the klp_test modules have been built
>> out-of-tree.
>>
>> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
>> ---
>>   tools/testing/selftests/livepatch/functions.sh | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
>> index 83560c3df2ee..f5d4ef12f1cb 100644
>> --- a/tools/testing/selftests/livepatch/functions.sh
>> +++ b/tools/testing/selftests/livepatch/functions.sh
>> @@ -260,7 +260,8 @@ function check_result {
>>   	local result
>>   
>>   	result=$(dmesg --notime | diff --changed-group-format='%>' --unchanged-group-format='' "$SAVED_DMESG" - | \
>> -		 grep -v 'tainting' | grep -e '^livepatch:' -e 'test_klp')
>> +		 grep -e '^livepatch:' -e 'test_klp' | \
>> +		 grep -ve '\<taints\>' -ve '\<tainting\>')
> 
> or make it just 'grep -v 'taint' ? It does not matter much though.
> 

I don't know of any larger words* that may hit a partial match on 
"taint", but I figured the two word bounded regexes would be more specific.


* https://www.wordfind.com/contains/taint/ : guess I need to up my 
scrabble game :D

-- Joe
Petr Mladek June 12, 2020, 11:47 a.m. UTC | #3
On Thu 2020-06-11 09:10:38, Joe Lawrence wrote:
> On 6/11/20 3:39 AM, Miroslav Benes wrote:
> > On Wed, 10 Jun 2020, Joe Lawrence wrote:
> > 
> > > The livepatch selftests currently filter out "tainting kernel with
> > > TAINT_LIVEPATCH" messages which may be logged when loading livepatch
> > > modules.
> > > 
> > > Further filter the log to drop "loading out-of-tree module taints
> > > kernel" in the rare case the klp_test modules have been built
> > > out-of-tree.
> > > 
> > > Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
> > > ---
> > >   tools/testing/selftests/livepatch/functions.sh | 3 ++-
> > >   1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
> > > index 83560c3df2ee..f5d4ef12f1cb 100644
> > > --- a/tools/testing/selftests/livepatch/functions.sh
> > > +++ b/tools/testing/selftests/livepatch/functions.sh
> > > @@ -260,7 +260,8 @@ function check_result {
> > >   	local result
> > >   	result=$(dmesg --notime | diff --changed-group-format='%>' --unchanged-group-format='' "$SAVED_DMESG" - | \
> > > -		 grep -v 'tainting' | grep -e '^livepatch:' -e 'test_klp')
> > > +		 grep -e '^livepatch:' -e 'test_klp' | \
> > > +		 grep -ve '\<taints\>' -ve '\<tainting\>')
> > 
> > or make it just 'grep -v 'taint' ? It does not matter much though.
> > 
> 
> I don't know of any larger words* that may hit a partial match on "taint",
> but I figured the two word bounded regexes would be more specific.

I do not have strong opinion. I am fine with both current and Mirek's proposal.

I am just curious where \< and \> regexp substitutions are documented.
I see the following at the very end of "man re_syntax":

   \< and \> are synonyms for  “[[:<:]]” and “[[:>:]]” respectively

But I am not able to find documentation for “[[:<:]]” and “[[:>:]].
Even google looks helpless ;-)

Best Regards,
Petr
Kamalesh Babulal June 12, 2020, 12:57 p.m. UTC | #4
On 6/12/20 5:17 PM, Petr Mladek wrote:
> On Thu 2020-06-11 09:10:38, Joe Lawrence wrote:
>> On 6/11/20 3:39 AM, Miroslav Benes wrote:
>>> On Wed, 10 Jun 2020, Joe Lawrence wrote:
>>>
>>>> The livepatch selftests currently filter out "tainting kernel with
>>>> TAINT_LIVEPATCH" messages which may be logged when loading livepatch
>>>> modules.
>>>>
>>>> Further filter the log to drop "loading out-of-tree module taints
>>>> kernel" in the rare case the klp_test modules have been built
>>>> out-of-tree.
>>>>
>>>> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
>>>> ---
>>>>   tools/testing/selftests/livepatch/functions.sh | 3 ++-
>>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
>>>> index 83560c3df2ee..f5d4ef12f1cb 100644
>>>> --- a/tools/testing/selftests/livepatch/functions.sh
>>>> +++ b/tools/testing/selftests/livepatch/functions.sh
>>>> @@ -260,7 +260,8 @@ function check_result {
>>>>   	local result
>>>>   	result=$(dmesg --notime | diff --changed-group-format='%>' --unchanged-group-format='' "$SAVED_DMESG" - | \
>>>> -		 grep -v 'tainting' | grep -e '^livepatch:' -e 'test_klp')
>>>> +		 grep -e '^livepatch:' -e 'test_klp' | \
>>>> +		 grep -ve '\<taints\>' -ve '\<tainting\>')
>>>
>>> or make it just 'grep -v 'taint' ? It does not matter much though.
>>>
>>
>> I don't know of any larger words* that may hit a partial match on "taint",
>> but I figured the two word bounded regexes would be more specific.
> 
> I do not have strong opinion. I am fine with both current and Mirek's proposal.
> 
> I am just curious where \< and \> regexp substitutions are documented.
> I see the following at the very end of "man re_syntax":
> 
>    \< and \> are synonyms for  “[[:<:]]” and “[[:>:]]” respectively
> 
> But I am not able to find documentation for “[[:<:]]” and “[[:>:]].
> Even google looks helpless ;-)
> 

AFAIK, using \< and \> matches exact word.  Whereas when used individually,
\< matches beginning and \> matches end of the word.
Joe Lawrence June 14, 2020, 2:45 p.m. UTC | #5
On 6/12/20 8:57 AM, Kamalesh Babulal wrote:
> On 6/12/20 5:17 PM, Petr Mladek wrote:
>> On Thu 2020-06-11 09:10:38, Joe Lawrence wrote:
>>> On 6/11/20 3:39 AM, Miroslav Benes wrote:
>>>> On Wed, 10 Jun 2020, Joe Lawrence wrote:
>>>>
>>>>> The livepatch selftests currently filter out "tainting kernel with
>>>>> TAINT_LIVEPATCH" messages which may be logged when loading livepatch
>>>>> modules.
>>>>>
>>>>> Further filter the log to drop "loading out-of-tree module taints
>>>>> kernel" in the rare case the klp_test modules have been built
>>>>> out-of-tree.
>>>>>
>>>>> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
>>>>> ---
>>>>>    tools/testing/selftests/livepatch/functions.sh | 3 ++-
>>>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
>>>>> index 83560c3df2ee..f5d4ef12f1cb 100644
>>>>> --- a/tools/testing/selftests/livepatch/functions.sh
>>>>> +++ b/tools/testing/selftests/livepatch/functions.sh
>>>>> @@ -260,7 +260,8 @@ function check_result {
>>>>>    	local result
>>>>>    	result=$(dmesg --notime | diff --changed-group-format='%>' --unchanged-group-format='' "$SAVED_DMESG" - | \
>>>>> -		 grep -v 'tainting' | grep -e '^livepatch:' -e 'test_klp')
>>>>> +		 grep -e '^livepatch:' -e 'test_klp' | \
>>>>> +		 grep -ve '\<taints\>' -ve '\<tainting\>')
>>>>
>>>> or make it just 'grep -v 'taint' ? It does not matter much though.
>>>>
>>>
>>> I don't know of any larger words* that may hit a partial match on "taint",
>>> but I figured the two word bounded regexes would be more specific.
>>
>> I do not have strong opinion. I am fine with both current and Mirek's proposal.
>>
>> I am just curious where \< and \> regexp substitutions are documented.
>> I see the following at the very end of "man re_syntax":
>>
>>     \< and \> are synonyms for  “[[:<:]]� and “[[:>:]]� respectively
>>
>> But I am not able to find documentation for “[[:<:]]� and “[[:>:]].
>> Even google looks helpless ;-)
>>
> 
> AFAIK, using \< and \> matches exact word.  Whereas when used individually,
> \< matches beginning and \> matches end of the word.
> 

 From 
https://www.gnu.org/software/grep/manual/grep.html#The-Backslash-Character-and-Special-Expressions 
:

The ‘\’ character, when followed by certain ordinary characters, takes a 
special meaning:

...

‘\<’

     Match the empty string at the beginning of word.
‘\>’

     Match the empty string at the end of word.


I'd be happy to use any other (more readable!) whole-word matching grep 
trick, this \<one\> just happens to be committed to my cmdline muscle 
memory.

-- Joe
Miroslav Benes June 15, 2020, 7:55 a.m. UTC | #6
> From
> https://www.gnu.org/software/grep/manual/grep.html#The-Backslash-Character-and-Special-Expressions
> :
> 
> The ‘\’ character, when followed by certain ordinary characters, takes a
> special meaning:
> 
> ...
> 
> ‘\<’
> 
>     Match the empty string at the beginning of word.
> ‘\>’
> 
>     Match the empty string at the end of word.
> 
> 
> I'd be happy to use any other (more readable!) whole-word matching grep trick,
> this \<one\> just happens to be committed to my cmdline muscle memory.

There is 'grep -w' which I use for this.

Miroslav
Petr Mladek June 15, 2020, 9:19 a.m. UTC | #7
On Mon 2020-06-15 09:55:27, Miroslav Benes wrote:
> > From
> > https://www.gnu.org/software/grep/manual/grep.html#The-Backslash-Character-and-Special-Expressions
> > :
> > 
> > The ‘\’ character, when followed by certain ordinary characters, takes a
> > special meaning:
> > 
> > ...
> > 
> > ‘\<’
> > 
> >     Match the empty string at the beginning of word.
> > ‘\>’
> > 
> >     Match the empty string at the end of word.

The description is a bit confusing. I wonder how it handles dot,
comma, or colon. They are neither empty or word characters.

> > 
> > I'd be happy to use any other (more readable!) whole-word matching grep trick,
> > this \<one\> just happens to be committed to my cmdline muscle memory.
> 
> There is 'grep -w' which I use for this.

'grep -w' looks good promissing.

Best Regards,
Petr
diff mbox series

Patch

diff --git a/tools/testing/selftests/livepatch/functions.sh b/tools/testing/selftests/livepatch/functions.sh
index 83560c3df2ee..f5d4ef12f1cb 100644
--- a/tools/testing/selftests/livepatch/functions.sh
+++ b/tools/testing/selftests/livepatch/functions.sh
@@ -260,7 +260,8 @@  function check_result {
 	local result
 
 	result=$(dmesg --notime | diff --changed-group-format='%>' --unchanged-group-format='' "$SAVED_DMESG" - | \
-		 grep -v 'tainting' | grep -e '^livepatch:' -e 'test_klp')
+		 grep -e '^livepatch:' -e 'test_klp' | \
+		 grep -ve '\<taints\>' -ve '\<tainting\>')
 
 	if [[ "$expect" == "$result" ]] ; then
 		echo "ok"