1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: event tracing - enable/disable with event level files
4# flags: instance
5
6do_reset() {
7    echo > set_event
8    clear_trace
9}
10
11fail() { #msg
12    do_reset
13    echo $1
14    exit_fail
15}
16
17yield() {
18    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
19}
20
21if [ ! -f set_event -o ! -d events/sched ]; then
22    echo "event tracing is not supported"
23    exit_unsupported
24fi
25
26reset_tracer
27do_reset
28
29echo 'sched:sched_switch' > set_event
30
31yield
32
33count=`cat trace | grep sched_switch | wc -l`
34if [ $count -eq 0 ]; then
35    fail "sched_switch events are not recorded"
36fi
37
38do_reset
39
40echo 1 > events/sched/sched_switch/enable
41
42yield
43
44count=`cat trace | grep sched_switch | wc -l`
45if [ $count -eq 0 ]; then
46    fail "sched_switch events are not recorded"
47fi
48
49do_reset
50
51echo 0 > events/sched/sched_switch/enable
52
53yield
54
55count=`cat trace | grep sched_switch | wc -l`
56if [ $count -ne 0 ]; then
57    fail "sched_switch events should not be recorded"
58fi
59
60do_reset
61
62exit 0
63