]>
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 | |
42534b1f | 16 | exit_fail |
2c6c3946 NK |
17 | } |
18 | ||
2c6c3946 NK |
19 | if [ ! -f set_event -o ! -d events/sched ]; then |
20 | echo "event tracing is not supported" | |
21 | exit_unsupported | |
22 | fi | |
23 | ||
24 | if [ ! -f set_event_pid ]; then | |
25 | echo "event pid filtering is not supported" | |
26 | exit_unsupported | |
27 | fi | |
28 | ||
e527c470 | 29 | echo 0 > options/event-fork |
2c6c3946 NK |
30 | |
31 | echo 1 > events/sched/sched_switch/enable | |
32 | ||
33 | yield | |
34 | ||
35 | count=`cat trace | grep sched_switch | wc -l` | |
36 | if [ $count -eq 0 ]; then | |
37 | fail "sched_switch events are not recorded" | |
38 | fi | |
39 | ||
40 | do_reset | |
41 | ||
42 | read mypid rest < /proc/self/stat | |
43 | ||
44 | echo $mypid > set_event_pid | |
45 | echo 'sched:sched_switch' > set_event | |
46 | ||
47 | yield | |
48 | ||
49 | count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` | |
50 | if [ $count -ne 0 ]; then | |
51 | fail "sched_switch events from other task are recorded" | |
52 | fi | |
53 | ||
54 | do_reset | |
55 | ||
56 | echo $mypid > set_event_pid | |
57 | echo 1 > options/event-fork | |
58 | echo 1 > events/sched/sched_switch/enable | |
59 | ||
60 | yield | |
61 | ||
62 | count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` | |
63 | if [ $count -eq 0 ]; then | |
64 | fail "sched_switch events from other task are not recorded" | |
65 | fi | |
66 | ||
67 | do_reset | |
68 | ||
69 | exit 0 |