relayd: move viewer stream chunk reference release to destroy
[lttng-tools.git] / tests / regression / ust / test_event_perf
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
19 TEST_DESC="UST tracer - Perf counters"
20
21 CURDIR=$(dirname $0)/
22 TESTDIR=$CURDIR/../..
23 SESSION_NAME="perf_counters"
24 EVENT_NAME="tp:tptest"
25 NUM_TESTS=24
26 NR_ITER=1
27 NR_USEC_WAIT=1
28 TESTAPP_PATH="$TESTDIR/utils/testapp"
29 TESTAPP_NAME="gen-ust-events"
30 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
31
32 source $TESTDIR/utils/utils.sh
33
34 function 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
44 function add_context_ust_skip_ok()
45 {
46 local session_name=$1
47 local channel_name=$2
48 local context_name=$3
49 local skip_num=$4
50
51 local ret
52
53 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" add-context -u \
54 -s "$session_name" -c "$channel_name" \
55 -t "$context_name" 1>"$OUTPUT_DEST" 2>"$ERROR_OUTPUT_DEST"
56 ret=$?
57
58 if [ "$ret" == "4" ]; then
59 skip 0 "Current UST lib doesn't implement '$context_name' context" "$skip_num"
60 else
61 ok $ret "Add context command for type: $context_name"
62 fi
63
64 return $ret
65 }
66
67 # Only test parsing of the enabling by raw ID
68 function test_parsing_raw()
69 {
70 TRACE_PATH=$(mktemp -d)
71 SESSION_NAME="ust_event_basic"
72 CHAN_NAME="mychan"
73
74 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
75
76 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
77
78 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
79
80 add_context_ust_skip_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test" 1
81 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:rZZZ:test"
82 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:b0110:test"
83 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:"
84 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110::"
85 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r:test"
86 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r::"
87 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw::"
88 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw"
89 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test:wrong"
90
91 destroy_lttng_session_ok $SESSION_NAME
92
93 rm -rf $TRACE_PATH
94 }
95
96 function test_event_basic()
97 {
98 TRACE_PATH=$(mktemp -d)
99 SESSION_NAME="ust_event_basic"
100 CHAN_NAME="mychan"
101
102 local ret
103
104 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
105
106 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
107
108 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
109
110 add_context_ust_skip_ok $SESSION_NAME $CHAN_NAME "perf:thread:page-fault" 4
111 ret=$?
112
113 if [ "$ret" != "4" ]; then
114 start_lttng_tracing_ok
115
116 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
117
118 stop_lttng_tracing_ok
119
120 validate_trace "perf_thread_page_fault" "$TRACE_PATH"
121 fi
122
123 destroy_lttng_session_ok $SESSION_NAME
124
125 rm -rf "$TRACE_PATH"
126 }
127
128 # MUST set TESTDIR before calling those functions
129 plan_tests $NUM_TESTS
130
131 print_test_banner "$TEST_DESC"
132
133 if [ "$(id -u)" == "0" ]; then
134 isroot=1
135 else
136 isroot=0
137 fi
138
139 start_lttng_sessiond
140
141 test_parsing_raw
142
143 skip $isroot "Root access is needed. Skipping UST perf tests." 8 ||
144 {
145 test_event_basic
146 }
147
148 stop_lttng_sessiond
This page took 0.037114 seconds and 4 git commands to generate.