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
26if [ ! -f snapshot ]; then
27    echo "snapshot is not supported"
28    exit_unsupported
29fi
30
31reset_tracer
32do_reset
33
34FEATURE=`grep snapshot events/sched/sched_process_fork/trigger`
35if [ -z "$FEATURE" ]; then
36    echo "snapshot trigger is not supported"
37    exit_unsupported
38fi
39
40echo "Test snapshot tigger"
41echo 0 > snapshot
42echo 1 > events/sched/sched_process_fork/enable
43( echo "forked")
44echo 'snapshot:1' > events/sched/sched_process_fork/trigger
45( echo "forked")
46grep sched_process_fork snapshot > /dev/null || \
47    fail "snapshot trigger on sched_process_fork did not work"
48
49reset_trigger
50echo 0 > snapshot
51echo 0 > events/sched/sched_process_fork/enable
52
53echo "Test snapshot semantic errors"
54
55! echo "snapshot+1" > events/sched/sched_process_fork/trigger
56echo "snapshot" > events/sched/sched_process_fork/trigger
57! echo "snapshot" > events/sched/sched_process_fork/trigger
58
59do_reset
60
61exit 0
62