All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] cyclictest, cyclicdeadline: Exit with failure when breaktrace threshold is exceeded
@ 2026-08-06 12:07 Costa Shulyupin
  2026-08-14  9:08 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Costa Shulyupin @ 2026-08-06 12:07 UTC (permalink / raw)
  To: John Kacur, Ahmed S. Darwish,
	Thomas Weißschuh (Schneider Electric), Costa Shulyupin,
	Sebastian Andrzej Siewior, Lukas Beckmann, Cheng-Yang Chou
  Cc: linux-rt-users

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.

Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>

---
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(-)

diff --git a/src/cyclictest/cyclictest.8 b/src/cyclictest/cyclictest.8
index fc6121aa4d47..813c61653f61 100644
--- a/src/cyclictest/cyclictest.8
+++ b/src/cyclictest/cyclictest.8
@@ -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 ,
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 71cf5cb25c22..88fc08347cba 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -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;
 		}
 	}
 
diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8
index bfc6327c51da..cd7088629d97 100644
--- a/src/sched_deadline/cyclicdeadline.8
+++ b/src/sched_deadline/cyclicdeadline.8
@@ -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 <rostedt@goodmis.org>
 .PP
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 0c6c96976010..1123de4f4cae 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -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;
 }
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] cyclictest, cyclicdeadline: Exit with failure when breaktrace threshold is exceeded
  2026-08-06 12:07 [PATCH v2] cyclictest, cyclicdeadline: Exit with failure when breaktrace threshold is exceeded Costa Shulyupin
@ 2026-08-14  9:08 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-08-14  9:08 UTC (permalink / raw)
  To: Costa Shulyupin
  Cc: John Kacur, Ahmed S. Darwish,
	Thomas Weißschuh (Schneider Electric), Lukas Beckmann,
	Cheng-Yang Chou, linux-rt-users

On 2026-08-06 15:07:31 [+0300], Costa Shulyupin wrote:
> 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

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.

> 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-6
> Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>

Sebastian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-14  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06 12:07 [PATCH v2] cyclictest, cyclicdeadline: Exit with failure when breaktrace threshold is exceeded Costa Shulyupin
2026-08-14  9:08 ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.