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