xref: /linux/tools/tracing/rtla/tests/timerlat.t (revision 5172a777248e56dbae22b55231d24c7ecc6393f9)
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" \
24892ae5f8STomas Glozar	"timerlat --help" 0 "timerlat version"
25ab16714fSTomas Glozarcheck "verify -s/--stack" \
26892ae5f8STomas Glozar	"timerlat top -s 3 -T 10 -t" 2 "Blocking thread stack trace"
27ab16714fSTomas Glozarcheck "verify -P/--priority" \
28*a80db1f8STomas Glozar	"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*a80db1f8STomas Glozar	2 "Priorities are set correctly"
30ab16714fSTomas Glozarcheck "test in nanoseconds" \
31892ae5f8STomas Glozar	"timerlat top -i 2 -c 0 -n -d 10s" 2 "ns"
32ab16714fSTomas Glozarcheck "set the automatic trace mode" \
33892ae5f8STomas Glozar	"timerlat top -a 5" 2 "analyzing it"
34892ae5f8STomas Glozarcheck "dump tasks" \
35892ae5f8STomas Glozar	"timerlat top -a 5 --dump-tasks" 2 "Printing CPU tasks"
36ab16714fSTomas Glozarcheck "print the auto-analysis if hits the stop tracing condition" \
3718682166SCosta Shulyupin	"timerlat top --aa-only 5" 2
38ab16714fSTomas Glozarcheck "disable auto-analysis" \
3918682166SCosta Shulyupin	"timerlat top -s 3 -T 10 -t --no-aa" 2
40ab16714fSTomas Glozarcheck "verify -c/--cpus" \
4104f83716STomas Glozar	"timerlat hist -c 0 -d 10s"
42ab16714fSTomas Glozarcheck "hist test in nanoseconds" \
43892ae5f8STomas Glozar	"timerlat hist -i 2 -c 0 -n -d 10s" 2 "ns"
444e26f84aSTomas Glozar
454e26f84aSTomas Glozar# Actions tests
464e26f84aSTomas Glozarcheck "trace output through -t" \
474e26f84aSTomas Glozar	"timerlat hist -T 2 -t" 2 "^  Saving trace to timerlat_trace.txt$"
484e26f84aSTomas Glozarcheck "trace output through -t with custom filename" \
494e26f84aSTomas Glozar	"timerlat hist -T 2 -t custom_filename.txt" 2 "^  Saving trace to custom_filename.txt$"
504e26f84aSTomas Glozarcheck "trace output through -A trace" \
514e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold trace" 2 "^  Saving trace to timerlat_trace.txt$"
524e26f84aSTomas Glozarcheck "trace output through -A trace with custom filename" \
534e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^  Saving trace to custom_filename.txt$"
544e26f84aSTomas Glozarcheck "exec command" \
554e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$"
564e26f84aSTomas Glozarcheck "multiple actions" \
574e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$"
584e26f84aSTomas Glozarcheck "hist stop at failed action" \
594e26f84aSTomas 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$"
604e26f84aSTomas Glozarcheck "top stop at failed action" \
614e26f84aSTomas Glozar	"timerlat top -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1ALL"
624e26f84aSTomas Glozarcheck "hist with continue" \
634e26f84aSTomas Glozar	"timerlat hist -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
644e26f84aSTomas Glozarcheck "top with continue" \
654e26f84aSTomas Glozar	"timerlat top -q -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
664e26f84aSTomas Glozarcheck "hist with trace output at end" \
674e26f84aSTomas Glozar	"timerlat hist -d 1s --on-end trace" 0 "^  Saving trace to timerlat_trace.txt$"
684e26f84aSTomas Glozarcheck "top with trace output at end" \
694e26f84aSTomas Glozar	"timerlat top -d 1s --on-end trace" 0 "^  Saving trace to timerlat_trace.txt$"
70005682b4STomas Glozardone
71ab16714fSTomas Glozar
72ab16714fSTomas Glozartest_end
73