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