xref: /linux/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic.tc (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: trace_marker trigger - test histogram with synthetic event
4# requires: set_event synthetic_events events/ftrace/print/trigger events/ftrace/print/hist
5# flags:
6
7fail() { #msg
8    echo $1
9    exit_fail
10}
11
12echo "Test histogram trace_marker to trace_marker latency histogram trigger"
13
14echo 'latency u64 lat' > synthetic_events
15echo 'hist:keys=common_pid:ts0=common_timestamp.usecs if buf == "start"' > events/ftrace/print/trigger
16echo 'hist:keys=common_pid:lat=common_timestamp.usecs-$ts0:onmatch(ftrace.print).latency($lat) if buf == "end"' >> events/ftrace/print/trigger
17echo 'hist:keys=common_pid,lat:sort=lat' > events/synthetic/latency/trigger
18echo -n "start" > trace_marker
19echo -n "end" > trace_marker
20
21cnt=`grep 'hitcount: *1$' events/ftrace/print/hist | wc -l`
22
23if [ $cnt -ne 2 ]; then
24    fail "hist trace_marker trigger did not trigger correctly"
25fi
26
27grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \
28    fail "hist trigger did not trigger "
29
30exit 0
31