From: Chaosheng Qu <[email protected]>
Subject: [PATCH] rtla: test that events are rejected without --trace
To: Steven Rostedt <[email protected]>
Cc: Tomas Glozar <[email protected]>,
    [email protected],
    [email protected]

-e, --filter and --trigger configure events of the trace instance that
--trace creates.  Before the previous patch they were silently dropped
when no --trace was given, and the tool still exited 0; the tests here
pin down the messages and exit codes for both the rejected and the
accepted cases.

hwnoise.t already covers the success path of -e with --trigger, so this
adds the failure paths only.

Signed-off-by: Chaosheng Qu <[email protected]>
---
diff --git a/tools/tracing/rtla/tests/osnoise.t 
b/tools/tracing/rtla/tests/osnoise.t
index 214fd40..ce9ff3e 100644
--- a/tools/tracing/rtla/tests/osnoise.t
+++ b/tools/tracing/rtla/tests/osnoise.t
@@ -99,4 +99,20 @@ check_top_q_hist "with conditional continue" \
 check_top_hist "with trace output at end" \
        "osnoise TOOL -d 1s --on-end trace" 0 "^  Saving trace to 
osnoise_trace.txt$"
 
+# -e, --filter and --trigger only take effect with --trace: they configure
+# events of the instance it creates.  Without it rtla used to drop them and
+# exit 0, so a typo in an event name went unnoticed.
+check "filter without a preceding -e" \
+       "osnoise top -q --filter 'prev_pid == 0' -d 1s" 129 "has no previous 
event to apply to"
+check "event without --trace" \
+       "osnoise top -q -e sched:sched_switch -d 1s" 1 "need --trace or 
--on-end trace"
+check "invalid event without --trace" \
+       "osnoise top -q -e nosuchsys:nosuchevent -d 1s" 1 "need --trace or 
--on-end trace"
+check "filter without --trace" \
+       "osnoise top -q -e sched:sched_switch --filter 'prev_pid == 0' -d 1s" 1 
"need --trace or --on-end trace"
+check "invalid event with --trace" \
+       "osnoise top -q -e nosuchsys:nosuchevent -t -d 1s" 1 "Error enabling 
event"
+check "valid event with --trace" \
+       "osnoise top -q -e sched:sched_switch -t -d 1s" 0 ""
+
 test_end
diff --git a/tools/tracing/rtla/tests/timerlat.t 
b/tools/tracing/rtla/tests/timerlat.t
index 5116857..18d7730 100644
--- a/tools/tracing/rtla/tests/timerlat.t
+++ b/tools/tracing/rtla/tests/timerlat.t
@@ -153,4 +153,20 @@ else
 fi
 done
 
+# -e, --filter and --trigger only take effect with --trace: they configure
+# events of the instance it creates.  Without it rtla used to drop them and
+# exit 0, so a typo in an event name went unnoticed.
+check "filter without a preceding -e" \
+       "timerlat top -q --filter 'prev_pid == 0' -d 1s" 129 "has no previous 
event to apply to"
+check "event without --trace" \
+       "timerlat top -q -e sched:sched_switch -d 1s" 1 "need --trace or 
--on-end trace"
+check "invalid event without --trace" \
+       "timerlat top -q -e nosuchsys:nosuchevent -d 1s" 1 "need --trace or 
--on-end trace"
+check "filter without --trace" \
+       "timerlat top -q -e sched:sched_switch --filter 'prev_pid == 0' -d 1s" 
1 "need --trace or --on-end trace"
+check "invalid event with --trace" \
+       "timerlat top -q -e nosuchsys:nosuchevent -t -d 1s" 1 "Error enabling 
event"
+check "valid event with --trace" \
+       "timerlat top -q -e sched:sched_switch -t -d 1s" 0 ""
+
 test_end


Reply via email to