clictest, cyclicdeadline: Exit with failure when breaktrace threshold is exceeded
PATCH v3 1/1 clictest, 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 2 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.
---
v3:
- return 2 on failure
- reword error descriptions in manpages
v2:
- refine subject
- "Assisted-by" already conforms format AGENT_NAME:MODEL_VERSION
- add sob
--- src/cyclictest/cyclictest.8 | 11 +++++++++++ src/cyclictest/cyclictest.c | 1 + src/sched_deadline/cyclicdeadline.8 | 11 +++++++++++ src/sched_deadline/cyclicdeadline.c | 7 +++++-- 4 files changed, 28 insertions(+), 2 deletions(-)
src/cyclictest/cyclictest.8 +11 -0
@@ -311,6 +311,17 @@ in mind, below cyclictest example invocation can provide a good start: --histfile=output.txt .fi . +.SH "Exit status" +.TP +.B 0 +Success - breaktrace latency was not exceeded. +.TP +.B 1 +Error or invalid argument. +.TP +.B 2 +Test failure - breaktrace latency is exceeded. +. .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 =2 ; } }
src/sched_deadline/cyclicdeadline.8 +11 -0
@@ -58,6 +58,17 @@ 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 - breaktrace latency was not exceeded. +.TP +.B 1 +Error or invalid argument. +.TP +.B 2 +Test failure - breaktrace latency is exceeded. +. .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 =2 ; } }
@@ -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 4 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.
Quoted 8 lines
Set ret to 2 when
break_thread_idis 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 tort_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 4 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.
Quoted 8 lines
Set ret to 2 when
break_thread_idis 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 tort_write_json()in cyclicdeadline so the JSON output reflects the failure.Assisted-by Claude:claude-opus-4-6Signed-off-by Costa Shulyupin <[email protected]>
John, does this look good to you?
Sebastian
Quoted 55 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 2 when
break_thread_idis 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 tort_write_json()in cyclicdeadline so the JSON output reflects the failure.Assisted-by Claude:claude-opus-4-6Signed-off-by Costa Shulyupin <[email protected]>---
v3:
- return 2 on failure
- reword error descriptions in manpages
v2:
- refine subject
- "Assisted-by" already conforms format AGENT_NAME:MODEL_VERSION
- add sob--- src/cyclictest/cyclictest.8 | 11 +++++++++++ src/cyclictest/cyclictest.c | 1 + src/sched_deadline/cyclicdeadline.8 | 11 +++++++++++ src/sched_deadline/cyclicdeadline.c | 7 +++++-- 4 files changed, 28 insertions(+), 2 deletions(-)src/cyclictest/cyclictest.8 +11
-0@@ -311,6 +311,17 @@ in mind, below cyclictest example invocation can provide a good start: --histfile=output.txt .fi . +.SH "Exit status" +.TP +.B 0 +Success - breaktrace latency was not exceeded. +.TP +.B 1 +Error or invalid argument. +.TP +.B 2 +Test failure - breaktrace latency is exceeded. +. .SH "See also" .MR numa 3 , .MR numactl 8 ,src/cyclictest/cyclictest.c +0
-0
src/cyclictest/cyclictest.c int main(int argc, char **argv) · line 2343
Quoted 7 lines
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 =2 ; } }
Did you test this?
When I run (on a non-rt kernel)
su -c './cyclictest -t -b50 --json json.txt'
Password:
# /dev/cpu_dma_latency set to 0us policy: other/other: loadavg: 0.70 1.00 0.80 1/2952 198115
T: 0 (198100) P: 0 I:1000 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 1
(198101) P: 0 I:1500 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 2 (198102) P: 0 I:2000 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 3 (198103) P: 0 I:2500 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 4 (198104) P: 0 I:3000 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 5 (198105) P: 0 I:3500 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 6 (198106) P: 0 I:4000 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 7 (198107) P: 0 I:4500 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 8 (198108) P: 0 I:5000 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T: 9 (198109) P: 0 I:5500 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T:10 (198110) P: 0 I:6000 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T:11 (198111) P: 0 I:6500 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T:12 (198112) P: 0 I:7000 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T:13 (198113) P: 0 I:7500 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T:14 (198114) P: 0 I:8000 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 T:15 (198115) P: 0 I:8500 C: 0 Min:1000000 Act: 0 Avg: 0 Max: 0 # Thread
Ids: 198100 198101 198102 198103 198104 198105 198106 198107 198108 198109 198110 198111 198112 198113 198114 198115
# Break thread: 198100
# Break value: 52
the top part of the json.txt file is
"file_version": 1,
"cmdline:": "./cyclictest -t -b50 --json json.txt", "rt_test_version:": "2.10",
"start_time": "Tue, 29 Sep 2026 16:18:56 -0400", "end_time": "Tue, 29 Sep 2026 16:18:56 -0400", "return_code": 0,
So the return_code is 0, and not 2
Looking at the code
ret = EXIT_SUCCESS;
outall:
shutdown = 1;
usleep(50000);
if (!verbose && !quiet && refresh_on_max)
printf("\033[%dB", num_threads + 2);
if (strlen(jsonfile) != 0)
rt_write_json(jsonfile, ret, write_stats, NULL);So we write EXIT_SUCCESS before we even get to the part where we have "ret = 2"; added to the code
if (tracelimit) {
print_tids(parameters, num_threads);
if (break_thread_id) {
printf("# Break thread: %d\n", break_thread_id);
printf("# Break value: %llu\n", (unsigned long
long)break_thread_value);
ret = 2;
}
}Maybe instead do ret = break_thread_id ? 2 : EXIT_SUCCESS;
Fix the typo in the subject too "clictest" should be "cyclictest"
John Kacur
Quoted 1 line · John Kacur
Maybe instead do ret =
break_thread_id? 2 :EXIT_SUCCESS;
I didn't pay attention to the json bits either. What about
src/cyclictest/cyclictest.c +3 -3
@@ -2340,9 +2340,6 @@ int main(int argc, char **argv)if (!verbose && !quiet && refresh_on_max)printf ("\033[%dB" , num_threads +2 ); -if (strlen (jsonfile) !=0 ) -rt_write_json (jsonfile, ret, write_stats,NULL ); -if (quiet) quiet =2 ;for (i =0 ; i < num_threads; i++) {
@@ -2372,6 +2369,9 @@ int main(int argc, char **argv) } } +if (strlen (jsonfile) !=0 ) +rt_write_json (jsonfile, ret, write_stats,NULL ); +for (i=0 ; i < num_threads; i++) {if (!statistics[i])
instead?
Quoted 1 line
John Kacur
Sebastian