aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/ftrace/test.d/trigger/trigger-trace-marker-synthetic-kernel.tc
blob: 18b4d1c2807e88db7aef429268447311325e794c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: trace_marker trigger - test histogram with synthetic event against kernel event
# flags:

fail() { #msg
    echo $1
    exit_fail
}

if [ ! -f set_event ]; then
    echo "event tracing is not supported"
    exit_unsupported
fi

if [ ! -f synthetic_events ]; then
    echo "synthetic events not supported"
    exit_unsupported
fi

if [ ! -d events/ftrace/print ]; then
    echo "event trace_marker is not supported"
    exit_unsupported
fi

if [ ! -d events/sched/sched_waking ]; then
    echo "event sched_waking is not supported"
    exit_unsupported
fi

if [ ! -f events/ftrace/print/trigger ]; then
    echo "event trigger is not supported"
    exit_unsupported
fi

if [ ! -f events/ftrace/print/hist ]; then
    echo "hist trigger is not supported"
    exit_unsupported
fi

echo "Test histogram kernel event to trace_marker latency histogram trigger"

echo 'latency u64 lat' > synthetic_events
echo 'hist:keys=pid:ts0=common_timestamp.usecs' > events/sched/sched_waking/trigger
echo 'hist:keys=common_pid:lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).latency($lat)' > events/ftrace/print/trigger
echo 'hist:keys=common_pid,lat:sort=lat' > events/synthetic/latency/trigger
sleep 1
echo "hello" > trace_marker

grep 'hitcount: *1$' events/ftrace/print/hist > /dev/null || \
    fail "hist trigger did not trigger correct times on trace_marker"

grep 'hitcount: *1$' events/synthetic/latency/hist > /dev/null || \
    fail "hist trigger did not trigger "

exit 0