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