xref: /linux/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1#!/bin/sh
2# description: event tracing - enable/disable with top 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 available_events -o ! -f set_event -o ! -d events ]; then
20    echo "event tracing is not supported"
21    exit_unsupported
22fi
23
24reset_tracer
25do_reset
26
27echo '*:*' > set_event
28
29yield
30
31count=`cat trace | grep -v ^# | wc -l`
32if [ $count -eq 0 ]; then
33    fail "none of events are recorded"
34fi
35
36do_reset
37
38echo 1 > events/enable
39
40yield
41
42count=`cat trace | grep -v ^# | wc -l`
43if [ $count -eq 0 ]; then
44    fail "none of events are recorded"
45fi
46
47do_reset
48
49echo 0 > events/enable
50
51yield
52
53count=`cat trace | grep -v ^# | wc -l`
54if [ $count -ne 0 ]; then
55    fail "any of events should not be recorded"
56fi
57
58do_reset
59
60exit 0
61