xref: /linux/tools/tracing/rtla/tests/timerlat.t (revision 4e26f84abfbbfa88a66f8a3b7e5ea9e494d3caf3)
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
21*4e26f84aSTomas Glozar
22*4e26f84aSTomas Glozar# Basic tests
23ab16714fSTomas Glozarcheck "verify help page" \
24ab16714fSTomas Glozar	"timerlat --help"
25ab16714fSTomas Glozarcheck "verify -s/--stack" \
2618682166SCosta Shulyupin	"timerlat top -s 3 -T 10 -t" 2
27ab16714fSTomas Glozarcheck "verify -P/--priority" \
28ab16714fSTomas Glozar	"timerlat top -P F:1 -c 0 -d 1M -q"
29ab16714fSTomas Glozarcheck "test in nanoseconds" \
3018682166SCosta Shulyupin	"timerlat top -i 2 -c 0 -n -d 30s" 2
31ab16714fSTomas Glozarcheck "set the automatic trace mode" \
3218682166SCosta Shulyupin	"timerlat top -a 5 --dump-tasks" 2
33ab16714fSTomas Glozarcheck "print the auto-analysis if hits the stop tracing condition" \
3418682166SCosta Shulyupin	"timerlat top --aa-only 5" 2
35ab16714fSTomas Glozarcheck "disable auto-analysis" \
3618682166SCosta Shulyupin	"timerlat top -s 3 -T 10 -t --no-aa" 2
37ab16714fSTomas Glozarcheck "verify -c/--cpus" \
38ab16714fSTomas Glozar	"timerlat hist -c 0 -d 30s"
39ab16714fSTomas Glozarcheck "hist test in nanoseconds" \
4018682166SCosta Shulyupin	"timerlat hist -i 2 -c 0 -n -d 30s" 2
41*4e26f84aSTomas Glozar
42*4e26f84aSTomas Glozar# Actions tests
43*4e26f84aSTomas Glozarcheck "trace output through -t" \
44*4e26f84aSTomas Glozar	"timerlat hist -T 2 -t" 2 "^  Saving trace to timerlat_trace.txt$"
45*4e26f84aSTomas Glozarcheck "trace output through -t with custom filename" \
46*4e26f84aSTomas Glozar	"timerlat hist -T 2 -t custom_filename.txt" 2 "^  Saving trace to custom_filename.txt$"
47*4e26f84aSTomas Glozarcheck "trace output through -A trace" \
48*4e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold trace" 2 "^  Saving trace to timerlat_trace.txt$"
49*4e26f84aSTomas Glozarcheck "trace output through -A trace with custom filename" \
50*4e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^  Saving trace to custom_filename.txt$"
51*4e26f84aSTomas Glozarcheck "exec command" \
52*4e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$"
53*4e26f84aSTomas Glozarcheck "multiple actions" \
54*4e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$"
55*4e26f84aSTomas Glozarcheck "hist stop at failed action" \
56*4e26f84aSTomas 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$"
57*4e26f84aSTomas Glozarcheck "top stop at failed action" \
58*4e26f84aSTomas Glozar	"timerlat top -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1ALL"
59*4e26f84aSTomas Glozarcheck "hist with continue" \
60*4e26f84aSTomas Glozar	"timerlat hist -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
61*4e26f84aSTomas Glozarcheck "top with continue" \
62*4e26f84aSTomas Glozar	"timerlat top -q -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
63*4e26f84aSTomas Glozarcheck "hist with trace output at end" \
64*4e26f84aSTomas Glozar	"timerlat hist -d 1s --on-end trace" 0 "^  Saving trace to timerlat_trace.txt$"
65*4e26f84aSTomas Glozarcheck "top with trace output at end" \
66*4e26f84aSTomas Glozar	"timerlat top -d 1s --on-end trace" 0 "^  Saving trace to timerlat_trace.txt$"
67005682b4STomas Glozardone
68ab16714fSTomas Glozar
69ab16714fSTomas Glozartest_end
70