]> git.ipfire.org Git - thirdparty/linux.git/blame - tools/testing/selftests/ftrace/test.d/event/event-pid.tc
selftests/ftrace: Use loopback address instead of localhost
[thirdparty/linux.git] / tools / testing / selftests / ftrace / test.d / event / event-pid.tc
CommitLineData
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
6do_reset() {
7 echo > set_event
8 echo > set_event_pid
9 echo 0 > options/event-fork
10 clear_trace
11}
12
13fail() { #msg
14 do_reset
15 echo $1
42534b1f 16 exit_fail
2c6c3946
NK
17}
18
2c6c3946
NK
19if [ ! -f set_event -o ! -d events/sched ]; then
20 echo "event tracing is not supported"
21 exit_unsupported
22fi
23
24if [ ! -f set_event_pid ]; then
25 echo "event pid filtering is not supported"
26 exit_unsupported
27fi
28
e527c470 29echo 0 > options/event-fork
2c6c3946
NK
30
31echo 1 > events/sched/sched_switch/enable
32
33yield
34
35count=`cat trace | grep sched_switch | wc -l`
36if [ $count -eq 0 ]; then
37 fail "sched_switch events are not recorded"
38fi
39
40do_reset
41
42read mypid rest < /proc/self/stat
43
44echo $mypid > set_event_pid
45echo 'sched:sched_switch' > set_event
46
47yield
48
49count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l`
50if [ $count -ne 0 ]; then
51 fail "sched_switch events from other task are recorded"
52fi
53
54do_reset
55
56echo $mypid > set_event_pid
57echo 1 > options/event-fork
58echo 1 > events/sched/sched_switch/enable
59
60yield
61
62count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l`
63if [ $count -eq 0 ]; then
64 fail "sched_switch events from other task are not recorded"
65fi
66
67do_reset
68
69exit 0