summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_tprobe_module.tc
blob: d319d5ed4226c538f28f7bd1cd0484ebc112ffd9 (plain)
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
57
58
59
60
61
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Generic dynamic event - add/remove tracepoint probe events on module
# requires: dynamic_events "t[:[<group>/][<event>]] <tracepoint> [<args>]":README

rmmod trace-events-sample ||:
if ! modprobe trace-events-sample ; then
  echo "No trace-events sample module - please make CONFIG_SAMPLE_TRACE_EVENTS=m"
  exit_unresolved;
fi
trap "rmmod trace-events-sample" EXIT

echo 0 > events/enable
echo > dynamic_events

TRACEPOINT1=foo_bar
TRACEPOINT2=foo_bar_with_cond

echo "t:myevent1 $TRACEPOINT1" >> dynamic_events
echo "t:myevent2 $TRACEPOINT2" >> dynamic_events

grep -q myevent1 dynamic_events
grep -q myevent2 dynamic_events
test -d events/tracepoints/myevent1
test -d events/tracepoints/myevent2

echo "-:myevent2" >> dynamic_events

grep -q myevent1 dynamic_events
! grep -q myevent2 dynamic_events

echo > dynamic_events

clear_trace

:;: "Try to put a probe on a tracepoint in non-loaded module" ;:
rmmod trace-events-sample

echo "t:myevent1 $TRACEPOINT1" >> dynamic_events
echo "t:myevent2 $TRACEPOINT2" >> dynamic_events

grep -q myevent1 dynamic_events
grep -q myevent2 dynamic_events
test -d events/tracepoints/myevent1
test -d events/tracepoints/myevent2

echo 1 > events/tracepoints/enable

modprobe trace-events-sample

sleep 2

grep -q "myevent1" trace
grep -q "myevent2" trace

rmmod trace-events-sample
trap "" EXIT

echo 0 > events/tracepoints/enable
echo > dynamic_events
clear_trace