xref: /linux/tools/tracing/rtla/tests/osnoise.t (revision 68a052239fc4b351e961f698b824f7654a346091)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3source tests/engine.sh
4test_begin
5
6set_timeout 2m
7
8check "verify help page" \
9	"osnoise --help" 0 "osnoise version"
10check "verify the --priority/-P param" \
11	"osnoise top -P F:1 -c 0 -r 900000 -d 10s -q -S 1 --on-threshold shell,command=\"tests/scripts/check-priority.sh osnoise/ SCHED_FIFO 1\"" \
12	2 "Priorities are set correctly"
13check "verify the --stop/-s param" \
14	"osnoise top -s 30 -T 1" 2 "osnoise hit stop tracing"
15check "verify the  --trace param" \
16	"osnoise hist -s 30 -T 1 -t" 2 "Saving trace to osnoise_trace.txt"
17check "verify the --entries/-E param" \
18	"osnoise hist -P F:1 -c 0 -r 900000 -d 10s -b 10 -E 25"
19
20# Test setting default period by putting an absurdly high period
21# and stopping on threshold.
22# If default period is not set, this will time out.
23check_with_osnoise_options "apply default period" \
24	"osnoise hist -s 1" 2 period_us=600000000
25
26# Actions tests
27check "trace output through -t with custom filename" \
28	"osnoise hist -S 2 -t custom_filename.txt" 2 "^  Saving trace to custom_filename.txt$"
29check "trace output through --on-threshold trace" \
30	"osnoise hist -S 2 --on-threshold trace" 2 "^  Saving trace to osnoise_trace.txt$"
31check "trace output through --on-threshold trace with custom filename" \
32	"osnoise hist -S 2 --on-threshold trace,file=custom_filename.txt" 2 "^  Saving trace to custom_filename.txt$"
33check "exec command" \
34	"osnoise hist -S 2 --on-threshold shell,command='echo TestOutput'" 2 "^TestOutput$"
35check "multiple actions" \
36	"osnoise hist -S 2 --on-threshold shell,command='echo -n 1' --on-threshold shell,command='echo 2'" 2 "^12$"
37check "hist stop at failed action" \
38	"osnoise hist -S 2 --on-threshold shell,command='echo -n 1; false' --on-threshold shell,command='echo -n 2'" 2 "^1# RTLA osnoise histogram$"
39check "top stop at failed action" \
40	"timerlat top -T 2 --on-threshold shell,command='echo -n abc; false' --on-threshold shell,command='echo -n defgh'" 2 "^abc" "defgh"
41check "hist with continue" \
42	"osnoise hist -S 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
43check "top with continue" \
44	"osnoise top -q -S 2 -d 1s --on-threshold shell,command='echo TestOutput' --on-threshold continue" 0 "^TestOutput$"
45check "hist with trace output at end" \
46	"osnoise hist -d 1s --on-end trace" 0 "^  Saving trace to osnoise_trace.txt$"
47check "top with trace output at end" \
48	"osnoise top -d 1s --on-end trace" 0 "^  Saving trace to osnoise_trace.txt$"
49
50test_end
51