xref: /linux/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc (revision f3a8b6645dc2e60d11f20c1c23afd964ff4e55ae)
1#!/bin/sh
2# description: event trigger - test snapshot-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 snapshot events/sched/sched_process_fork/trigger`
30if [ -z "$FEATURE" ]; then
31    echo "snapshot trigger is not supported"
32    exit_unsupported
33fi
34
35echo "Test snapshot tigger"
36echo 0 > snapshot
37echo 1 > events/sched/sched_process_fork/enable
38( echo "forked")
39echo 'snapshot:1' > events/sched/sched_process_fork/trigger
40( echo "forked")
41grep sched_process_fork snapshot > /dev/null || \
42    fail "snapshot trigger on sched_process_fork did not work"
43
44reset_trigger
45echo 0 > snapshot
46echo 0 > events/sched/sched_process_fork/enable
47
48echo "Test snapshot semantic errors"
49
50! echo "snapshot+1" > events/sched/sched_process_fork/trigger
51echo "snapshot" > events/sched/sched_process_fork/trigger
52! echo "snapshot" > events/sched/sched_process_fork/trigger
53
54do_reset
55
56exit 0
57