Fix: lttng_poll_mod calls compat_(e)poll_add
[lttng-tools.git] / tests / perf / test_perf_raw.in
CommitLineData
6faa26ca
JD
1#!/bin/bash
2#
3# Copyright (C) - 2016 Julien Desfossez <jdesfossez@efficios.com>
4#
5# This program is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License, version 2 only, as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12# more details.
13#
14# You should have received a copy of the GNU General Public License along with
15# this program; if not, write to the Free Software Foundation, Inc., 51
16# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18TEST_DESC="Perf counters"
19
20CURDIR=$(dirname $0)/
21TESTDIR=$CURDIR/..
22LTTNG_BIN="lttng"
23SESSION_NAME="perf_counters"
95cdb5e3 24NUM_TESTS=21
6faa26ca
JD
25NR_ITER=1
26NR_USEC_WAIT=1
27TESTAPP_PATH="$TESTDIR/utils/testapp"
28TESTAPP_NAME="gen-ust-events"
29TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
30# Empty if libpfm is installed, "#" otherwise
31HAVE_LIBPFM="@LTTNG_TOOLS_BUILD_WITH_LIBPFM_TRUE@"
32
33source $TESTDIR/utils/utils.sh
34
35function enable_ust_lttng_event_per_chan()
36{
37 sess_name="$1"
38 event_name="$2"
39 chan_name="$3"
40
41 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
42 ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
43}
44
45function have_libpfm()
46{
47 test -z $HAVE_LIBPFM
48 ok $? "Have libpfm installed"
49}
50
51function test_ust_raw()
52{
53 TRACE_PATH=$(mktemp -d)
54 SESSION_NAME="ust_perf"
55 CHAN_NAME="mychan"
56 EVENT_NAME="tp:tptest"
57 PMU="UNHALTED_REFERENCE_CYCLES"
58 PERFID=$($CURDIR/find_event $PMU)
59 test $? -eq "0"
60 ok $? "Find PMU $PMU"
61
62 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
63
64 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
65
66 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
67
68 add_context_ust_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:${PERFID}:test"
69
70 start_lttng_tracing_ok
71
72 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
73
74 stop_lttng_tracing_ok
75
76 destroy_lttng_session_ok $SESSION_NAME
77
78 validate_trace "perf_thread_raw_${PERFID}_test" $TRACE_PATH
79
80 rm -rf $TRACE_PATH
81}
82
83function test_kernel_raw()
84{
85 TRACE_PATH=$(mktemp -d)
86 SESSION_NAME="kernel_perf"
87 CHAN_NAME="mychan"
88 EVENT_NAME="lttng_test_filter_event"
89 PMU="UNHALTED_REFERENCE_CYCLES"
90 PERFID=$($CURDIR/find_event $PMU)
91 test $? -eq "0"
92 ok $? "Find PMU $PMU"
93
94 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
95
96 lttng_enable_kernel_channel_ok $SESSION_NAME $CHAN_NAME
97
98 enable_kernel_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHAN_NAME
99
100 add_context_kernel_ok $SESSION_NAME $CHAN_NAME "perf:cpu:raw:${PERFID}:test"
101
102 start_lttng_tracing_ok
103
104 echo -n 10 > /proc/lttng-test-filter-event
105
106 stop_lttng_tracing_ok
107
108 destroy_lttng_session_ok $SESSION_NAME
109
110 validate_trace "perf_cpu_raw_${PERFID}_test" $TRACE_PATH
111
112 rm -rf $TRACE_PATH
113}
114
115if [ "$(id -u)" == "0" ]; then
116 isroot=1
117else
118 isroot=0
119fi
120
121# MUST set TESTDIR before calling those functions
122plan_tests $NUM_TESTS
123
124print_test_banner "$TEST_DESC"
125
126start_lttng_sessiond
127
128have_libpfm
129
130test_ust_raw
131
132skip $isroot "Root access is needed for kernel testing, skipping." 9 ||
133{
134 modprobe lttng-test
135 test_kernel_raw
136 rmmod lttng-test
137}
138
139stop_lttng_sessiond
This page took 0.039717 seconds and 4 git commands to generate.