Commit | Line | Data |
---|---|---|
10a8a223 | 1 | #!/src/bin/bash |
d3e8f6bb DG |
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 | |
17 | ||
18 | SESSIOND_BIN="lttng-sessiond" | |
f7613992 | 19 | CONSUMERD_BIN="lttng-consumerd" |
f4e40ab6 | 20 | RELAYD_BIN="lttng-relayd" |
d3e8f6bb DG |
21 | LTTNG_BIN="lttng" |
22 | BABELTRACE_BIN="babeltrace" | |
873c2aae | 23 | OUTPUT_DEST=/dev/null 2>&1 |
d3e8f6bb | 24 | |
fd4dfcec DG |
25 | # Minimal kernel version supported for session daemon tests |
26 | KERNEL_MAJOR_VERSION=2 | |
27 | KERNEL_MINOR_VERSION=6 | |
28 | KERNEL_PATCHLEVEL_VERSION=27 | |
29 | ||
29655db7 CB |
30 | source $TESTDIR/utils/tap/tap.sh |
31 | ||
fec81a7e CB |
32 | function print_ok () |
33 | { | |
34 | # Check if we are a terminal | |
35 | if [ -t 1 ]; then | |
36 | echo -e "\e[1;32mOK\e[0m" | |
37 | else | |
38 | echo -e "OK" | |
39 | fi | |
40 | } | |
41 | ||
42 | function print_fail () | |
43 | { | |
44 | # Check if we are a terminal | |
45 | if [ -t 1 ]; then | |
46 | echo -e "\e[1;31mFAIL\e[0m" | |
47 | else | |
48 | echo -e "FAIL" | |
49 | fi | |
50 | } | |
51 | ||
52 | function print_test_banner () | |
53 | { | |
7d0ad314 | 54 | local desc="$1" |
29655db7 | 55 | diag "$desc" |
fec81a7e CB |
56 | } |
57 | ||
fd4dfcec DG |
58 | function validate_kernel_version () |
59 | { | |
7d0ad314 | 60 | local kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n')) |
fd4dfcec DG |
61 | if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then |
62 | return 0 | |
63 | fi | |
64 | if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then | |
65 | return 0 | |
66 | fi | |
67 | if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then | |
68 | return 0 | |
69 | fi | |
70 | return 1 | |
71 | } | |
72 | ||
9ac429ef | 73 | # Generate a random string |
f4e40ab6 DG |
74 | # $1 = number of characters; defaults to 16 |
75 | # $2 = include special characters; 1 = yes, 0 = no; defaults to yes | |
9ac429ef | 76 | function randstring() |
f4e40ab6 DG |
77 | { |
78 | [ "$2" == "0" ] && CHAR="[:alnum:]" || CHAR="[:graph:]" | |
79 | cat /dev/urandom | tr -cd "$CHAR" | head -c ${1:-16} | |
80 | echo | |
81 | } | |
82 | ||
f4e40ab6 DG |
83 | function lttng_enable_kernel_event |
84 | { | |
7d0ad314 JRJ |
85 | local sess_name=$1 |
86 | local event_name=$2 | |
87 | local channel_name=$3 | |
f4e40ab6 DG |
88 | |
89 | if [ -z $event_name ]; then | |
90 | # Enable all event if no event name specified | |
29655db7 | 91 | event_name="-a" |
f4e40ab6 DG |
92 | fi |
93 | ||
07b86b52 JD |
94 | if [ -z $channel_name ]; then |
95 | # default channel if none specified | |
96 | chan="" | |
97 | else | |
98 | chan="-c $channel_name" | |
99 | fi | |
100 | ||
873c2aae | 101 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -k >$OUTPUT_DEST |
29655db7 | 102 | ok $? "Enable kernel event $event_name for session $sess_name" |
f4e40ab6 DG |
103 | } |
104 | ||
fb3268e3 | 105 | function start_lttng_relayd |
f4e40ab6 | 106 | { |
198e7caf | 107 | local opt=$1 |
173af62f | 108 | |
f4e40ab6 DG |
109 | DIR=$(readlink -f $TESTDIR) |
110 | ||
111 | if [ -z $(pidof lt-$RELAYD_BIN) ]; then | |
873c2aae | 112 | $DIR/../src/bin/lttng-relayd/$RELAYD_BIN -b $opt >$OUTPUT_DEST |
25a818af | 113 | #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 & |
f4e40ab6 | 114 | if [ $? -eq 1 ]; then |
29655db7 | 115 | fail "Start lttng-relayd (opt: $opt)" |
f4e40ab6 DG |
116 | return 1 |
117 | else | |
29655db7 | 118 | pass "Start lttng-relayd (opt: $opt)" |
f4e40ab6 DG |
119 | fi |
120 | else | |
29655db7 | 121 | pass "Start lttng-relayd (opt: $opt)" |
f4e40ab6 DG |
122 | fi |
123 | } | |
124 | ||
1fb23888 | 125 | function stop_lttng_relayd_nocheck |
f4e40ab6 DG |
126 | { |
127 | PID_RELAYD=`pidof lt-$RELAYD_BIN` | |
128 | ||
1fb23888 | 129 | diag "Killing lttng-relayd (pid: $PID_RELAYD)" |
873c2aae | 130 | kill $PID_RELAYD >$OUTPUT_DEST |
1fb23888 | 131 | retval=$? |
29655db7 | 132 | |
1fb23888 | 133 | if [ $retval -eq 1 ]; then |
f4e40ab6 DG |
134 | out=1 |
135 | while [ -n "$out" ]; do | |
136 | out=$(pidof lt-$RELAYD_BIN) | |
137 | sleep 0.5 | |
138 | done | |
1fb23888 MD |
139 | fi |
140 | return $retval | |
141 | } | |
142 | ||
143 | function stop_lttng_relayd | |
144 | { | |
145 | stop_lttng_relayd_nocheck | |
146 | ||
147 | if [ $? -eq 1 ]; then | |
148 | fail "Killed lttng-relayd (pid: $PID_RELAYD)" | |
149 | return 1 | |
150 | else | |
151 | pass "Killed lttng-relayd (pid: $PID_RELAYD)" | |
f4e40ab6 DG |
152 | return 0 |
153 | fi | |
154 | } | |
155 | ||
8d51ddbc | 156 | #First argument: load path for automatic loading |
fb3268e3 | 157 | function start_lttng_sessiond() |
355f483d | 158 | { |
8d51ddbc JRJ |
159 | |
160 | local load_path="$1" | |
355f483d DG |
161 | if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
162 | # Env variable requested no session daemon | |
163 | return | |
164 | fi | |
165 | ||
29655db7 CB |
166 | validate_kernel_version |
167 | if [ $? -ne 0 ]; then | |
168 | fail "Start session daemon" | |
169 | BAIL_OUT "*** Kernel too old for session daemon tests ***" | |
355f483d DG |
170 | fi |
171 | ||
29655db7 | 172 | DIR=$(readlink -f $TESTDIR) |
d3d97763 JG |
173 | : ${LTTNG_SESSION_CONFIG_XSD_PATH=${DIR}/../src/common/config/} |
174 | export LTTNG_SESSION_CONFIG_XSD_PATH | |
29655db7 CB |
175 | |
176 | if [ -z $(pidof lt-$SESSIOND_BIN) ]; then | |
8d51ddbc JRJ |
177 | # Have a load path ? |
178 | if [ -n "$1" ]; then | |
179 | $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --load "$1" --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" | |
180 | else | |
181 | $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" | |
182 | fi | |
29655db7 CB |
183 | #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1 & |
184 | status=$? | |
29655db7 CB |
185 | ok $status "Start session daemon" |
186 | fi | |
355f483d DG |
187 | } |
188 | ||
fb3268e3 | 189 | function stop_lttng_sessiond () |
d3e8f6bb | 190 | { |
355f483d DG |
191 | if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then |
192 | # Env variable requested no session daemon | |
193 | return | |
194 | fi | |
195 | ||
d3e8f6bb DG |
196 | PID_SESSIOND=`pidof lt-$SESSIOND_BIN` |
197 | ||
873c2aae | 198 | kill $PID_SESSIOND >$OUTPUT_DEST |
29655db7 | 199 | |
d3e8f6bb | 200 | if [ $? -eq 1 ]; then |
29655db7 | 201 | fail "Kill sessions daemon" |
d3e8f6bb DG |
202 | return 1 |
203 | else | |
5fa32580 DG |
204 | out=1 |
205 | while [ -n "$out" ]; do | |
206 | out=$(pidof lt-$SESSIOND_BIN) | |
207 | sleep 0.5 | |
208 | done | |
f7613992 MD |
209 | out=1 |
210 | while [ -n "$out" ]; do | |
211 | out=$(pidof $CONSUMERD_BIN) | |
212 | sleep 0.5 | |
213 | done | |
29655db7 | 214 | pass "Kill session daemon" |
d3e8f6bb DG |
215 | fi |
216 | } | |
217 | ||
873c2aae JRJ |
218 | function list_lttng_with_opts () |
219 | { | |
7d0ad314 | 220 | local opts=$1 |
312dabc3 | 221 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN list $opts >$OUTPUT_DEST |
873c2aae JRJ |
222 | ok $? "Lttng-tool list command with option $opts" |
223 | } | |
224 | ||
07b86b52 JD |
225 | function create_lttng_session_no_output () |
226 | { | |
7d0ad314 | 227 | local sess_name=$1 |
07b86b52 | 228 | |
873c2aae | 229 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name --no-output >$OUTPUT_DEST |
07b86b52 JD |
230 | ok $? "Create session $sess_name in no-output mode" |
231 | } | |
232 | ||
d3e8f6bb DG |
233 | function create_lttng_session () |
234 | { | |
7d0ad314 JRJ |
235 | local sess_name=$1 |
236 | local trace_path=$2 | |
237 | local expected_to_fail=$3 | |
d3e8f6bb | 238 | |
873c2aae JRJ |
239 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path > $OUTPUT_DEST |
240 | ret=$? | |
312dabc3 | 241 | if [[ $expected_to_fail ]]; then |
01513c3e JRJ |
242 | test "$ret" -ne "0" |
243 | ok $? "Expected fail on session creation $sess_name in $trace_path" | |
873c2aae JRJ |
244 | else |
245 | ok $ret "Create session $sess_name in $trace_path" | |
246 | fi | |
d4018451 DG |
247 | } |
248 | ||
29655db7 | 249 | function enable_ust_lttng_channel() |
d4018451 | 250 | { |
7d0ad314 JRJ |
251 | local sess_name=$1 |
252 | local channel_name=$2 | |
253 | local expect_fail=$3 | |
d4018451 | 254 | |
873c2aae | 255 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name >$OUTPUT_DEST |
312dabc3 JRJ |
256 | ret=$? |
257 | if [[ $expect_fail ]]; then | |
01513c3e JRJ |
258 | test "$ret" -ne "0" |
259 | ok $? "Expected fail on ust channel creation $channel_name in $sess_name" | |
312dabc3 JRJ |
260 | else |
261 | ok $ret "Enable channel $channel_name for session $sess_name" | |
262 | fi | |
d4018451 DG |
263 | } |
264 | ||
29655db7 | 265 | function disable_ust_lttng_channel() |
d4018451 | 266 | { |
7d0ad314 JRJ |
267 | local sess_name=$1 |
268 | local channel_name=$2 | |
d4018451 | 269 | |
873c2aae | 270 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel -u $channel_name -s $sess_name >$OUTPUT_DEST |
29655db7 | 271 | ok $? "Disable channel $channel_name for session $sess_name" |
d3e8f6bb DG |
272 | } |
273 | ||
07b86b52 JD |
274 | function enable_lttng_mmap_overwrite_kernel_channel() |
275 | { | |
7d0ad314 JRJ |
276 | local sess_name=$1 |
277 | local channel_name=$2 | |
07b86b52 | 278 | |
873c2aae | 279 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite >$OUTPUT_DEST |
07b86b52 JD |
280 | ok $? "Enable channel $channel_name for session $sess_name" |
281 | } | |
282 | ||
ebaaaf5e JD |
283 | function enable_lttng_mmap_overwrite_ust_channel() |
284 | { | |
7d0ad314 JRJ |
285 | local sess_name=$1 |
286 | local channel_name=$2 | |
ebaaaf5e | 287 | |
873c2aae | 288 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -u --output mmap --overwrite >$OUTPUT_DEST |
ebaaaf5e JD |
289 | ok $? "Enable channel $channel_name for session $sess_name" |
290 | } | |
291 | ||
d3e8f6bb DG |
292 | function enable_ust_lttng_event () |
293 | { | |
7d0ad314 JRJ |
294 | local sess_name=$1 |
295 | local event_name="$2" | |
296 | local channel_name=$3 | |
01513c3e | 297 | local expected_to_fail=$4 |
ebaaaf5e JD |
298 | |
299 | if [ -z $channel_name ]; then | |
300 | # default channel if none specified | |
301 | chan="" | |
302 | else | |
303 | chan="-c $channel_name" | |
304 | fi | |
d3e8f6bb | 305 | |
873c2aae | 306 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -u >$OUTPUT_DEST |
01513c3e JRJ |
307 | ret=$? |
308 | if [[ $expected_to_fail ]]; then | |
309 | test $ret -ne "0" | |
310 | ok $? "Enable ust event $event_name for session $session_name on channel $channel_name failed as expected" | |
311 | else | |
312 | ok $ret "Enable event $event_name for session $sess_name" | |
313 | fi | |
26b53d3b DG |
314 | } |
315 | ||
37175ce4 DG |
316 | function enable_jul_lttng_event() |
317 | { | |
318 | sess_name=$1 | |
319 | event_name="$2" | |
320 | channel_name=$3 | |
321 | ||
322 | if [ -z $channel_name ]; then | |
323 | # default channel if none specified | |
324 | chan="" | |
325 | else | |
326 | chan="-c $channel_name" | |
327 | fi | |
328 | ||
873c2aae | 329 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -j >$OUTPUT_DEST |
37175ce4 DG |
330 | ok $? "Enable JUL event $event_name for session $sess_name" |
331 | } | |
332 | ||
b2064f54 DG |
333 | function enable_jul_lttng_event_loglevel() |
334 | { | |
7d0ad314 JRJ |
335 | local sess_name=$1 |
336 | local event_name="$2" | |
337 | local loglevel=$3 | |
338 | local channel_name=$4 | |
b2064f54 DG |
339 | |
340 | if [ -z $channel_name ]; then | |
341 | # default channel if none specified | |
342 | chan="" | |
343 | else | |
344 | chan="-c $channel_name" | |
345 | fi | |
346 | ||
873c2aae | 347 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -j >$OUTPUT_DEST |
b2064f54 DG |
348 | ok $? "Enable JUL event $event_name for session $sess_name with loglevel $loglevel" |
349 | } | |
350 | ||
26b53d3b DG |
351 | function enable_ust_lttng_event_filter() |
352 | { | |
7d0ad314 JRJ |
353 | local sess_name="$1" |
354 | local event_name="$2" | |
355 | local filter="$3" | |
26b53d3b | 356 | |
873c2aae | 357 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --filter "$filter" >$OUTPUT_DEST |
29655db7 | 358 | ok $? "Enable event $event_name with filtering for session $sess_name" |
26b53d3b DG |
359 | } |
360 | ||
361 | function enable_ust_lttng_event_loglevel() | |
362 | { | |
7d0ad314 JRJ |
363 | local sess_name="$1" |
364 | local event_name="$2" | |
365 | local loglevel="$3" | |
26b53d3b | 366 | |
873c2aae | 367 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel $loglevel >$OUTPUT_DEST |
29655db7 | 368 | ok $? "Enable event $event_name with loglevel $loglevel" |
26b53d3b DG |
369 | } |
370 | ||
371 | function enable_ust_lttng_event_loglevel_only() | |
372 | { | |
7d0ad314 JRJ |
373 | local sess_name="$1" |
374 | local event_name="$2" | |
375 | local loglevel="$3" | |
26b53d3b | 376 | |
873c2aae | 377 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u --loglevel-only $loglevel >$OUTPUT_DEST |
29655db7 | 378 | ok $? "Enable event $event_name with loglevel-only $loglevel" |
26b53d3b DG |
379 | } |
380 | ||
381 | function disable_ust_lttng_event () | |
382 | { | |
7d0ad314 JRJ |
383 | local sess_name="$1" |
384 | local event_name="$2" | |
01513c3e | 385 | local channel_name="$3" |
26b53d3b | 386 | |
01513c3e JRJ |
387 | if [ -z $channel_name ]; then |
388 | # default channel if none specified | |
389 | chan="" | |
390 | else | |
391 | chan="-c $channel_name" | |
392 | fi | |
393 | ||
394 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name $chan -u >$OUTPUT_DEST | |
29655db7 | 395 | ok $? "Disable event $event_name for session $sess_name" |
d3e8f6bb DG |
396 | } |
397 | ||
1d842d5a DG |
398 | function disable_jul_lttng_event () |
399 | { | |
400 | local sess_name="$1" | |
401 | local event_name="$2" | |
402 | ||
403 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -j >/dev/null 2>&1 | |
404 | ok $? "Disable JUL event $event_name for session $sess_name" | |
405 | } | |
406 | ||
fb3268e3 | 407 | function start_lttng_tracing () |
d3e8f6bb | 408 | { |
7d0ad314 | 409 | local sess_name=$1 |
01513c3e | 410 | local expected_to_fail=$2 |
d3e8f6bb | 411 | |
873c2aae | 412 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name >$OUTPUT_DEST |
01513c3e JRJ |
413 | ret=$? |
414 | if [[ $expected_to_fail ]]; then | |
415 | test "$ret" -ne "0" | |
416 | ok $? "Expected fail on start tracing for session: $sess_name" | |
417 | else | |
418 | ok $ret "Start tracing for session $sess_name" | |
419 | fi | |
d3e8f6bb DG |
420 | } |
421 | ||
fb3268e3 | 422 | function stop_lttng_tracing () |
d3e8f6bb | 423 | { |
7d0ad314 | 424 | local sess_name=$1 |
01513c3e | 425 | local expected_to_fail=$2 |
d3e8f6bb | 426 | |
873c2aae | 427 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name >$OUTPUT_DEST |
01513c3e JRJ |
428 | ret=$? |
429 | if [[ $expected_to_fail ]]; then | |
430 | test "$ret" -ne "0" | |
431 | ok $? "Expected fail on stop tracing for session: $sess_name" | |
432 | else | |
433 | ok $ret "Stop lttng tracing for session $sess_name" | |
434 | fi | |
d3e8f6bb DG |
435 | } |
436 | ||
437 | function destroy_lttng_session () | |
438 | { | |
7d0ad314 | 439 | local sess_name=$1 |
01513c3e | 440 | local expected_to_fail=$2 |
d3e8f6bb | 441 | |
873c2aae | 442 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name >$OUTPUT_DEST |
01513c3e JRJ |
443 | ret=$? |
444 | if [[ $expected_to_fail ]]; then | |
445 | test "$ret" -ne "0" | |
446 | ok $? "Expected fail on session deletion $sess_name" | |
447 | else | |
448 | ok $ret "Destroy session $sess_name" | |
449 | fi | |
d3e8f6bb DG |
450 | } |
451 | ||
873c2aae JRJ |
452 | function destroy_lttng_sessions () |
453 | { | |
454 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy --all >$OUTPUT_DEST | |
455 | ok $? "Destroy all lttng sessions" | |
456 | } | |
457 | ||
07b86b52 JD |
458 | function lttng_snapshot_add_output () |
459 | { | |
7d0ad314 JRJ |
460 | local sess_name=$1 |
461 | local trace_path=$2 | |
01513c3e | 462 | local expected_to_fail=$3 |
07b86b52 | 463 | |
873c2aae | 464 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name file://$trace_path >$OUTPUT_DEST |
01513c3e JRJ |
465 | ret=$? |
466 | if [[ $expected_to_fail ]]; then | |
467 | test "$ret" -ne "0" | |
468 | ok $? "Failed to add a snapshot output file://$trace_path as expected" | |
469 | else | |
470 | ok $ret "Added snapshot output file://$trace_path" | |
471 | fi | |
07b86b52 JD |
472 | } |
473 | ||
26402e0c DG |
474 | function lttng_snapshot_del_output () |
475 | { | |
476 | local sess_name=$1 | |
477 | local id=$2 | |
01513c3e | 478 | local expected_to_fail=$3 |
26402e0c | 479 | |
873c2aae | 480 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output -s $sess_name $id >$OUTPUT_DEST |
01513c3e JRJ |
481 | ret=$? |
482 | if [[ $expected_to_fail ]]; then | |
483 | test "$ret" -ne "0" | |
484 | ok $? "Expect fail on deletion of snapshot output id $id" | |
485 | else | |
486 | ok $ret "Deleted snapshot output id $id" | |
487 | fi | |
26402e0c DG |
488 | } |
489 | ||
07b86b52 JD |
490 | function lttng_snapshot_record () |
491 | { | |
7d0ad314 JRJ |
492 | local sess_name=$1 |
493 | local trace_path=$2 | |
07b86b52 | 494 | |
873c2aae | 495 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot record -s $sess_name >$OUTPUT_DEST |
07b86b52 JD |
496 | ok $? "Snapshot recorded" |
497 | } | |
498 | ||
01513c3e JRJ |
499 | function lttng_snapshot_list () |
500 | { | |
501 | local sess_name=$1 | |
502 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot list-output -s $sess_name >$OUTPUT_DEST | |
503 | ok $? "Snapshot list" | |
504 | } | |
505 | ||
e02b109b DG |
506 | function lttng_save() |
507 | { | |
508 | local sess_name=$1 | |
509 | local opts=$2 | |
510 | ||
873c2aae | 511 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN save $sess_name $opts >$OUTPUT_DEST |
e02b109b DG |
512 | ok $? "Session successfully saved" |
513 | } | |
514 | ||
515 | function lttng_load() | |
516 | { | |
517 | local opts=$1 | |
518 | ||
873c2aae | 519 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN load $opts >$OUTPUT_DEST |
e02b109b DG |
520 | ok $? "Load command successful" |
521 | } | |
522 | ||
d3e8f6bb DG |
523 | function trace_matches () |
524 | { | |
7d0ad314 JRJ |
525 | local event_name=$1 |
526 | local nr_iter=$2 | |
527 | local trace_path=$3 | |
d3e8f6bb | 528 | |
317eef93 | 529 | which $BABELTRACE_BIN >/dev/null |
29655db7 | 530 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" |
d3e8f6bb | 531 | |
7d0ad314 | 532 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) |
29655db7 | 533 | |
d3e8f6bb | 534 | if [ "$count" -ne "$nr_iter" ]; then |
29655db7 CB |
535 | fail "Trace match" |
536 | diag "$count events found in trace" | |
d3e8f6bb | 537 | else |
29655db7 | 538 | pass "Trace match" |
d3e8f6bb DG |
539 | fi |
540 | } | |
f4e40ab6 | 541 | |
d53addeb DG |
542 | function trace_match_only() |
543 | { | |
544 | local event_name=$1 | |
545 | local nr_iter=$2 | |
546 | local trace_path=$3 | |
547 | ||
548 | which $BABELTRACE_BIN >/dev/null | |
549 | skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" | |
550 | ||
551 | local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) | |
552 | local total=$($BABELTRACE_BIN $trace_path | wc -l) | |
553 | ||
554 | if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then | |
555 | pass "Trace match with $total event $event_name" | |
556 | else | |
557 | fail "Trace match" | |
558 | diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count" | |
559 | fi | |
560 | } | |
561 | ||
f4e40ab6 DG |
562 | function validate_trace |
563 | { | |
7d0ad314 JRJ |
564 | local event_name=$1 |
565 | local trace_path=$2 | |
f4e40ab6 DG |
566 | |
567 | which $BABELTRACE_BIN >/dev/null | |
29655db7 CB |
568 | if [ $? -ne 0 ]; then |
569 | skip 0 "Babeltrace binary not found. Skipping trace validation" | |
f4e40ab6 DG |
570 | fi |
571 | ||
07b86b52 JD |
572 | OLDIFS=$IFS |
573 | IFS="," | |
574 | for i in $event_name; do | |
575 | traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $i | wc -l) | |
576 | if [ "$traced" -ne 0 ]; then | |
ebaaaf5e | 577 | pass "Validate trace for event $i, $traced events" |
07b86b52 JD |
578 | else |
579 | fail "Validate trace for event $i" | |
580 | diag "Found $traced occurences of $i" | |
581 | fi | |
582 | done | |
583 | ret=$? | |
584 | IFS=$OLDIFS | |
585 | return $ret | |
f4e40ab6 | 586 | } |