1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3source tests/engine.sh 4test_begin 5 6set_timeout 2m 7timerlat_sample_event='/sys/kernel/tracing/events/osnoise/timerlat_sample' 8 9if ldd $RTLA | grep libbpf >/dev/null && [ -d "$timerlat_sample_event" ] 10then 11 # rtla build with BPF and system supports BPF mode 12 no_bpf_options='0 1' 13else 14 no_bpf_options='1' 15fi 16 17# Do every test with and without BPF 18for option in $no_bpf_options 19do 20export RTLA_NO_BPF=$option 21 22# Basic tests 23check "verify help page" \ 24 "timerlat --help" 25check "verify -s/--stack" \ 26 "timerlat top -s 3 -T 10 -t" 2 27check "verify -P/--priority" \ 28 "timerlat top -P F:1 -c 0 -d 10s -q" 29check "test in nanoseconds" \ 30 "timerlat top -i 2 -c 0 -n -d 10s" 2 31check "set the automatic trace mode" \ 32 "timerlat top -a 5 --dump-tasks" 2 33check "print the auto-analysis if hits the stop tracing condition" \ 34 "timerlat top --aa-only 5" 2 35check "disable auto-analysis" \ 36 "timerlat top -s 3 -T 10 -t --no-aa" 2 37check "verify -c/--cpus" \ 38 "timerlat hist -c 0 -d 10s" 39check "hist test in nanoseconds" \ 40 "timerlat hist -i 2 -c 0 -n -d 10s" 2 41 42# Actions tests 43check "trace output through -t" \ 44 "timerlat hist -T 2 -t" 2 "^ Saving trace to timerlat_trace.txt$" 45check "trace output through -t with custom filename" \ 46 "timerlat hist -T 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" 47check "trace output through -A trace" \ 48 "timerlat hist -T 2 --on-threshold trace" 2 "^ Saving trace to timerlat_trace.txt$" 49check "trace output through -A trace with custom filename" \ 50 "timerlat hist -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" 51check "exec command" \ 52 "timerlat hist -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$" 53check "multiple actions" \ 54 "timerlat hist -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$" 55check "hist stop at failed action" \ 56 "timerlat hist -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1# RTLA timerlat histogram$" 57check "top stop at failed action" \ 58 "timerlat top -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1ALL" 59check "hist with continue" \ 60 "timerlat hist -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" 61check "top with continue" \ 62 "timerlat top -q -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" 63check "hist with trace output at end" \ 64 "timerlat hist -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" 65check "top with trace output at end" \ 66 "timerlat top -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" 67done 68 69test_end 70