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