]>
Commit | Line | Data |
---|---|---|
2c6c3946 | 1 | #!/bin/sh |
b2441318 | 2 | # SPDX-License-Identifier: GPL-2.0 |
2c6c3946 | 3 | # description: event tracing - restricts events based on pid |
35df6a89 | 4 | # flags: instance |
2c6c3946 NK |
5 | |
6 | do_reset() { | |
7 | echo > set_event | |
8 | echo > set_event_pid | |
9 | echo 0 > options/event-fork | |
10 | clear_trace | |
11 | } | |
12 | ||
13 | fail() { #msg | |
14 | do_reset | |
15 | echo $1 | |
16 | exit $FAIL | |
17 | } | |
18 | ||
19 | yield() { | |
20 | ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 | |
21 | } | |
22 | ||
23 | if [ ! -f set_event -o ! -d events/sched ]; then | |
24 | echo "event tracing is not supported" | |
25 | exit_unsupported | |
26 | fi | |
27 | ||
28 | if [ ! -f set_event_pid ]; then | |
29 | echo "event pid filtering is not supported" | |
30 | exit_unsupported | |
31 | fi | |
32 | ||
33 | reset_tracer | |
34 | do_reset | |
35 | ||
36 | echo 1 > events/sched/sched_switch/enable | |
37 | ||
38 | yield | |
39 | ||
40 | count=`cat trace | grep sched_switch | wc -l` | |
41 | if [ $count -eq 0 ]; then | |
42 | fail "sched_switch events are not recorded" | |
43 | fi | |
44 | ||
45 | do_reset | |
46 | ||
47 | read mypid rest < /proc/self/stat | |
48 | ||
49 | echo $mypid > set_event_pid | |
50 | echo 'sched:sched_switch' > set_event | |
51 | ||
52 | yield | |
53 | ||
54 | count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` | |
55 | if [ $count -ne 0 ]; then | |
56 | fail "sched_switch events from other task are recorded" | |
57 | fi | |
58 | ||
59 | do_reset | |
60 | ||
61 | echo $mypid > set_event_pid | |
62 | echo 1 > options/event-fork | |
63 | echo 1 > events/sched/sched_switch/enable | |
64 | ||
65 | yield | |
66 | ||
67 | count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` | |
68 | if [ $count -eq 0 ]; then | |
69 | fail "sched_switch events from other task are not recorded" | |
70 | fi | |
71 | ||
72 | do_reset | |
73 | ||
74 | exit 0 |