diff options
Diffstat (limited to 'tools/tracing/rtla/tests')
-rw-r--r-- | tools/tracing/rtla/tests/engine.sh | 66 | ||||
-rw-r--r-- | tools/tracing/rtla/tests/osnoise.t | 6 | ||||
-rw-r--r-- | tools/tracing/rtla/tests/timerlat.t | 14 |
3 files changed, 86 insertions, 0 deletions
diff --git a/tools/tracing/rtla/tests/engine.sh b/tools/tracing/rtla/tests/engine.sh index 64d0446dc28e..b1697b3e3f52 100644 --- a/tools/tracing/rtla/tests/engine.sh +++ b/tools/tracing/rtla/tests/engine.sh @@ -8,12 +8,44 @@ test_begin() { [ -n "$TEST_COUNT" ] && echo "1..$TEST_COUNT" } +reset_osnoise() { + # Reset osnoise options to default and remove any dangling instances created + # by improperly exited rtla runs. + pushd /sys/kernel/tracing || return 1 + + # Remove dangling instances created by previous rtla run + echo 0 > tracing_thresh + cd instances + for i in osnoise_top osnoise_hist timerlat_top timerlat_hist + do + [ ! -d "$i" ] && continue + rmdir "$i" + done + + # Reset options to default + # Note: those are copied from the default values of osnoise_data + # in kernel/trace/trace_osnoise.c + cd ../osnoise + echo all > cpus + echo DEFAULTS > options + echo 1000000 > period_us + echo 0 > print_stack + echo 1000000 > runtime_us + echo 0 > stop_tracing_total_us + echo 0 > stop_tracing_us + echo 1000 > timerlat_period_us + + popd +} + check() { # Simple check: run rtla with given arguments and test exit code. # If TEST_COUNT is set, run the test. Otherwise, just count. ctr=$(($ctr + 1)) if [ -n "$TEST_COUNT" ] then + # Reset osnoise options before running test. + [ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise # Run rtla; in case of failure, include its output as comment # in the test results. result=$(stdbuf -oL $TIMEOUT "$RTLA" $2 2>&1); exitcode=$? @@ -29,6 +61,32 @@ check() { fi } +check_with_osnoise_options() { + # Do the same as "check", but with pre-set osnoise options. + # Note: rtla should reset the osnoise options, this is used to test + # if it indeed does so. + # Save original arguments + arg1=$1 + arg2=$2 + + # Apply osnoise options (if not dry run) + if [ -n "$TEST_COUNT" ] + then + [ "$NO_RESET_OSNOISE" == 1 ] || reset_osnoise + shift + while shift + do + [ "$1" == "" ] && continue + option=$(echo $1 | cut -d '=' -f 1) + value=$(echo $1 | cut -d '=' -f 2) + echo "option: $option, value: $value" + echo "$value" > "/sys/kernel/tracing/osnoise/$option" || return 1 + done + fi + + NO_RESET_OSNOISE=1 check "$arg1" "$arg2" +} + set_timeout() { TIMEOUT="timeout -v -k 15s $1" } @@ -37,6 +95,14 @@ unset_timeout() { unset TIMEOUT } +set_no_reset_osnoise() { + NO_RESET_OSNOISE=1 +} + +unset_no_reset_osnoise() { + unset NO_RESET_OSNOISE +} + test_end() { # If running without TEST_COUNT, tests are not actually run, just # counted. In that case, re-run the test with the correct count. diff --git a/tools/tracing/rtla/tests/osnoise.t b/tools/tracing/rtla/tests/osnoise.t index 86596e547893..e5995c03c790 100644 --- a/tools/tracing/rtla/tests/osnoise.t +++ b/tools/tracing/rtla/tests/osnoise.t @@ -16,4 +16,10 @@ check "verify the --trace param" \ check "verify the --entries/-E param" \ "osnoise hist -P F:1 -c 0 -r 900000 -d 1M -b 10 -E 25" +# Test setting default period by putting an absurdly high period +# and stopping on threshold. +# If default period is not set, this will time out. +check_with_osnoise_options "apply default period" \ + "osnoise hist -s 1" period_us=600000000 + test_end diff --git a/tools/tracing/rtla/tests/timerlat.t b/tools/tracing/rtla/tests/timerlat.t index e86f40e5749e..e939ff71d6be 100644 --- a/tools/tracing/rtla/tests/timerlat.t +++ b/tools/tracing/rtla/tests/timerlat.t @@ -4,7 +4,20 @@ source tests/engine.sh test_begin set_timeout 2m +timerlat_sample_event='/sys/kernel/tracing/events/osnoise/timerlat_sample' +if ldd $RTLA | grep libbpf >/dev/null && [ -d "$timerlat_sample_event" ] +then + # rtla build with BPF and system supports BPF mode + no_bpf_options='0 1' +else + no_bpf_options='1' +fi + +# Do every test with and without BPF +for option in $no_bpf_options +do +export RTLA_NO_BPF=$option check "verify help page" \ "timerlat --help" check "verify -s/--stack" \ @@ -23,5 +36,6 @@ check "verify -c/--cpus" \ "timerlat hist -c 0 -d 30s" check "hist test in nanoseconds" \ "timerlat hist -i 2 -c 0 -n -d 30s" +done test_end |