Gen-ust-events: use options instead of arguments
[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/../..
bb8ec90d
JD
23SESSION_NAME="perf_counters"
24EVENT_NAME="tp:tptest"
7cd988f0 25NUM_TESTS=24
bb8ec90d
JD
26NR_ITER=1
27NR_USEC_WAIT=1
28TESTAPP_PATH="$TESTDIR/utils/testapp"
29TESTAPP_NAME="gen-ust-events"
30TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
31
32source $TESTDIR/utils/utils.sh
33
34function enable_ust_lttng_event_per_chan()
35{
36 sess_name="$1"
37 event_name="$2"
38 chan_name="$3"
39
40 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
41 ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
42}
43
7cd988f0
JD
44# Only test parsing of the enabling by raw ID
45function test_parsing_raw()
bb8ec90d 46{
7cd988f0
JD
47 TRACE_PATH=$(mktemp -d)
48 SESSION_NAME="ust_event_basic"
49 CHAN_NAME="mychan"
50
51 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
52
53 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
54
55 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
bb8ec90d 56
7cd988f0
JD
57 add_context_ust_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test"
58 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:rZZZ:test"
59 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:b0110:test"
60 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:"
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:r:test"
63 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r::"
64 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw::"
65 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw"
66 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test:wrong"
67
68 destroy_lttng_session_ok $SESSION_NAME
69
70 rm -rf $TRACE_PATH
bb8ec90d
JD
71}
72
73function test_event_basic()
74{
75 TRACE_PATH=$(mktemp -d)
76 SESSION_NAME="ust_event_basic"
77 CHAN_NAME="mychan"
78
bf6ae429 79 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
bb8ec90d 80
827caf52 81 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
bb8ec90d
JD
82
83 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
84
7cd988f0 85 add_context_ust_ok $SESSION_NAME $CHAN_NAME "perf:thread:page-fault"
bb8ec90d 86
e563bbdb 87 start_lttng_tracing_ok
bb8ec90d 88
a4c30524 89 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev/null 2>&1
bb8ec90d 90
96340a01 91 stop_lttng_tracing_ok
bb8ec90d 92
67b4c664 93 destroy_lttng_session_ok $SESSION_NAME
bb8ec90d
JD
94
95 validate_trace "perf_thread_page_fault" $TRACE_PATH
96 rm -rf $TRACE_PATH
97}
98
99# MUST set TESTDIR before calling those functions
100plan_tests $NUM_TESTS
101
102print_test_banner "$TEST_DESC"
103
bc2d01d2
MD
104if [ "$(id -u)" == "0" ]; then
105 isroot=1
106else
107 isroot=0
108fi
109
7cd988f0 110start_lttng_sessiond
bb8ec90d 111
7cd988f0 112test_parsing_raw
bb8ec90d 113
7cd988f0
JD
114skip $isroot "Root access is needed. Skipping UST perf tests." 8 ||
115{
116 test_event_basic
bc2d01d2 117}
7cd988f0
JD
118
119stop_lttng_sessiond
This page took 0.069534 seconds and 5 git commands to generate.