2024-05-23 16:45:06

by Steven Rostedt

[permalink] [raw]
Subject: [PATCH] tracing/selftests: Run the ownership test twice

From: "Steven Rostedt (Google)" <[email protected]>

A regression happened where running the ownership test passes on the first
iteration but fails running it a second time. This was caught and fixed,
but a later change brought it back. The regression was missed because the
automated tests only run the tests once per boot.

Change the ownership test to iterate through the tests twice, as this will
catch the regression with a single run.

Signed-off-by: Steven Rostedt (Google) <[email protected]>
---
.../ftrace/test.d/00basic/test_ownership.tc | 34 +++++++++++--------
1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
index c45094d1e1d2..71e43a92352a 100644
--- a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
+++ b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
@@ -83,32 +83,38 @@ run_tests() {
done
}

-mount -o remount,"$new_options" .
+# Run the tests twice as leftovers can cause issues
+for loop in 1 2 ; do

-run_tests
+ echo "Running iteration $loop"

-mount -o remount,"$mount_options" .
+ mount -o remount,"$new_options" .

-for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
- test "$d" $original_group
-done
+ run_tests
+
+ mount -o remount,"$mount_options" .
+
+ for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
+ test "$d" $original_group
+ done

# check instances as well

-chgrp $other_group instances
+ chgrp $other_group instances

-instance="$(mktemp -u test-XXXXXX)"
+ instance="$(mktemp -u test-XXXXXX)"

-mkdir instances/$instance
+ mkdir instances/$instance

-cd instances/$instance
+ cd instances/$instance

-run_tests
+ run_tests

-cd ../..
+ cd ../..

-rmdir instances/$instance
+ rmdir instances/$instance

-chgrp $original_group instances
+ chgrp $original_group instances
+done

exit 0
--
2.43.0



2024-05-24 00:48:10

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH] tracing/selftests: Run the ownership test twice

On Thu, 23 May 2024 12:45:41 -0400
Steven Rostedt <[email protected]> wrote:

> From: "Steven Rostedt (Google)" <[email protected]>
>
> A regression happened where running the ownership test passes on the first
> iteration but fails running it a second time. This was caught and fixed,
> but a later change brought it back. The regression was missed because the
> automated tests only run the tests once per boot.
>
> Change the ownership test to iterate through the tests twice, as this will
> catch the regression with a single run.
>

Looks good to me.

Acked-by: Masami Hiramatsu (Google) <[email protected]>

Thanks!

> Signed-off-by: Steven Rostedt (Google) <[email protected]>
> ---
> .../ftrace/test.d/00basic/test_ownership.tc | 34 +++++++++++--------
> 1 file changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
> index c45094d1e1d2..71e43a92352a 100644
> --- a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
> +++ b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
> @@ -83,32 +83,38 @@ run_tests() {
> done
> }
>
> -mount -o remount,"$new_options" .
> +# Run the tests twice as leftovers can cause issues
> +for loop in 1 2 ; do
>
> -run_tests
> + echo "Running iteration $loop"
>
> -mount -o remount,"$mount_options" .
> + mount -o remount,"$new_options" .
>
> -for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
> - test "$d" $original_group
> -done
> + run_tests
> +
> + mount -o remount,"$mount_options" .
> +
> + for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
> + test "$d" $original_group
> + done
>
> # check instances as well
>
> -chgrp $other_group instances
> + chgrp $other_group instances
>
> -instance="$(mktemp -u test-XXXXXX)"
> + instance="$(mktemp -u test-XXXXXX)"
>
> -mkdir instances/$instance
> + mkdir instances/$instance
>
> -cd instances/$instance
> + cd instances/$instance
>
> -run_tests
> + run_tests
>
> -cd ../..
> + cd ../..
>
> -rmdir instances/$instance
> + rmdir instances/$instance
>
> -chgrp $original_group instances
> + chgrp $original_group instances
> +done
>
> exit 0
> --
> 2.43.0
>
>


--
Masami Hiramatsu (Google) <[email protected]>

2024-06-14 17:04:29

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] tracing/selftests: Run the ownership test twice


Shuah,

Can you take this through your tree?

-- Steve


On Thu, 23 May 2024 12:45:41 -0400
Steven Rostedt <[email protected]> wrote:

> From: "Steven Rostedt (Google)" <[email protected]>
>
> A regression happened where running the ownership test passes on the first
> iteration but fails running it a second time. This was caught and fixed,
> but a later change brought it back. The regression was missed because the
> automated tests only run the tests once per boot.
>
> Change the ownership test to iterate through the tests twice, as this will
> catch the regression with a single run.
>
> Signed-off-by: Steven Rostedt (Google) <[email protected]>
> ---
> .../ftrace/test.d/00basic/test_ownership.tc | 34 +++++++++++--------
> 1 file changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
> index c45094d1e1d2..71e43a92352a 100644
> --- a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
> +++ b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
> @@ -83,32 +83,38 @@ run_tests() {
> done
> }
>
> -mount -o remount,"$new_options" .
> +# Run the tests twice as leftovers can cause issues
> +for loop in 1 2 ; do
>
> -run_tests
> + echo "Running iteration $loop"
>
> -mount -o remount,"$mount_options" .
> + mount -o remount,"$new_options" .
>
> -for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
> - test "$d" $original_group
> -done
> + run_tests
> +
> + mount -o remount,"$mount_options" .
> +
> + for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
> + test "$d" $original_group
> + done
>
> # check instances as well
>
> -chgrp $other_group instances
> + chgrp $other_group instances
>
> -instance="$(mktemp -u test-XXXXXX)"
> + instance="$(mktemp -u test-XXXXXX)"
>
> -mkdir instances/$instance
> + mkdir instances/$instance
>
> -cd instances/$instance
> + cd instances/$instance
>
> -run_tests
> + run_tests
>
> -cd ../..
> + cd ../..
>
> -rmdir instances/$instance
> + rmdir instances/$instance
>
> -chgrp $original_group instances
> + chgrp $original_group instances
> +done
>
> exit 0