1ab16714fSTomas Glozar#!/bin/bash 2ab16714fSTomas Glozar# SPDX-License-Identifier: GPL-2.0 3ab16714fSTomas Glozarsource tests/engine.sh 4ab16714fSTomas Glozartest_begin 5ab16714fSTomas Glozar 6ab16714fSTomas Glozarset_timeout 2m 7005682b4STomas Glozartimerlat_sample_event='/sys/kernel/tracing/events/osnoise/timerlat_sample' 8ab16714fSTomas Glozar 9005682b4STomas Glozarif ldd $RTLA | grep libbpf >/dev/null && [ -d "$timerlat_sample_event" ] 10005682b4STomas Glozarthen 11005682b4STomas Glozar # rtla build with BPF and system supports BPF mode 12005682b4STomas Glozar no_bpf_options='0 1' 13005682b4STomas Glozarelse 14005682b4STomas Glozar no_bpf_options='1' 15005682b4STomas Glozarfi 16005682b4STomas Glozar 17005682b4STomas Glozar# Do every test with and without BPF 18005682b4STomas Glozarfor option in $no_bpf_options 19005682b4STomas Glozardo 20005682b4STomas Glozarexport RTLA_NO_BPF=$option 214e26f84aSTomas Glozar 224e26f84aSTomas Glozar# Basic tests 23ab16714fSTomas Glozarcheck "verify help page" \ 24*892ae5f8STomas Glozar "timerlat --help" 0 "timerlat version" 25ab16714fSTomas Glozarcheck "verify -s/--stack" \ 26*892ae5f8STomas Glozar "timerlat top -s 3 -T 10 -t" 2 "Blocking thread stack trace" 27ab16714fSTomas Glozarcheck "verify -P/--priority" \ 2804f83716STomas Glozar "timerlat top -P F:1 -c 0 -d 10s -q" 29ab16714fSTomas Glozarcheck "test in nanoseconds" \ 30*892ae5f8STomas Glozar "timerlat top -i 2 -c 0 -n -d 10s" 2 "ns" 31ab16714fSTomas Glozarcheck "set the automatic trace mode" \ 32*892ae5f8STomas Glozar "timerlat top -a 5" 2 "analyzing it" 33*892ae5f8STomas Glozarcheck "dump tasks" \ 34*892ae5f8STomas Glozar "timerlat top -a 5 --dump-tasks" 2 "Printing CPU tasks" 35ab16714fSTomas Glozarcheck "print the auto-analysis if hits the stop tracing condition" \ 3618682166SCosta Shulyupin "timerlat top --aa-only 5" 2 37ab16714fSTomas Glozarcheck "disable auto-analysis" \ 3818682166SCosta Shulyupin "timerlat top -s 3 -T 10 -t --no-aa" 2 39ab16714fSTomas Glozarcheck "verify -c/--cpus" \ 4004f83716STomas Glozar "timerlat hist -c 0 -d 10s" 41ab16714fSTomas Glozarcheck "hist test in nanoseconds" \ 42*892ae5f8STomas Glozar "timerlat hist -i 2 -c 0 -n -d 10s" 2 "ns" 434e26f84aSTomas Glozar 444e26f84aSTomas Glozar# Actions tests 454e26f84aSTomas Glozarcheck "trace output through -t" \ 464e26f84aSTomas Glozar "timerlat hist -T 2 -t" 2 "^ Saving trace to timerlat_trace.txt$" 474e26f84aSTomas Glozarcheck "trace output through -t with custom filename" \ 484e26f84aSTomas Glozar "timerlat hist -T 2 -t custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" 494e26f84aSTomas Glozarcheck "trace output through -A trace" \ 504e26f84aSTomas Glozar "timerlat hist -T 2 --on-threshold trace" 2 "^ Saving trace to timerlat_trace.txt$" 514e26f84aSTomas Glozarcheck "trace output through -A trace with custom filename" \ 524e26f84aSTomas Glozar "timerlat hist -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^ Saving trace to custom_filename.txt$" 534e26f84aSTomas Glozarcheck "exec command" \ 544e26f84aSTomas Glozar "timerlat hist -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$" 554e26f84aSTomas Glozarcheck "multiple actions" \ 564e26f84aSTomas Glozar "timerlat hist -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$" 574e26f84aSTomas Glozarcheck "hist stop at failed action" \ 584e26f84aSTomas Glozar "timerlat hist -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1# RTLA timerlat histogram$" 594e26f84aSTomas Glozarcheck "top stop at failed action" \ 604e26f84aSTomas Glozar "timerlat top -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1ALL" 614e26f84aSTomas Glozarcheck "hist with continue" \ 624e26f84aSTomas Glozar "timerlat hist -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" 634e26f84aSTomas Glozarcheck "top with continue" \ 644e26f84aSTomas Glozar "timerlat top -q -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$" 654e26f84aSTomas Glozarcheck "hist with trace output at end" \ 664e26f84aSTomas Glozar "timerlat hist -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" 674e26f84aSTomas Glozarcheck "top with trace output at end" \ 684e26f84aSTomas Glozar "timerlat top -d 1s --on-end trace" 0 "^ Saving trace to timerlat_trace.txt$" 69005682b4STomas Glozardone 70ab16714fSTomas Glozar 71ab16714fSTomas Glozartest_end 72