xref: /linux/tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc (revision e5c86679d5e864947a52fb31e45a425dea3e7fa9)
1#!/bin/sh
2# description: event trigger - test event enable/disable trigger
3
4do_reset() {
5    reset_trigger
6    echo > set_event
7    clear_trace
8}
9
10fail() { #msg
11    do_reset
12    echo $1
13    exit $FAIL
14}
15
16if [ ! -f set_event -o ! -d events/sched ]; then
17    echo "event tracing is not supported"
18    exit_unsupported
19fi
20
21if [ ! -f events/sched/sched_process_fork/trigger ]; then
22    echo "event trigger is not supported"
23    exit_unsupported
24fi
25
26reset_tracer
27do_reset
28
29FEATURE=`grep enable_event events/sched/sched_process_fork/trigger`
30if [ -z "$FEATURE" ]; then
31    echo "event enable/disable trigger is not supported"
32    exit_unsupported
33fi
34
35echo "Test enable_event trigger"
36echo 0 > events/sched/sched_switch/enable
37echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
38( echo "forked")
39if [ `cat events/sched/sched_switch/enable` != '1*' ]; then
40    fail "enable_event trigger on sched_process_fork did not work"
41fi
42
43reset_trigger
44
45echo "Test disable_event trigger"
46echo 1 > events/sched/sched_switch/enable
47echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
48( echo "forked")
49if [ `cat events/sched/sched_switch/enable` != '0*' ]; then
50    fail "disable_event trigger on sched_process_fork did not work"
51fi
52
53reset_trigger
54
55echo "Test semantic error for event enable/disable trigger"
56! echo 'enable_event:nogroup:noevent' > events/sched/sched_process_fork/trigger
57! echo 'disable_event+1' > events/sched/sched_process_fork/trigger
58echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
59! echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
60! echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
61
62do_reset
63
64exit 0
65