1#!/bin/sh
2# description: event tracing - enable/disable with subsystem 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:*' > set_event
28
29yield
30
31count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
32if [ $count -lt 3 ]; then
33    fail "at least fork, exec and exit events should be recorded"
34fi
35
36do_reset
37
38echo 1 > events/sched/enable
39
40yield
41
42count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
43if [ $count -lt 3 ]; then
44    fail "at least fork, exec and exit events should be recorded"
45fi
46
47do_reset
48
49echo 0 > events/sched/enable
50
51yield
52
53count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
54if [ $count -ne 0 ]; then
55    fail "any of scheduler events should not be recorded"
56fi
57
58do_reset
59
60exit 0
61