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" 0 "timerlat version" 25check "verify -s/--stack" \ 26 "timerlat top -s 3 -T 10 -t" 2 "Blocking thread stack trace" 27check "verify -P/--priority" \ 28 "timerlat top -P F:1 -c 0 -d 10s -q -T 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh timerlatu/ SCHED_FIFO 1\"" \ 29 2 "Priorities are set correctly" 30check "test in nanoseconds" \ 31 "timerlat top -i 2 -c 0 -n -d 10s" 2 "ns" 32check "set the automatic trace mode" \ 33 "timerlat top -a 5" 2 "analyzing it" 34check "dump tasks" \ 35 "timerlat top -a 5 --dump-tasks" 2 "Printing CPU tasks" 36check "print the auto-analysis if hits the stop tracing condition" \ 37 "timerlat top --aa-only 5" 2 38check "disable auto-analysis" \ 39 "timerlat top -s 3 -T 10 -t --no-aa" 2 40check "verify -c/--cpus" \ 41 "timerlat hist -c 0 -d 10s" 42check "hist test in nanoseconds" \ 43 "timerlat hist -i 2 -c 0 -n -d 10s" 2 "ns" 44 45# Actions tests 46check "trace output through -t" \ 47 "timerlat hist -T 2 -t" 2 "^ Saving trace to timerlat_trace.txt$" 48check "trace output through -t with custom filename" \ 49 "timerlat hist -T 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" 50check "trace output through -A trace" \ 51 "timerlat hist -T 2 --on-threshold trace" 2 "^ Saving trace to timerlat_trace.txt$" 52check "trace output through -A trace with custom filename" \ 53 "timerlat hist -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" 54check "exec command" \ 55 "timerlat hist -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$" 56check "multiple actions" \ 57 "timerlat hist -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$" 58check "hist stop at failed action" \ 59 "timerlat hist -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1# RTLA timerlat histogram$" 60check "top stop at failed action" \ 61 "timerlat top -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1ALL" 62check "hist with continue" \ 63 "timerlat hist -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" 64check "top with continue" \ 65 "timerlat top -q -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" 66check "hist with trace output at end" \ 67 "timerlat hist -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" 68check "top with trace output at end" \ 69 "timerlat top -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" 70done 71 72test_end 73