Skip to content

Commit ee666a1

Browse files
committed
tracing: Skip selftests if tracing is disabled
If tracing is disabled for some reason (traceoff_on_warning, command line, etc), the ftrace selftests are guaranteed to fail, as their results are defined by trace data in the ring buffers. If the ring buffers are turned off, the tests will fail, due to lack of data. Because tracing being disabled is for a specific reason (warning, user decided to, etc), it does not make sense to enable tracing to run the self tests, as the test output may corrupt the reason for the tracing to be disabled. Instead, simply skip the self tests and report that they are being skipped due to tracing being disabled. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent f40fc79 commit ee666a1

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

kernel/trace/trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,12 @@ static int run_tracer_selftest(struct tracer *type)
19291929
if (!selftests_can_run)
19301930
return save_selftest(type);
19311931

1932+
if (!tracing_is_on()) {
1933+
pr_warn("Selftest for tracer %s skipped due to tracing disabled\n",
1934+
type->name);
1935+
return 0;
1936+
}
1937+
19321938
/*
19331939
* Run a selftest on this tracer.
19341940
* Here we reset the trace buffer, and set the current

0 commit comments

Comments
 (0)