[PATCH] selftests/ftrace: Add check for ping command for trigger tests

From: Naveen N. Rao
Date: Mon Oct 17 2022 - 06:20:34 EST


All these tests depend on the ping command and will fail if it is not
installed. Add an explicit check and mark the tests as unresolved if it
isn't found.

Reported-by: Akanksha J N <akanksha@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>
---
.../trigger/inter-event/trigger-field-variable-support.tc | 5 +++++
.../trigger/inter-event/trigger-inter-event-combined-hist.tc | 5 +++++
.../trigger/inter-event/trigger-onchange-action-hist.tc | 5 +++++
.../trigger/inter-event/trigger-onmatch-action-hist.tc | 5 +++++
.../trigger/inter-event/trigger-onmatch-onmax-action-hist.tc | 5 +++++
.../test.d/trigger/inter-event/trigger-onmax-action-hist.tc | 5 +++++
.../trigger/inter-event/trigger-snapshot-action-hist.tc | 5 +++++
.../trigger/inter-event/trigger-synthetic-event-dynstring.tc | 5 +++++
.../test.d/trigger/inter-event/trigger-trace-action-hist.tc | 5 +++++
9 files changed, 45 insertions(+)

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..b0969e6eed8375 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test field variable support"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events
echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_waking/trigger
echo 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger
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..82875eab17f09f 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test create synthetic event"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 'waking_latency u64 lat pid_t pid' > synthetic_events
if [ ! -d events/synthetic/waking_latency ]; then
fail "Failed to create waking_latency synthetic event"
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..84b3fb08cc1519 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test onchange action"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio) if comm=="ping"' >> events/sched/sched_waking/trigger

ping $LOCALHOST -c 3
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..25866576b0bbe4 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test create synthetic event"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
if [ ! -d events/synthetic/wakeup_latency ]; then
fail "Failed to create wakeup_latency synthetic event"
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..3c4a4b11aa2421 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test create synthetic event"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
if [ ! -d events/synthetic/wakeup_latency ]; then
fail "Failed to create wakeup_latency synthetic event"
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..908bb99cdc4ece 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test create synthetic event"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
if [ ! -d events/synthetic/wakeup_latency ]; then
fail "Failed to create wakeup_latency synthetic event"
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..ee06706ae51a2c 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test snapshot action"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 1 > events/sched/enable

echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio):onchange($newprio).snapshot() if comm=="ping"' >> events/sched/sched_waking/trigger
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..dc0fffbe3c1dd8 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test create synthetic event"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 'ping_test_latency u64 lat; char filename[]' > synthetic_events
if [ ! -d events/synthetic/ping_test_latency ]; then
fail "Failed to create ping_test_latency synthetic event"
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..1a9f10826b9421 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
@@ -10,6 +10,11 @@ fail() { #msg

echo "Test create synthetic event"

+if ! which ping; then
+ echo "ping is not found. This test requires ping command."
+ exit_unresolved
+fi
+
echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events
if [ ! -d events/synthetic/wakeup_latency ]; then
fail "Failed to create wakeup_latency synthetic event"

base-commit: 6c0f39e87b6ab1a3009e3a49d3e6f6db8dc756a8
--
2.38.0