Linux-kselftest Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg
@ 2020-06-26 20:59 Kees Cook
  2020-06-27 11:51 ` Michael Ellerman
  2020-06-30 18:53 ` Joe Lawrence
  0 siblings, 2 replies; 5+ messages in thread
From: Kees Cook @ 2020-06-26 20:59 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Naresh Kamboju, Petr Mladek, Joe Lawrence, Michael Ellerman,
	linux-kselftest, linux-kernel

Instead of full GNU diff (which smaller boot environments may not have),
use "comm" which is more available.

Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Link: https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com
Fixes: f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 tools/testing/selftests/lkdtm/run.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/lkdtm/run.sh b/tools/testing/selftests/lkdtm/run.sh
index 8383eb89d88a..5fe23009ae13 100755
--- a/tools/testing/selftests/lkdtm/run.sh
+++ b/tools/testing/selftests/lkdtm/run.sh
@@ -82,7 +82,7 @@ dmesg > "$DMESG"
 ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true
 
 # Record and dump the results
-dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true
+dmesg | comm -13 "$DMESG" - > "$LOG" || true
 
 cat "$LOG"
 # Check for expected output
-- 
2.25.1


-- 
Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg
  2020-06-26 20:59 [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg Kees Cook
@ 2020-06-27 11:51 ` Michael Ellerman
  2020-06-27 15:52   ` Kees Cook
  2020-06-30 18:53 ` Joe Lawrence
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2020-06-27 11:51 UTC (permalink / raw)
  To: Kees Cook, Shuah Khan
  Cc: Naresh Kamboju, Petr Mladek, Joe Lawrence, linux-kselftest, linux-kernel

Kees Cook <keescook@chromium.org> writes:
> Instead of full GNU diff (which smaller boot environments may not have),
> use "comm" which is more available.

Although using "comm" requires CONFIG_PRINTK_TIME=y doesn't it?

Which is probably fine, but should be mentioned.

And I guess for completeness you could add:

diff --git a/tools/testing/selftests/lkdtm/config b/tools/testing/selftests/lkdtm/config
index d874990e442b..ae88bfb163ff 100644
--- a/tools/testing/selftests/lkdtm/config
+++ b/tools/testing/selftests/lkdtm/config
@@ -1 +1,2 @@
 CONFIG_LKDTM=y
+CONFIG_PRINTK_TIME=y


cheers

> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Link: https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com
> Fixes: f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  tools/testing/selftests/lkdtm/run.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/lkdtm/run.sh b/tools/testing/selftests/lkdtm/run.sh
> index 8383eb89d88a..5fe23009ae13 100755
> --- a/tools/testing/selftests/lkdtm/run.sh
> +++ b/tools/testing/selftests/lkdtm/run.sh
> @@ -82,7 +82,7 @@ dmesg > "$DMESG"
>  ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true
>  
>  # Record and dump the results
> -dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true
> +dmesg | comm -13 "$DMESG" - > "$LOG" || true
>  
>  cat "$LOG"
>  # Check for expected output
> -- 
> 2.25.1
>
>
> -- 
> Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg
  2020-06-27 11:51 ` Michael Ellerman
@ 2020-06-27 15:52   ` Kees Cook
  2020-06-29  5:50     ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2020-06-27 15:52 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Shuah Khan, Naresh Kamboju, Petr Mladek, Joe Lawrence,
	linux-kselftest, linux-kernel

On Sat, Jun 27, 2020 at 09:51:31PM +1000, Michael Ellerman wrote:
> Kees Cook <keescook@chromium.org> writes:
> > Instead of full GNU diff (which smaller boot environments may not have),
> > use "comm" which is more available.
> 
> Although using "comm" requires CONFIG_PRINTK_TIME=y doesn't it?

No, it doesn't seem to. "comm" doesn't carry about the line prefixes.
AIUI, the only reason for a mention of "sort" is because of how "comm"
does its line pairing. i.e. as soon as it goes out of sync, it starts
accounting for the disjunction between files. But that's exactly what we
want it doing, and the prefix doesn't matter.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg
  2020-06-27 15:52   ` Kees Cook
@ 2020-06-29  5:50     ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2020-06-29  5:50 UTC (permalink / raw)
  To: Kees Cook
  Cc: Shuah Khan, Naresh Kamboju, Petr Mladek, Joe Lawrence,
	linux-kselftest, linux-kernel

Kees Cook <keescook@chromium.org> writes:
> On Sat, Jun 27, 2020 at 09:51:31PM +1000, Michael Ellerman wrote:
>> Kees Cook <keescook@chromium.org> writes:
>> > Instead of full GNU diff (which smaller boot environments may not have),
>> > use "comm" which is more available.
>> 
>> Although using "comm" requires CONFIG_PRINTK_TIME=y doesn't it?
>
> No, it doesn't seem to. "comm" doesn't carry about the line prefixes.
> AIUI, the only reason for a mention of "sort" is because of how "comm"
> does its line pairing. i.e. as soon as it goes out of sync, it starts
> accounting for the disjunction between files. But that's exactly what we
> want it doing, and the prefix doesn't matter.

OK, if it works.

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg
  2020-06-26 20:59 [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg Kees Cook
  2020-06-27 11:51 ` Michael Ellerman
@ 2020-06-30 18:53 ` Joe Lawrence
  1 sibling, 0 replies; 5+ messages in thread
From: Joe Lawrence @ 2020-06-30 18:53 UTC (permalink / raw)
  To: Kees Cook
  Cc: Shuah Khan, Naresh Kamboju, Petr Mladek, Michael Ellerman,
	linux-kselftest, linux-kernel

On Fri, Jun 26, 2020 at 01:59:43PM -0700, Kees Cook wrote:
> Instead of full GNU diff (which smaller boot environments may not have),
> use "comm" which is more available.
> 
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Link: https://lore.kernel.org/lkml/CA+G9fYtHP+Gg+BrR_GkBMxu2oOi-_e9pATtpb6TVRswv1G1r1Q@mail.gmail.com
> Fixes: f131d9edc29d ("selftests/lkdtm: Don't clear dmesg when running tests")
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  tools/testing/selftests/lkdtm/run.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/lkdtm/run.sh b/tools/testing/selftests/lkdtm/run.sh
> index 8383eb89d88a..5fe23009ae13 100755
> --- a/tools/testing/selftests/lkdtm/run.sh
> +++ b/tools/testing/selftests/lkdtm/run.sh
> @@ -82,7 +82,7 @@ dmesg > "$DMESG"
>  ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true
>  
>  # Record and dump the results
> -dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true
> +dmesg | comm -13 "$DMESG" - > "$LOG" || true
>  
>  cat "$LOG"
>  # Check for expected output

I'm not familiar with running lkdtm tests, but I copied the same fixup
for the livepatching selftests and "comm" slides in nicely over there,
so,

Acked-by: Joe Lawrence <joe.lawrence@redhat.com>

-- Joe


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-26 20:59 [PATCH] selftests/lkdtm: Use "comm" instead of "diff" for dmesg Kees Cook
2020-06-27 11:51 ` Michael Ellerman
2020-06-27 15:52   ` Kees Cook
2020-06-29  5:50     ` Michael Ellerman
2020-06-30 18:53 ` Joe Lawrence

Linux-kselftest Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-kselftest/0 linux-kselftest/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-kselftest linux-kselftest/ https://lore.kernel.org/linux-kselftest \
		linux-kselftest@vger.kernel.org
	public-inbox-index linux-kselftest

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kselftest


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git