Skip to content

Commit 6c61827

Browse files
lenticularis39rostedt
authored andcommitted
rtla/tests: Reset osnoise options before check
Remove any dangling tracing instances from previous improperly exited runs of rtla, and reset osnoise options to default before running a test case. This ensures that the test results are deterministic. Specific test cases checked that rtla behaves correctly even when the tracer state is not clean will be added later. Cc: John Kacur <jkacur@redhat.com> Cc: Luis Goncalves <lgoncalv@redhat.com> Link: https://lore.kernel.org/20250320092500.101385-6-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 0122938 commit 6c61827

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tools/tracing/rtla/tests/engine.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,44 @@ test_begin() {
88
[ -n "$TEST_COUNT" ] && echo "1..$TEST_COUNT"
99
}
1010

11+
reset_osnoise() {
12+
# Reset osnoise options to default and remove any dangling instances created
13+
# by improperly exited rtla runs.
14+
pushd /sys/kernel/tracing || return 1
15+
16+
# Remove dangling instances created by previous rtla run
17+
echo 0 > tracing_thresh
18+
cd instances
19+
for i in osnoise_top osnoise_hist timerlat_top timerlat_hist
20+
do
21+
[ ! -d "$i" ] && continue
22+
rmdir "$i"
23+
done
24+
25+
# Reset options to default
26+
# Note: those are copied from the default values of osnoise_data
27+
# in kernel/trace/trace_osnoise.c
28+
cd ../osnoise
29+
echo all > cpus
30+
echo DEFAULTS > options
31+
echo 1000000 > period_us
32+
echo 0 > print_stack
33+
echo 1000000 > runtime_us
34+
echo 0 > stop_tracing_total_us
35+
echo 0 > stop_tracing_us
36+
echo 1000 > timerlat_period_us
37+
38+
popd
39+
}
40+
1141
check() {
1242
# Simple check: run rtla with given arguments and test exit code.
1343
# If TEST_COUNT is set, run the test. Otherwise, just count.
1444
ctr=$(($ctr + 1))
1545
if [ -n "$TEST_COUNT" ]
1646
then
47+
# Reset osnoise options before running test.
48+
[ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise
1749
# Run rtla; in case of failure, include its output as comment
1850
# in the test results.
1951
result=$(stdbuf -oL $TIMEOUT "$RTLA" $2 2>&1); exitcode=$?
@@ -37,6 +69,14 @@ unset_timeout() {
3769
unset TIMEOUT
3870
}
3971

72+
set_no_reset_osnoise() {
73+
NO_RESET_OSNOISE=1
74+
}
75+
76+
unset_no_reset_osnoise() {
77+
unset NO_RESET_OSNOISE
78+
}
79+
4080
test_end() {
4181
# If running without TEST_COUNT, tests are not actually run, just
4282
# counted. In that case, re-run the test with the correct count.

0 commit comments

Comments
 (0)