Fix: format string type mismatch
[lttng-tools.git] / tests / regression / ust / periodical-metadata-flush / test_periodical_metadata_flush
CommitLineData
a788a3ed
DG
1#!/bin/bash
2#
3# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17TEST_DESC="UST tracer - Tracing with per UID buffers and periodical flush"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21NR_ITER=100
b688191f
CB
22NR_USEC_WAIT=100000
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
a788a3ed 26SESSION_NAME="periodical-flush"
b688191f 27EVENT_NAME="tp:tptest"
a788a3ed
DG
28BIN_NAME="gen-nevents"
29NUM_TESTS=38
30
31source $TESTDIR/utils/utils.sh
32
b688191f
CB
33if [ ! -x "$TESTAPP_BIN" ]; then
34 BAIL_OUT "No UST events binary detected."
a788a3ed
DG
35fi
36
37# MUST set TESTDIR before calling those functions
38
39function enable_channel_per_uid()
40{
41 local sess_name=$1
42 local channel_name=$2
43
dd770530
DG
44 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name --switch-timer 1000000 >/dev/null 2>&1
45 ok $? "Enable channel $channel_name per UID for session $sess_name"
46}
47
48function enable_channel_per_pid()
49{
50 local sess_name=$1
51 local channel_name=$2
52
53 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name --switch-timer 1000000 >/dev/null 2>&1
a788a3ed
DG
54 ok $? "Enable channel $channel_name per UID for session $sess_name"
55}
56
57function enable_metadata_per_uid()
58{
59 local sess_name=$1
60 local channel_name="metadata"
61
62 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name --switch-timer 200000 >/dev/null 2>&1
63 ok $? "Enable channel $channel_name per UID for session $sess_name"
64}
65
66function enable_metadata_per_pid()
67{
68 local sess_name=$1
69 local channel_name="metadata"
70
71 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name --switch-timer 200000 >/dev/null 2>&1
72 ok $? "Enable channel $channel_name per PID for session $sess_name"
73}
74
75function wait_apps
76{
77 diag "Waiting for applications to end..."
b688191f 78 while [ -n "$(pidof $TESTAPP_NAME)" ]; do
a788a3ed
DG
79 sleep 1
80 done
81}
82
dd770530
DG
83function validate_trace()
84{
85 local out
86
87 out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
88 if [ $out -eq 0 ]; then
89 fail "Trace validation"
90 diag "No event(s) found. We are supposed to have at least one."
91 out=1
92 else
93 pass "Trace validation"
94 diag "Found $out event(s). Coherent."
95 out=0
96 fi
97
98 return $out
99}
100
a788a3ed
DG
101test_after_app_pid() {
102 local out
103
104 diag "Start application AFTER tracing is started"
105
106 # BEFORE application is spawned
107 create_lttng_session $SESSION_NAME $TRACE_PATH
108 enable_metadata_per_pid $SESSION_NAME
dd770530 109 enable_channel_per_pid $SESSION_NAME "channel0"
447e8ad9 110 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
a788a3ed
DG
111 start_lttng_tracing $SESSION_NAME
112
b688191f 113 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
a788a3ed
DG
114 ok $? "Start application to trace"
115
dd770530
DG
116 # At least hit one event
117 sleep 2
118 validate_trace
119 out=$?
120
a788a3ed
DG
121 stop_lttng_tracing $SESSION_NAME
122 destroy_lttng_session $SESSION_NAME
123
dd770530 124 return $out
a788a3ed
DG
125}
126
127test_before_app_pid() {
128 local out
129
130 diag "Start application BEFORE tracing is started"
131
b688191f 132 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
a788a3ed
DG
133 ok $? "Start application to trace"
134
135 # BEFORE application is spawned
136 create_lttng_session $SESSION_NAME $TRACE_PATH
137 enable_metadata_per_pid $SESSION_NAME
dd770530 138 enable_channel_per_pid $SESSION_NAME "channel0"
447e8ad9 139 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
a788a3ed
DG
140 start_lttng_tracing $SESSION_NAME
141
142 # At least hit one event
143 sleep 2
dd770530
DG
144 validate_trace
145 out=$?
a788a3ed
DG
146
147 stop_lttng_tracing $SESSION_NAME
148 destroy_lttng_session $SESSION_NAME
149
a788a3ed
DG
150 wait_apps
151
152 return $out
153}
154
155test_after_app_uid() {
156 local out
157
158 diag "Start application AFTER tracing is started"
159
160 # BEFORE application is spawned
161 create_lttng_session $SESSION_NAME $TRACE_PATH
162 enable_metadata_per_uid $SESSION_NAME
163 enable_channel_per_uid $SESSION_NAME "channel0"
1afc6e74 164 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
a788a3ed
DG
165 start_lttng_tracing $SESSION_NAME
166
b688191f 167 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
a788a3ed
DG
168 ok $? "Start application to trace"
169
dd770530
DG
170 # At least hit one event
171 sleep 2
172 validate_trace
173 out=$?
174
a788a3ed
DG
175 stop_lttng_tracing $SESSION_NAME
176 destroy_lttng_session $SESSION_NAME
177
dd770530 178 return $out
a788a3ed
DG
179}
180
181test_before_app_uid() {
182 local out
183
184 diag "Start application BEFORE tracing is started"
185
b688191f 186 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
a788a3ed
DG
187 ok $? "Start application to trace"
188
189 # BEFORE application is spawned
190 create_lttng_session $SESSION_NAME $TRACE_PATH
191 enable_metadata_per_uid $SESSION_NAME
192 enable_channel_per_uid $SESSION_NAME "channel0"
1afc6e74 193 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
a788a3ed
DG
194 start_lttng_tracing $SESSION_NAME
195
196 # At least hit one event
197 sleep 2
dd770530
DG
198 validate_trace
199 out=$?
a788a3ed
DG
200
201 stop_lttng_tracing $SESSION_NAME
202 destroy_lttng_session $SESSION_NAME
203
a788a3ed
DG
204 wait_apps
205
206 return $out
207}
208
209# MUST set TESTDIR before calling those functions
210plan_tests $NUM_TESTS
211
212print_test_banner "$TEST_DESC"
213
214TESTS=(
215 "test_before_app_uid"
216 "test_after_app_uid"
217 "test_before_app_pid"
218 "test_after_app_pid"
219)
220
221TEST_COUNT=${#TESTS[@]}
222i=0
223
224start_lttng_sessiond
225
226while [ $i -lt $TEST_COUNT ]; do
227 TRACE_PATH=$(mktemp -d)
228 ${TESTS[$i]}
229 #rm -rf $TRACE_PATH
230 let "i++"
231done
232
233stop_lttng_sessiond
This page took 0.048259 seconds and 4 git commands to generate.