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