Commit 18682166 authored by Costa Shulyupin's avatar Costa Shulyupin Committed by Steven Rostedt (Google)
Browse files

rtla: Set distinctive exit value for failed tests

A test is considered failed when a sample trace exceeds the threshold.
Failed tests return the same exit code as passed tests, requiring test
frameworks to determine the result by searching for "hit stop tracing"
in the output.

Assign a distinct exit code for failed tests to enable the use of shell
expressions and seamless integration with testing frameworks without the
need to parse output.

Add enum type for return value.

Update `make check`.

Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: John Kacur <jkacur@redhat.com>
Cc: "Luis Claudio R. Goncalves" <lgoncalv@redhat.com>
Cc: Eder Zulian <ezulian@redhat.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Jan Stancek <jstancek@redhat.com>
Link: https://lore.kernel.org/20250417185757.2194541-1-costa.shul@redhat.com


Signed-off-by: default avatarCosta Shulyupin <costa.shul@redhat.com>
Reviewed-by: default avatarTomas Glozar <tglozar@redhat.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 92a09c47
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -766,8 +766,8 @@ int osnoise_hist_main(int argc, char *argv[])
	struct osnoise_params *params;
	struct osnoise_tool *record = NULL;
	struct osnoise_tool *tool = NULL;
	enum result return_value = ERROR;
	struct trace_instance *trace;
	int return_value = 1;
	int retval;

	params = osnoise_hist_parse_args(argc, argv);
@@ -889,12 +889,13 @@ int osnoise_hist_main(int argc, char *argv[])

	osnoise_print_stats(params, tool);

	return_value = 0;
	return_value = PASSED;

	if (osnoise_trace_is_off(tool, record)) {
		printf("rtla osnoise hit stop tracing\n");
		save_trace_to_file(record ? record->trace.inst : NULL,
				   params->trace_output);
		return_value = FAILED;
	}

out_hist:
+3 −2
Original line number Diff line number Diff line
@@ -594,8 +594,8 @@ int osnoise_top_main(int argc, char **argv)
	struct osnoise_params *params;
	struct osnoise_tool *record = NULL;
	struct osnoise_tool *tool = NULL;
	enum result return_value = ERROR;
	struct trace_instance *trace;
	int return_value = 1;
	int retval;

	params = osnoise_top_parse_args(argc, argv);
@@ -715,12 +715,13 @@ int osnoise_top_main(int argc, char **argv)

	osnoise_print_stats(params, tool);

	return_value = 0;
	return_value = PASSED;

	if (osnoise_trace_is_off(tool, record)) {
		printf("osnoise hit stop tracing\n");
		save_trace_to_file(record ? record->trace.inst : NULL,
				   params->trace_output);
		return_value = FAILED;
	}

out_top:
+3 −2
Original line number Diff line number Diff line
@@ -1141,11 +1141,11 @@ int timerlat_hist_main(int argc, char *argv[])
	struct timerlat_params *params;
	struct osnoise_tool *record = NULL;
	struct timerlat_u_params params_u;
	enum result return_value = ERROR;
	struct osnoise_tool *tool = NULL;
	struct osnoise_tool *aa = NULL;
	struct trace_instance *trace;
	int dma_latency_fd = -1;
	int return_value = 1;
	pthread_t timerlat_u;
	int retval;
	int nr_cpus, i;
@@ -1378,7 +1378,7 @@ int timerlat_hist_main(int argc, char *argv[])

	timerlat_print_stats(params, tool);

	return_value = 0;
	return_value = PASSED;

	if (osnoise_trace_is_off(tool, record) && !stop_tracing) {
		printf("rtla timerlat hit stop tracing\n");
@@ -1388,6 +1388,7 @@ int timerlat_hist_main(int argc, char *argv[])

		save_trace_to_file(record ? record->trace.inst : NULL,
				   params->trace_output);
		return_value = FAILED;
	}

out_hist:
+3 −2
Original line number Diff line number Diff line
@@ -985,12 +985,12 @@ int timerlat_top_main(int argc, char *argv[])
	struct timerlat_params *params;
	struct osnoise_tool *record = NULL;
	struct timerlat_u_params params_u;
	enum result return_value = ERROR;
	struct osnoise_tool *top = NULL;
	struct osnoise_tool *aa = NULL;
	struct trace_instance *trace;
	int dma_latency_fd = -1;
	pthread_t timerlat_u;
	int return_value = 1;
	char *max_lat;
	int retval;
	int nr_cpus, i;
@@ -1197,7 +1197,7 @@ int timerlat_top_main(int argc, char *argv[])

	timerlat_print_stats(params, top);

	return_value = 0;
	return_value = PASSED;

	if (osnoise_trace_is_off(top, record) && !stop_tracing) {
		printf("rtla timerlat hit stop tracing\n");
@@ -1207,6 +1207,7 @@ int timerlat_top_main(int argc, char *argv[])

		save_trace_to_file(record ? record->trace.inst : NULL,
				   params->trace_output);
		return_value = FAILED;
	} else if (params->aa_only) {
		/*
		 * If the trace did not stop with --aa-only, at least print the
+6 −0
Original line number Diff line number Diff line
@@ -83,3 +83,9 @@ int auto_house_keeping(cpu_set_t *monitored_cpus);

#define ns_to_usf(x) (((double)x/1000))
#define ns_to_per(total, part) ((part * 100) / (double)total)

enum result {
	PASSED = 0, /* same as EXIT_SUCCESS */
	ERROR = 1,  /* same as EXIT_FAILURE, an error in arguments */
	FAILED = 2, /* test hit the stop tracing condition */
};
Loading