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 20unres() { #msg 21 reset_tracer 22 rmmod $MOD || true 23 echo $1 24 exit_unresolved 25} 26 27modprobe $MOD || unres "$MOD module not available" 28rmmod $MOD 29 30grep -q "preemptoff" available_tracers || unsup "preemptoff tracer not enabled" 31grep -q "irqsoff" available_tracers || unsup "irqsoff tracer not enabled" 32 33reset_tracer 34 35# Simulate preemptoff section for half a second couple of times 36echo preemptoff > current_tracer 37sleep 1 38modprobe $MOD test_mode=preempt delay=500000 || fail 39rmmod $MOD || fail 40modprobe $MOD test_mode=preempt delay=500000 || fail 41rmmod $MOD || fail 42modprobe $MOD test_mode=preempt delay=500000 || fail 43rmmod $MOD || fail 44 45cat trace 46 47# Confirm which tracer 48grep -q "tracer: preemptoff" trace || fail 49 50# Check the end of the section 51egrep -q "5.....us : <stack trace>" trace || fail 52 53# Check for 500ms of latency 54egrep -q "latency: 5..... us" trace || fail 55 56reset_tracer 57 58# Simulate irqsoff section for half a second couple of times 59echo irqsoff > current_tracer 60sleep 1 61modprobe $MOD test_mode=irq delay=500000 || fail 62rmmod $MOD || fail 63modprobe $MOD test_mode=irq delay=500000 || fail 64rmmod $MOD || fail 65modprobe $MOD test_mode=irq delay=500000 || fail 66rmmod $MOD || fail 67 68cat trace 69 70# Confirm which tracer 71grep -q "tracer: irqsoff" trace || fail 72 73# Check the end of the section 74egrep -q "5.....us : <stack trace>" trace || fail 75 76# Check for 500ms of latency 77egrep -q "latency: 5..... us" trace || fail 78 79reset_tracer 80exit 0 81