1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: event trigger - test stacktrace-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
27reset_tracer
28do_reset
29
30FEATURE=`grep stacktrace events/sched/sched_process_fork/trigger`
31if [ -z "$FEATURE" ]; then
32    echo "stacktrace trigger is not supported"
33    exit_unsupported
34fi
35
36echo "Test stacktrace tigger"
37echo 0 > trace
38echo 0 > options/stacktrace
39echo 'stacktrace' > events/sched/sched_process_fork/trigger
40( echo "forked")
41grep "<stack trace>" trace > /dev/null || \
42    fail "stacktrace trigger on sched_process_fork did not work"
43
44reset_trigger
45
46echo "Test stacktrace semantic errors"
47
48! echo "stacktrace:foo" > events/sched/sched_process_fork/trigger
49echo "stacktrace" > events/sched/sched_process_fork/trigger
50! echo "stacktrace" > events/sched/sched_process_fork/trigger
51
52do_reset
53
54exit 0
55