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