xref: /linux/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-snapshot.tc (revision e1bcad609f5a533da45fac071cf0849b86dbab92)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: trace_marker trigger - test snapshot trigger
4# requires: set_event snapshot events/ftrace/print/trigger
5# flags: instance
6
7fail() { #msg
8    echo $1
9    exit_fail
10}
11
12test_trace() {
13    file=$1
14    x=$2
15
16    cat $file | while read line; do
17	comment=`echo $line | sed -e 's/^#//'`
18	if [ "$line" != "$comment" ]; then
19	    continue
20	fi
21	echo "testing $line for >$x<"
22	match=`echo $line | sed -e "s/>$x<//"`
23	if [ "$line" = "$match" ]; then
24	    fail "$line does not have >$x< in it"
25	fi
26	x=$((x+2))
27    done
28}
29
30echo "Test snapshot trace_marker trigger"
31
32echo 'snapshot' > events/ftrace/print/trigger
33
34# make sure the snapshot is allocated
35
36grep -q 'Snapshot is allocated' snapshot
37
38for i in `seq 1 10` ; do echo "hello >$i<" > trace_marker; done
39
40test_trace trace 1
41test_trace snapshot 2
42
43exit 0
44