Test the parsing of perf raw context
[lttng-tools.git] / tests / regression / ust / test_event_perf
CommitLineData
bb8ec90d
JD
1#!/bin/bash
2#
3# Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com>
4# Copyright (C) - 2014 Julien Desfossez <jdesfossez@efficios.com>
5#
6# This program is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License, version 2 only, as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13# more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# this program; if not, write to the Free Software Foundation, Inc., 51
17# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19TEST_DESC="UST tracer - Perf counters"
20
21CURDIR=$(dirname $0)/
22TESTDIR=$CURDIR/../..
23LTTNG_BIN="lttng"
24SESSION_NAME="perf_counters"
25EVENT_NAME="tp:tptest"
7cd988f0 26NUM_TESTS=24
bb8ec90d
JD
27NR_ITER=1
28NR_USEC_WAIT=1
29TESTAPP_PATH="$TESTDIR/utils/testapp"
30TESTAPP_NAME="gen-ust-events"
31TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
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
7cd988f0
JD
45# Only test parsing of the enabling by raw ID
46function test_parsing_raw()
bb8ec90d 47{
7cd988f0
JD
48 TRACE_PATH=$(mktemp -d)
49 SESSION_NAME="ust_event_basic"
50 CHAN_NAME="mychan"
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
bb8ec90d 57
7cd988f0
JD
58 add_context_ust_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test"
59 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:rZZZ:test"
60 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:b0110:test"
61 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:"
62 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110::"
63 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r:test"
64 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r::"
65 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw::"
66 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw"
67 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test:wrong"
68
69 destroy_lttng_session_ok $SESSION_NAME
70
71 rm -rf $TRACE_PATH
bb8ec90d
JD
72}
73
74function test_event_basic()
75{
76 TRACE_PATH=$(mktemp -d)
77 SESSION_NAME="ust_event_basic"
78 CHAN_NAME="mychan"
79
bf6ae429 80 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
bb8ec90d 81
827caf52 82 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
bb8ec90d
JD
83
84 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
85
7cd988f0 86 add_context_ust_ok $SESSION_NAME $CHAN_NAME "perf:thread:page-fault"
bb8ec90d 87
e563bbdb 88 start_lttng_tracing_ok
bb8ec90d
JD
89
90 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
91
96340a01 92 stop_lttng_tracing_ok
bb8ec90d 93
67b4c664 94 destroy_lttng_session_ok $SESSION_NAME
bb8ec90d
JD
95
96 validate_trace "perf_thread_page_fault" $TRACE_PATH
97 rm -rf $TRACE_PATH
98}
99
100# MUST set TESTDIR before calling those functions
101plan_tests $NUM_TESTS
102
103print_test_banner "$TEST_DESC"
104
bc2d01d2
MD
105if [ "$(id -u)" == "0" ]; then
106 isroot=1
107else
108 isroot=0
109fi
110
7cd988f0 111start_lttng_sessiond
bb8ec90d 112
7cd988f0 113test_parsing_raw
bb8ec90d 114
7cd988f0
JD
115skip $isroot "Root access is needed. Skipping UST perf tests." 8 ||
116{
117 test_event_basic
bc2d01d2 118}
7cd988f0
JD
119
120stop_lttng_sessiond
This page took 0.049355 seconds and 4 git commands to generate.