xref: /linux/tools/testing/selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc (revision e9f0878c4b2004ac19581274c1ae4c61ae3ca70e)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: test for the preemptirqsoff tracer
4
5MOD=preemptirq_delay_test
6
7fail() {
8    reset_tracer
9    rmmod $MOD || true
10    exit_fail
11}
12
13unsup() { #msg
14    reset_tracer
15    rmmod $MOD || true
16    echo $1
17    exit_unsupported
18}
19
20modprobe $MOD || unsup "$MOD module not available"
21rmmod $MOD
22
23grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled"
24grep -q "irqsoff" available_tracers || unsup "irqsoff tracer not enabled"
25
26reset_tracer
27
28# Simulate preemptoff section for half a second couple of times
29echo preemptoff > current_tracer
30sleep 1
31modprobe $MOD test_mode=preempt delay=500000 || fail
32rmmod $MOD || fail
33modprobe $MOD test_mode=preempt delay=500000 || fail
34rmmod $MOD || fail
35modprobe $MOD test_mode=preempt delay=500000 || fail
36rmmod $MOD || fail
37
38cat trace
39
40# Confirm which tracer
41grep -q "tracer: preemptoff" trace || fail
42
43# Check the end of the section
44egrep -q "5.....us : <stack trace>" trace || fail
45
46# Check for 500ms of latency
47egrep -q "latency: 5..... us" trace || fail
48
49reset_tracer
50
51# Simulate irqsoff section for half a second couple of times
52echo irqsoff > current_tracer
53sleep 1
54modprobe $MOD test_mode=irq delay=500000 || fail
55rmmod $MOD || fail
56modprobe $MOD test_mode=irq delay=500000 || fail
57rmmod $MOD || fail
58modprobe $MOD test_mode=irq delay=500000 || fail
59rmmod $MOD || fail
60
61cat trace
62
63# Confirm which tracer
64grep -q "tracer: irqsoff" trace || fail
65
66# Check the end of the section
67egrep -q "5.....us : <stack trace>" trace || fail
68
69# Check for 500ms of latency
70egrep -q "latency: 5..... us" trace || fail
71
72reset_tracer
73exit 0
74