xref: /linux/tools/tracing/rtla/tests/timerlat.t (revision 04f837165b9480d6d6d8b00bbc1298762f3f0e4d)
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" \
24ab16714fSTomas Glozar	"timerlat --help"
25ab16714fSTomas Glozarcheck "verify -s/--stack" \
2618682166SCosta Shulyupin	"timerlat top -s 3 -T 10 -t" 2
27ab16714fSTomas Glozarcheck "verify -P/--priority" \
28*04f83716STomas Glozar	"timerlat top -P F:1 -c 0 -d 10s -q"
29ab16714fSTomas Glozarcheck "test in nanoseconds" \
30*04f83716STomas Glozar	"timerlat top -i 2 -c 0 -n -d 10s" 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" \
38*04f83716STomas Glozar	"timerlat hist -c 0 -d 10s"
39ab16714fSTomas Glozarcheck "hist test in nanoseconds" \
40*04f83716STomas Glozar	"timerlat hist -i 2 -c 0 -n -d 10s" 2
414e26f84aSTomas Glozar
424e26f84aSTomas Glozar# Actions tests
434e26f84aSTomas Glozarcheck "trace output through -t" \
444e26f84aSTomas Glozar	"timerlat hist -T 2 -t" 2 "^  Saving trace to timerlat_trace.txt$"
454e26f84aSTomas Glozarcheck "trace output through -t with custom filename" \
464e26f84aSTomas Glozar	"timerlat hist -T 2 -t custom_filename.txt" 2 "^  Saving trace to custom_filename.txt$"
474e26f84aSTomas Glozarcheck "trace output through -A trace" \
484e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold trace" 2 "^  Saving trace to timerlat_trace.txt$"
494e26f84aSTomas Glozarcheck "trace output through -A trace with custom filename" \
504e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold trace,file=custom_filename.txt" 2 "^  Saving trace to custom_filename.txt$"
514e26f84aSTomas Glozarcheck "exec command" \
524e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$"
534e26f84aSTomas Glozarcheck "multiple actions" \
544e26f84aSTomas Glozar	"timerlat hist -T 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$"
554e26f84aSTomas Glozarcheck "hist stop at failed action" \
564e26f84aSTomas 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$"
574e26f84aSTomas Glozarcheck "top stop at failed action" \
584e26f84aSTomas Glozar	"timerlat top -T 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1ALL"
594e26f84aSTomas Glozarcheck "hist with continue" \
604e26f84aSTomas Glozar	"timerlat hist -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
614e26f84aSTomas Glozarcheck "top with continue" \
624e26f84aSTomas Glozar	"timerlat top -q -T 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
634e26f84aSTomas Glozarcheck "hist with trace output at end" \
644e26f84aSTomas Glozar	"timerlat hist -d 1s --on-end trace" 0 "^  Saving trace to timerlat_trace.txt$"
654e26f84aSTomas Glozarcheck "top with trace output at end" \
664e26f84aSTomas Glozar	"timerlat top -d 1s --on-end trace" 0 "^  Saving trace to timerlat_trace.txt$"
67005682b4STomas Glozardone
68ab16714fSTomas Glozar
69ab16714fSTomas Glozartest_end
70