Skip to content

Commit a86150f

Browse files
lenticularis39rostedt
authored andcommitted
rtla/tests: Test setting default options
Add function to test engine to test with pre-set osnoise options, and use it to test whether osnoise period (as an example) is set correctly. The test works by pre-setting a high period of 10 minutes and stop on threshold. Thus, it is easy to check whether rtla is properly resetting the period to default: if it is, the test will complete on time, since the first sample will overflow the threshold. If not, it will time out. Cc: Luis Goncalves <lgoncalv@redhat.com> Link: https://lore.kernel.org/20250320092500.101385-7-tglozar@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com> Reviewed-by: John Kacur <jkacur@redhat.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 6c61827 commit a86150f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tools/tracing/rtla/tests/engine.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,32 @@ check() {
6161
fi
6262
}
6363

64+
check_with_osnoise_options() {
65+
# Do the same as "check", but with pre-set osnoise options.
66+
# Note: rtla should reset the osnoise options, this is used to test
67+
# if it indeed does so.
68+
# Save original arguments
69+
arg1=$1
70+
arg2=$2
71+
72+
# Apply osnoise options (if not dry run)
73+
if [ -n "$TEST_COUNT" ]
74+
then
75+
[ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise
76+
shift
77+
while shift
78+
do
79+
[ "$1" == "" ] && continue
80+
option=$(echo $1 | cut -d '=' -f 1)
81+
value=$(echo $1 | cut -d '=' -f 2)
82+
echo "option: $option, value: $value"
83+
echo "$value" > "/sys/kernel/tracing/osnoise/$option" || return 1
84+
done
85+
fi
86+
87+
NO_RESET_OSNOISE=1 check "$arg1" "$arg2"
88+
}
89+
6490
set_timeout() {
6591
TIMEOUT="timeout -v -k 15s $1"
6692
}

tools/tracing/rtla/tests/osnoise.t

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ check "verify the --trace param" \
1616
check "verify the --entries/-E param" \
1717
"osnoise hist -P F:1 -c 0 -r 900000 -d 1M -b 10 -E 25"
1818

19+
# Test setting default period by putting an absurdly high period
20+
# and stopping on threshold.
21+
# If default period is not set, this will time out.
22+
check_with_osnoise_options "apply default period" \
23+
"osnoise hist -s 1" period_us=600000000
24+
1925
test_end

0 commit comments

Comments
 (0)