Re: [PATCH v2 1/2] selftests/ftrace: Add check for ping command for trigger tests
From: Google
Date: Wed Oct 19 2022 - 11:43:41 EST
On Tue, 18 Oct 2022 19:33:40 +0530
"Naveen N. Rao" <naveen.n.rao@xxxxxxxxxxxxxxxxxx> wrote:
> All these tests depend on the ping command and will fail if it is not
> found. Allow tests to specify dependencies on programs through the
> 'requires' field. Add dependency on 'ping' for some of the trigger
> tests.
>
> Reported-by: Akanksha J N <akanksha@xxxxxxxxxxxxxxxxxx>
> Suggested-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>
Thanks, this looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> ---
> tools/testing/selftests/ftrace/test.d/functions | 8 +++++++-
> .../trigger/inter-event/trigger-field-variable-support.tc | 2 +-
> .../inter-event/trigger-inter-event-combined-hist.tc | 2 +-
> .../trigger/inter-event/trigger-onchange-action-hist.tc | 2 +-
> .../trigger/inter-event/trigger-onmatch-action-hist.tc | 2 +-
> .../inter-event/trigger-onmatch-onmax-action-hist.tc | 2 +-
> .../trigger/inter-event/trigger-onmax-action-hist.tc | 2 +-
> .../trigger/inter-event/trigger-snapshot-action-hist.tc | 2 +-
> .../inter-event/trigger-synthetic-event-dynstring.tc | 2 +-
> .../trigger/inter-event/trigger-trace-action-hist.tc | 2 +-
> 10 files changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
> index 5f6cbec847fc99..779f3e62ec9005 100644
> --- a/tools/testing/selftests/ftrace/test.d/functions
> +++ b/tools/testing/selftests/ftrace/test.d/functions
> @@ -142,9 +142,15 @@ finish_ftrace() {
>
> check_requires() { # Check required files and tracers
> for i in "$@" ; do
> + p=${i%:program}
> r=${i%:README}
> t=${i%:tracer}
> - if [ $t != $i ]; then
> + if [ $p != $i ]; then
> + if ! which $p ; then
> + echo "Required program $p is not found."
> + exit_unresolved
> + fi
> + elif [ $t != $i ]; then
> if ! grep -wq $t available_tracers ; then
> echo "Required tracer $t is not configured."
> exit_unsupported
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc
> index 41119e0440e960..04c5dd7d0acc4b 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test field variable support
> -# requires: set_event synthetic_events events/sched/sched_process_fork/hist
> +# requires: set_event synthetic_events events/sched/sched_process_fork/hist ping:program
>
> fail() { #msg
> echo $1
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc
> index 9098f1e7433fd0..f7447d800899ac 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test inter-event combined histogram trigger
> -# requires: set_event synthetic_events events/sched/sched_process_fork/hist
> +# requires: set_event synthetic_events events/sched/sched_process_fork/hist ping:program
>
> fail() { #msg
> echo $1
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc
> index adaabb873ed4ab..91339c1308324b 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test inter-event histogram trigger onchange action
> -# requires: set_event "onchange(var)":README
> +# requires: set_event "onchange(var)":README ping:program
>
> fail() { #msg
> echo $1
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc
> index 20e39471052e9a..d645abcf11c4f7 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test inter-event histogram trigger onmatch action
> -# requires: set_event synthetic_events events/sched/sched_process_fork/hist
> +# requires: set_event synthetic_events events/sched/sched_process_fork/hist ping:program
>
> fail() { #msg
> echo $1
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc
> index f4b03ab7c28714..c369247efb3501 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test inter-event histogram trigger onmatch-onmax action
> -# requires: set_event synthetic_events events/sched/sched_process_fork/hist
> +# requires: set_event synthetic_events events/sched/sched_process_fork/hist ping:program
>
> fail() { #msg
> echo $1
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc
> index 71c9b5911c7067..e28dc5f11b2be0 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test inter-event histogram trigger onmax action
> -# requires: set_event synthetic_events events/sched/sched_process_fork/hist
> +# requires: set_event synthetic_events events/sched/sched_process_fork/hist ping:program
>
> fail() { #msg
> echo $1
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc
> index 67fa328b830f5f..147967e86584ac 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test inter-event histogram trigger snapshot action
> -# requires: set_event snapshot events/sched/sched_process_fork/hist "onchange(var)":README "snapshot()":README
> +# requires: set_event snapshot events/sched/sched_process_fork/hist "onchange(var)":README "snapshot()":README ping:program
>
> fail() { #msg
> echo $1
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-dynstring.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-dynstring.tc
> index 3d65c856eca3e6..213d890ed1886e 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-dynstring.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-dynstring.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test inter-event histogram trigger trace action with dynamic string param
> -# requires: set_event synthetic_events events/sched/sched_process_exec/hist "char name[]' >> synthetic_events":README
> +# requires: set_event synthetic_events events/sched/sched_process_exec/hist "char name[]' >> synthetic_events":README ping:program
>
> fail() { #msg
> echo $1
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-trace-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-trace-action-hist.tc
> index c126d2350a6d41..d7312047ce2818 100644
> --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-trace-action-hist.tc
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-trace-action-hist.tc
> @@ -1,7 +1,7 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0
> # description: event trigger - test inter-event histogram trigger trace action
> -# requires: set_event synthetic_events events/sched/sched_process_fork/hist "trace(<synthetic_event>":README
> +# requires: set_event synthetic_events events/sched/sched_process_fork/hist "trace(<synthetic_event>":README ping:program
>
> fail() { #msg
> echo $1
> --
> 2.38.0
>
--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>