* [PATCH] selftests/tracing: Fix false failure of subsystem event test
@ 2025-07-21 17:42 Steven Rostedt
2025-07-24 13:53 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2025-07-21 17:42 UTC (permalink / raw)
To: LKML, Linux trace kernel, linux-kselftest
Cc: Masami Hiramatsu, Mathieu Desnoyers, Shuah Khan, Shuah Khan,
Tengda Wu
From: Steven Rostedt <rostedt@goodmis.org>
The subsystem event test enables all "sched" events and makes sure there's
at least 3 different events in the output. It used to cat the entire trace
file to | wc -l, but on slow machines, that could last a very long time.
To solve that, it was changed to just read the first 100 lines of the
trace file. This can cause false failures as some events repeat so often,
that the 100 lines that are examined could possibly be of only one event.
Instead, create an awk script that looks for 3 different events and will
exit out after it finds them. This will find the 3 events the test looks
for (eventually if it works), and still exit out after the test is
satisfied and not cause slower machines to run forever.
Reported-by: Tengda Wu <wutengda@huaweicloud.com>
Closes: https://lore.kernel.org/all/20250710130134.591066-1-wutengda@huaweicloud.com/
Fixes: 1a4ea83a6e67 ("selftests/ftrace: Limit length in subsystem-enable tests")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
.../ftrace/test.d/event/subsystem-enable.tc | 28 +++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
index b7c8f29c09a9..65916bb55dfb 100644
--- a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
+++ b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
@@ -14,11 +14,35 @@ fail() { #msg
exit_fail
}
+# As reading trace can last forever, simply look for 3 different
+# events then exit out of reading the file. If there's not 3 different
+# events, then the test has failed.
+check_unique() {
+ cat trace | grep -v '^#' | awk '
+ BEGIN { cnt = 0; }
+ {
+ for (i = 0; i < cnt; i++) {
+ if (event[i] == $5) {
+ break;
+ }
+ }
+ if (i == cnt) {
+ event[cnt++] = $5;
+ if (cnt > 2) {
+ exit;
+ }
+ }
+ }
+ END {
+ printf "%d", cnt;
+ }'
+}
+
echo 'sched:*' > set_event
yield
-count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
+count=`check_unique`
if [ $count -lt 3 ]; then
fail "at least fork, exec and exit events should be recorded"
fi
@@ -29,7 +53,7 @@ echo 1 > events/sched/enable
yield
-count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
+count=`check_unique`
if [ $count -lt 3 ]; then
fail "at least fork, exec and exit events should be recorded"
fi
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/tracing: Fix false failure of subsystem event test
2025-07-21 17:42 [PATCH] selftests/tracing: Fix false failure of subsystem event test Steven Rostedt
@ 2025-07-24 13:53 ` Steven Rostedt
2025-07-24 21:53 ` Shuah Khan
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2025-07-24 13:53 UTC (permalink / raw)
To: LKML, Linux trace kernel, linux-kselftest, Shuah Khan, Shuah Khan
Cc: Masami Hiramatsu, Mathieu Desnoyers, Tengda Wu
Shuah,
Can you take this patch?
Thanks,
-- Steve
On Mon, 21 Jul 2025 13:42:12 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> The subsystem event test enables all "sched" events and makes sure there's
> at least 3 different events in the output. It used to cat the entire trace
> file to | wc -l, but on slow machines, that could last a very long time.
> To solve that, it was changed to just read the first 100 lines of the
> trace file. This can cause false failures as some events repeat so often,
> that the 100 lines that are examined could possibly be of only one event.
>
> Instead, create an awk script that looks for 3 different events and will
> exit out after it finds them. This will find the 3 events the test looks
> for (eventually if it works), and still exit out after the test is
> satisfied and not cause slower machines to run forever.
>
> Reported-by: Tengda Wu <wutengda@huaweicloud.com>
> Closes: https://lore.kernel.org/all/20250710130134.591066-1-wutengda@huaweicloud.com/
> Fixes: 1a4ea83a6e67 ("selftests/ftrace: Limit length in subsystem-enable tests")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> .../ftrace/test.d/event/subsystem-enable.tc | 28 +++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
> index b7c8f29c09a9..65916bb55dfb 100644
> --- a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
> +++ b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
> @@ -14,11 +14,35 @@ fail() { #msg
> exit_fail
> }
>
> +# As reading trace can last forever, simply look for 3 different
> +# events then exit out of reading the file. If there's not 3 different
> +# events, then the test has failed.
> +check_unique() {
> + cat trace | grep -v '^#' | awk '
> + BEGIN { cnt = 0; }
> + {
> + for (i = 0; i < cnt; i++) {
> + if (event[i] == $5) {
> + break;
> + }
> + }
> + if (i == cnt) {
> + event[cnt++] = $5;
> + if (cnt > 2) {
> + exit;
> + }
> + }
> + }
> + END {
> + printf "%d", cnt;
> + }'
> +}
> +
> echo 'sched:*' > set_event
>
> yield
>
> -count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
> +count=`check_unique`
> if [ $count -lt 3 ]; then
> fail "at least fork, exec and exit events should be recorded"
> fi
> @@ -29,7 +53,7 @@ echo 1 > events/sched/enable
>
> yield
>
> -count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
> +count=`check_unique`
> if [ $count -lt 3 ]; then
> fail "at least fork, exec and exit events should be recorded"
> fi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/tracing: Fix false failure of subsystem event test
2025-07-24 13:53 ` Steven Rostedt
@ 2025-07-24 21:53 ` Shuah Khan
0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2025-07-24 21:53 UTC (permalink / raw)
To: Steven Rostedt, LKML, Linux trace kernel, linux-kselftest,
Shuah Khan
Cc: Masami Hiramatsu, Mathieu Desnoyers, Tengda Wu, Shuah Khan
On 7/24/25 07:53, Steven Rostedt wrote:
> Shuah,
>
> Can you take this patch?
Done.
>
> Thanks,
>
> -- Steve
>
>
> On Mon, 21 Jul 2025 13:42:12 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
>> From: Steven Rostedt <rostedt@goodmis.org>
Applied to linux-kselftext next for Linux 6.17-rc1.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-24 21:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 17:42 [PATCH] selftests/tracing: Fix false failure of subsystem event test Steven Rostedt
2025-07-24 13:53 ` Steven Rostedt
2025-07-24 21:53 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).