sessiond: kernel triggers: add infrastructure to create event notifiers
[lttng-tools.git] / tests / perf / test_perf_raw.in
CommitLineData
6faa26ca
JD
1#!/bin/bash
2#
9d16b343 3# Copyright (C) 2016 Julien Desfossez <jdesfossez@efficios.com>
6faa26ca 4#
9d16b343 5# SPDX-License-Identifier: GPL-2.0-only
6faa26ca 6#
6faa26ca
JD
7
8TEST_DESC="Perf counters"
9
10CURDIR=$(dirname $0)/
11TESTDIR=$CURDIR/..
12LTTNG_BIN="lttng"
13SESSION_NAME="perf_counters"
95cdb5e3 14NUM_TESTS=21
6faa26ca
JD
15NR_ITER=1
16NR_USEC_WAIT=1
17TESTAPP_PATH="$TESTDIR/utils/testapp"
18TESTAPP_NAME="gen-ust-events"
19TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
20# Empty if libpfm is installed, "#" otherwise
21HAVE_LIBPFM="@LTTNG_TOOLS_BUILD_WITH_LIBPFM_TRUE@"
22
23source $TESTDIR/utils/utils.sh
24
25function enable_ust_lttng_event_per_chan()
26{
27 sess_name="$1"
28 event_name="$2"
29 chan_name="$3"
30
31 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
32 ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
33}
34
35function have_libpfm()
36{
37 test -z $HAVE_LIBPFM
38 ok $? "Have libpfm installed"
39}
40
41function test_ust_raw()
42{
43 TRACE_PATH=$(mktemp -d)
44 SESSION_NAME="ust_perf"
45 CHAN_NAME="mychan"
46 EVENT_NAME="tp:tptest"
47 PMU="UNHALTED_REFERENCE_CYCLES"
48 PERFID=$($CURDIR/find_event $PMU)
49 test $? -eq "0"
50 ok $? "Find PMU $PMU"
51
52 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
53
54 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
55
56 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
57
58 add_context_ust_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:${PERFID}:test"
59
60 start_lttng_tracing_ok
61
6c4a91d6 62 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev/null 2>&1
6faa26ca
JD
63
64 stop_lttng_tracing_ok
65
66 destroy_lttng_session_ok $SESSION_NAME
67
68 validate_trace "perf_thread_raw_${PERFID}_test" $TRACE_PATH
69
70 rm -rf $TRACE_PATH
71}
72
73function test_kernel_raw()
74{
75 TRACE_PATH=$(mktemp -d)
76 SESSION_NAME="kernel_perf"
77 CHAN_NAME="mychan"
78 EVENT_NAME="lttng_test_filter_event"
79 PMU="UNHALTED_REFERENCE_CYCLES"
80 PERFID=$($CURDIR/find_event $PMU)
81 test $? -eq "0"
82 ok $? "Find PMU $PMU"
83
84 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
85
86 lttng_enable_kernel_channel_ok $SESSION_NAME $CHAN_NAME
87
88 enable_kernel_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHAN_NAME
89
90 add_context_kernel_ok $SESSION_NAME $CHAN_NAME "perf:cpu:raw:${PERFID}:test"
91
92 start_lttng_tracing_ok
93
94 echo -n 10 > /proc/lttng-test-filter-event
95
96 stop_lttng_tracing_ok
97
98 destroy_lttng_session_ok $SESSION_NAME
99
100 validate_trace "perf_cpu_raw_${PERFID}_test" $TRACE_PATH
101
102 rm -rf $TRACE_PATH
103}
104
105if [ "$(id -u)" == "0" ]; then
106 isroot=1
107else
108 isroot=0
109fi
110
111# MUST set TESTDIR before calling those functions
112plan_tests $NUM_TESTS
113
114print_test_banner "$TEST_DESC"
115
116start_lttng_sessiond
117
118have_libpfm
119
120test_ust_raw
121
122skip $isroot "Root access is needed for kernel testing, skipping." 9 ||
123{
124 modprobe lttng-test
125 test_kernel_raw
d0e263e7 126 modprobe --remove lttng-test
6faa26ca
JD
127}
128
129stop_lttng_sessiond
This page took 0.053159 seconds and 4 git commands to generate.