cyclictest, cyclicdeadline: Exit with failure when breaktrace threshold is exceeded
PATCH v2 1/1 cyclictest, cyclicdeadline: Exit with failure when breaktrace threshold is exceeded
cyclictest and cyclicdeadline always exit 0 even when the latency threshold set by --breaktrace is exceeded, requiring test harnesses to parse output or json to detect a failed test.
Set ret to EXIT_FAILURE when break_thread_id is set, indicating the breaktrace threshold was hit. The exit code enables shell expressions like "cyclictest ... && echo PASS" and seamless integration with testing frameworks. Also pass ret to rt_write_json() in cyclicdeadline so the JSON output reflects the failure.
---
v2:
- refine subject
- "Assisted-by" already conforms format AGENT_NAME:MODEL_VERSION
- add sob
--- src/cyclictest/cyclictest.8 | 8 ++++++++ src/cyclictest/cyclictest.c | 1 + src/sched_deadline/cyclicdeadline.8 | 8 ++++++++ src/sched_deadline/cyclicdeadline.c | 7 +++++-- 4 files changed, 22 insertions(+), 2 deletions(-)
src/cyclictest/cyclictest.8 +8 -0
@@ -311,6 +311,14 @@ in mind, below cyclictest example invocation can provide a good start: --histfile=output.txt .fi . +.SH "Exit status" +.TP +.B 0 +Success - all latencies were within the breaktrace threshold, or no threshold was set. +.TP +.B 1 +Failure - a latency exceeding the breaktrace threshold was detected. +. .SH "See also" .MR numa 3 , .MR numactl 8 ,
src/cyclictest/cyclictest.c +1 -0
@@ -2337,6 +2337,7 @@ int main(int argc, char **argv)if (break_thread_id) {printf ("# Break thread: %d\n" , break_thread_id);printf ("# Break value: %llu\n" , (unsigned long long )break_thread_value); + ret =EXIT_FAILURE ; } }
src/sched_deadline/cyclicdeadline.8 +8 -0
@@ -58,6 +58,14 @@ Send break trace command when latency > USEC .B \-\-tracemark write a trace mark when \-b latency is exceeded. .br +.SH "Exit status" +.TP +.B 0 +Success - all latencies were within the breaktrace threshold, or no threshold was set. +.TP +.B 1 +Failure - a latency exceeding the breaktrace threshold was detected. +. .SH AUTHOR cyclicdeadline was written by Steven Rostedt <[email protected]> .PP
src/sched_deadline/cyclicdeadline.c +5 -2
@@ -1315,10 +1315,13 @@ int main(int argc, char **argv)loop (sched_data, nr_threads); + ret =EXIT_SUCCESS ; +if (tracelimit) {if (break_thread_id) {printf ("# Break thread: %d\n" , break_thread_id);printf ("# Break value: %llu\n" , (unsigned long long )break_thread_value); + ret =EXIT_FAILURE ; } }
@@ -1334,7 +1337,7 @@ int main(int argc, char **argv) }if (strlen (jsonfile) !=0 ) -rt_write_json (jsonfile,0 , write_stats, sched_data); +rt_write_json (jsonfile, ret, write_stats, sched_data);if (setcpu_buf)free (setcpu_buf);
@@ -1344,5 +1347,5 @@ int main(int argc, char **argv)fclose (histfile);hset_destroy (&hset); -return 0 ; +return ret; }
Signature · 1 line
2.55.0
Quoted 5 lines · Costa Shulyupin
cyclictest and cyclicdeadline always exit 0 even when the latency threshold set by --breaktrace is exceeded, requiring test harnesses to parse output or json to detect a failed test.
Set ret to
EXIT_FAILUREwhenbreak_thread_idis set, indicating the
This is misleading because 1 is also returned if you use the wrong options, are now allowed to use the higher priority. You can't set it to failure and claim in the docs that the threshold has been reach. This might have happen, there might be another reason.
Why not pick a dedicated exit code value for this scenario and document it as such and use it for this purpose only.
Quoted 7 lines
breaktrace threshold was hit. The exit code enables shell expressions like "cyclictest ... && echo PASS" and seamless integration with testing frameworks. Also pass ret to
rt_write_json()in cyclicdeadline so the JSON output reflects the failure.Assisted-by Claude:claude-opus-4-6Signed-off-by Costa Shulyupin <[email protected]>
Sebastian
Quoted 3 lines · Sebastian Andrzej Siewior
Why not pick a dedicated exit code value for this scenario and document it as such and use it for this purpose only.
In standalone RTLA we use:
1 Error: invalid argument
2 Failed: the test hit the stop tracing condition
However, returning 2 here would be inconsistent with oslat from this project, which returns 1 on test failure via err_quit. What do you suggest?
Thanks,
Costa
Quoted 6 lines · Costa Shulyupin
Quoted 3 lines · Sebastian Andrzej Siewior
Why not pick a dedicated exit code value for this scenario and document it as such and use it for this purpose only.
Quoted 7 lines
In standalone RTLA we use:
1 Error: invalid argument
2 Failed: the test hit the stop tracing conditionHowever, returning 2 here would be inconsistent with oslat from this project, which returns 1 on test failure via
err_quit. What do you suggest?
Pick a number and document it. Make it unique. I don't like that there is an exit code that could be a failure of some sorts and the "trace abort condition hit" at once.
Quoted 2 lines
Thanks,
Costa
Sebastian