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    echo $1
12    exit_fail
13}
14
15if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
16    echo "event tracing is not supported"
17    exit_unsupported
18fi
19
20echo '*:*' > set_event
21
22yield
23
24echo 0 > tracing_on
25
26count=`head -n 128 trace | grep -v ^# | wc -l`
27if [ $count -eq 0 ]; then
28    fail "none of events are recorded"
29fi
30
31do_reset
32
33echo 1 > events/enable
34echo 1 > tracing_on
35
36yield
37
38echo 0 > tracing_on
39count=`head -n 128 trace | grep -v ^# | wc -l`
40if [ $count -eq 0 ]; then
41    fail "none of events are recorded"
42fi
43
44do_reset
45
46echo 0 > events/enable
47
48yield
49
50count=`cat trace | grep -v ^# | wc -l`
51if [ $count -ne 0 ]; then
52    fail "any of events should not be recorded"
53fi
54
55exit 0
56