Implement test_event_tracef
[lttng-tools.git] / tests / regression / ust / overlap / test_overlap
CommitLineData
26b53d3b 1#!/bin/bash
ecce1eb6
CB
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 - Wildcard overlap"
26b53d3b 18
ecce1eb6
CB
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21SESSION_NAME="wildcard-overlap"
26b53d3b 22
ecce1eb6
CB
23DEMO_EVENT1="ust_tests_demo:starting"
24DEMO_EVENT1_2="ust_tests_demo:done"
25DEMO_EVENT2="ust_tests_demo2:loop"
26DEMO_EVENT3="ust_tests_demo3:done"
26b53d3b 27
ecce1eb6
CB
28NUM_DEMO1_EVENT=1
29NUM_DEMO1_2_EVENT=1
30NUM_DEMO2_EVENT=5
31NUM_DEMO3_EVENT=1
26b53d3b 32
7972aab2 33NUM_TESTS=259
ecce1eb6
CB
34
35source $TESTDIR/utils/utils.sh
36
ecce1eb6
CB
37if [ ! -x "$CURDIR/demo/demo" ]; then
38 BAIL_OUT "No UST nevents binary detected."
39fi
40
41# MUST set TESTDIR before calling those functions
42
43run_demo_app()
44{
45 cd $CURDIR/demo
46
47 # Start test
48 ./demo-trace >/dev/null 2>&1
49 ok $? "Start application"
50
51 cd -
52}
53
54# Ease our life a bit ;)
55trace_match_demo1_events()
56{
57 trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
58 trace_matches "$DEMO_EVENT1_2" $NUM_DEMO1_EVENT $TRACE_PATH
59}
60
61# Ease our life a bit ;)
62trace_match_all_demo_events()
63{
64 trace_match_demo1_events
65 trace_matches "$DEMO_EVENT2" $NUM_DEMO2_EVENT $TRACE_PATH
66 trace_matches "$DEMO_EVENT3" $NUM_DEMO3_EVENT $TRACE_PATH
67}
68
69# Ease our life a bit ;)
70trace_match_no_demo_events()
26b53d3b 71{
ecce1eb6
CB
72 trace_matches "$DEMO_EVENT1" 0 $TRACE_PATH
73 trace_matches "$DEMO_EVENT1_2" 0 $TRACE_PATH
74 trace_matches "$DEMO_EVENT2" 0 $TRACE_PATH
75 trace_matches "$DEMO_EVENT3" 0 $TRACE_PATH
26b53d3b
DG
76}
77
ecce1eb6
CB
78# Expect all "demo" events, no duplicate.
79test_enable_simple_wildcard()
80{
81 local event_wild1="us*"
82 local event_wild2="ust*"
83
84 diag "Simple wildcard overlap"
85
86 enable_ust_lttng_event $SESSION_NAME "$event_wild1"
87 enable_ust_lttng_event $SESSION_NAME "$event_wild2"
88
813e19a2 89 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
90
91 run_demo_app
92
813e19a2 93 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
94
95 trace_match_all_demo_events
96
97 return $?
98}
99
100# Expect all "demo" events, no duplicate.
101test_enable_wildcard_filter()
102{
103 local event_wild1="us*"
104 local event_wild2="ust*"
105
106 diag "Wildcard overlap with filter"
107
108 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
109 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
110
813e19a2 111 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
112
113 run_demo_app
114
813e19a2 115 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
116
117 trace_match_all_demo_events
118 return $?
119}
120
121# Expect all "demo" events, no duplicate.
122test_enable_wildcard_filter_2()
123{
124 local event_wild1="us*"
125 local event_wild2="ust*"
126
127 diag "Wildcard overlap with filter 2"
128
129 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
130 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
131
813e19a2 132 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
133
134 run_demo_app
135
813e19a2 136 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
137
138 trace_match_all_demo_events
139 return $?
140}
141
142# Expect all "demo" events, no duplicate.
143test_enable_wildcard_filter_3()
144{
145 local event_wild1="us*"
146 local event_wild2="ust*"
147
148 diag "Wildcard overlap with filter 3"
149
150 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
151 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
152
813e19a2 153 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
154
155 run_demo_app
156
813e19a2 157 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
158
159 trace_match_all_demo_events
160 return $?
161}
162
163# Expected: No events.
164test_enable_wildcard_filter_4()
165{
166 local event_wild1="us*"
167 local event_wild2="ust*"
168
169 diag "Wildcard overlap with filter 4"
170
171 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
172 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
173
813e19a2 174 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
175
176 run_demo_app
177
813e19a2 178 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
179
180 trace_match_no_demo_events
181 return $?
182}
183
184# Expect all "demo" events, no duplicate.
185test_enable_wildcard_filter_5()
186{
187 local event_wild1="us*"
188 local event_wild2="$DEMO_EVENT1"
189
190 diag "Wildcard overlap with filter 5"
191
192 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
193 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
194
813e19a2 195 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
196
197 run_demo_app
198
813e19a2 199 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
200
201 trace_match_all_demo_events
202 return $?
203}
204
205# Expect all $DEMO_EVENT1 events, no duplicate.
206test_enable_wildcard_filter_6()
207{
208 local event_wild1="us*"
209 local event_wild2="$DEMO_EVENT1"
210
211 diag "Wildcard overlap with filter 6"
212
213 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
214 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
215
813e19a2 216 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
217
218 run_demo_app
219
813e19a2 220 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
221
222 trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
223 trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
224 trace_matches $DEMO_EVENT2 0 $TRACE_PATH
225 trace_matches $DEMO_EVENT3 0 $TRACE_PATH
226 return $?
227}
228
229# Expect all events, no duplicate.
230test_enable_wildcard_filter_7()
231{
232 local event_wild1="us*"
233 local event_wild2="$DEMO_EVENT1"
234
235 diag "Wildcard overlap with filter 7"
236
237 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
238 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
239
813e19a2 240 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
241
242 run_demo_app
243
813e19a2 244 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
245
246 trace_match_all_demo_events
247 return $?
248}
249
250# Expected: No events.
251test_enable_wildcard_filter_8()
252{
253 local event_wild1="us*"
254 local event_wild2="$DEMO_EVENT1"
255
256 diag "Wildcard overlap with filter 8"
257
258 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0"
259 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
260
813e19a2 261 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
262
263 run_demo_app
264
813e19a2 265 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
266
267 trace_match_no_demo_events
268 return $?
269}
270
271# Expect all events.
272test_enable_same_wildcard_filter()
273{
274 local event_wild1="ust*"
275 local event_wild2="ust*"
276
277 diag "Same wildcard overlap with filter"
278
279 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
280 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
281
813e19a2 282 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
283
284 run_demo_app
285
813e19a2 286 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
287
288 trace_match_all_demo_events
289 return $?
290}
291
292# Expect all events.
293test_enable_same_wildcard_filter_2()
294{
295 local event_wild1="ust*"
296 local event_wild2="ust*"
297
298 diag "Same wildcard overlap with filter 2"
299
300 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
301
7972aab2 302 # Enabling the same events with same filters should fail. This one is expected to fail.
ecce1eb6 303 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_wild2" -s $SESSION_NAME -u --filter "1==1" >/dev/null 2>&1
7972aab2 304 if [ $? -ne 0 ]; then
ecce1eb6
CB
305 pass "Enable event $event_name with filtering for session $sess_name twice failure detected"
306 else
7972aab2 307 fail "Enable event $event_name with filtering for session $sess_name twice failure NOT detected"
ecce1eb6
CB
308 fi
309
813e19a2 310 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
311
312 run_demo_app
313
813e19a2 314 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
315
316 trace_match_all_demo_events
317 return $?
318}
319
320# Expect all events.
321test_enable_same_wildcard_filter_3()
322{
323 local event_wild1="ust*"
324 local event_wild2="ust*"
325
326 diag "Same wildcard overlap with filter 3"
327
328 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1"
329 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
330
813e19a2 331 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
332
333 run_demo_app
334
813e19a2 335 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
336
337 trace_match_all_demo_events
338 return $?
339}
340
341# Expected: No events.
342test_enable_same_wildcard_filter_4()
343{
344 local event_wild1="ust*"
345 local event_wild2="ust*"
346
347 diag "Same wildcard overlap with filter 4"
348
349 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0&&1==0"
350 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0"
351
813e19a2 352 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
353
354 run_demo_app
355
813e19a2 356 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
357
358 trace_match_no_demo_events
359 return $?
360}
361
362# Expected: Only $DEMO_EVENT1
363test_enable_same_event_filter()
364{
365 local event_wild1="$DEMO_EVENT1"
366 local event_wild2="$DEMO_EVENT1"
367
368 diag "Enable same event with filter."
369
370 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
371 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
372
813e19a2 373 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
374
375 run_demo_app
376
813e19a2 377 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
378
379 trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
380 trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
381 trace_matches $DEMO_EVENT2 0 $TRACE_PATH
382 trace_matches $DEMO_EVENT3 0 $TRACE_PATH
383 return $?
384}
385
386# Expected: No events.
387test_disable_same_wildcard_filter()
388{
389 local event_wild1="ust*"
390 local event_wild2="ust*"
391
392 diag "Disable same wildcard with filter."
393
394 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1"
395 enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1"
396
397 disable_ust_lttng_event $SESSION_NAME "ust*"
398
813e19a2 399 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
400
401 run_demo_app
402
813e19a2 403 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
404
405 trace_match_no_demo_events
406 return $?
407}
408
409# Expect no events
410test_enable_bad_wildcard()
411{
412 # Invalid event
413 local event_wild1="ust_tests_demo"
414 local event_wild2="ust_tests_demo2"
415 local event_wild3="ust_tests_demo3"
416
417 diag "Enable bad wildcard"
418
419 enable_ust_lttng_event $SESSION_NAME "$event_wild1"
420 enable_ust_lttng_event $SESSION_NAME "$event_wild2"
421 enable_ust_lttng_event $SESSION_NAME "$event_wild3"
422
813e19a2 423 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
424
425 run_demo_app
426
813e19a2 427 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
428
429 trace_match_no_demo_events
430 return $?
431}
432
433# Expect all "demo" events, no duplicate.
434test_enable_simple_wildcard_2()
435{
436 local event_wild1="us*"
437 local event_wild2="$DEMO_EVENT1"
438
439 diag "Simple wildcard 2"
440
441 enable_ust_lttng_event $SESSION_NAME "$event_wild1"
442 enable_ust_lttng_event $SESSION_NAME "$event_wild2"
443
813e19a2 444 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
445
446 run_demo_app
447
813e19a2 448 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
449
450 trace_match_all_demo_events
451 return $?
452}
453
454# Expected: all CRIT events, + all warning events.
455test_enable_loglevel_overlap()
456{
457 local event_wild1="us*"
458 local event_wild2="ust*"
459
460 diag "Enable loglevel overlap"
461
462 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
463 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT"
464
813e19a2 465 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
466
467 run_demo_app
468
813e19a2 469 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
470
471 trace_match_all_demo_events
472 return $?
473}
474
475# Expected: all CRIT events, + all warning events.
476test_enable_loglevel_only_overlap()
477{
478 local event_wild1="us*"
479 local event_wild2="ust*"
480
481 diag "Enable loglevel only overlap"
482
483 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
484 enable_ust_lttng_event_loglevel_only $SESSION_NAME "$event_wild2" "TRACE_CRIT"
485
813e19a2 486 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
487
488 run_demo_app
489
813e19a2 490 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
491
492 trace_match_all_demo_events
493 return $?
494}
495
496# Expected: all events
497test_enable_loglevel_overlap_2()
498{
499 local event_wild1="us*"
500 local event_wild2="$DEMO_EVENT2"
501
502 diag "Enable loglevel overlap 2"
503
504 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING"
505 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT"
506
813e19a2 507 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
508
509 run_demo_app
510
813e19a2 511 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
512
513 trace_match_all_demo_events
514 return $?
515}
516
517# Expected only ust_tests_demo* events.
518test_enable_same_wildcard_loglevels()
519{
520 local event_wild1="ust*"
521 local event_wild2="ust*"
522
523 diag "Enable same wildcard with different loglevels"
524
525 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT"
526 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING"
527
813e19a2 528 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
529
530 run_demo_app
531
813e19a2 532 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
533
534 trace_match_all_demo_events
535 return $?
536}
537
538# Expected only ust_tests_demo:starting events.
539test_enable_same_event_loglevels()
540{
541 local event_wild1="$DEMO_EVENT1"
542 local event_wild2="$DEMO_EVENT1"
543
544 diag "Enable same event with different loglevels"
545
546 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT"
547 enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING"
548
813e19a2 549 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
550
551 run_demo_app
552
813e19a2 553 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
554
555 trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH
556 trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH
557 trace_matches $DEMO_EVENT2 0 $TRACE_PATH
558 trace_matches $DEMO_EVENT3 0 $TRACE_PATH
559 return $?
560}
561
562# Expect 0 event
563test_disable_simple_wildcard()
564{
565 local event_wild1="us*"
566 local event_wild2="$DEMO_EVENT1"
567
568 diag "Disable simple wildcard"
569
570 enable_ust_lttng_event $SESSION_NAME "$event_wild1"
571 enable_ust_lttng_event $SESSION_NAME "$event_wild2"
572
573 disable_ust_lttng_event $SESSION_NAME "$event_wild1"
574 disable_ust_lttng_event $SESSION_NAME "$event_wild2"
575
813e19a2 576 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
577
578 run_demo_app
579
813e19a2 580 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
581
582 # No events are expected.
583 trace_match_no_demo_events
584 return $?
585}
586
587# Expect only "ust_tests_demo" events.
588test_disable_wildcard_overlap()
589{
590 local event_wild1="us*"
591 local event_wild2="$DEMO_EVENT1"
592
593 diag "Disable wildcard overlap"
594
595 enable_ust_lttng_event $SESSION_NAME "$event_wild1"
596 enable_ust_lttng_event $SESSION_NAME "$event_wild2"
597
598 disable_ust_lttng_event $SESSION_NAME "$event_wild1"
599
813e19a2 600 start_lttng_tracing $SESSION_NAME
ecce1eb6
CB
601
602 run_demo_app
603
813e19a2 604 stop_lttng_tracing $SESSION_NAME
ecce1eb6
CB
605
606 # Expect only "ust_tests_demo" events.
607 trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH
608 trace_matches "$DEMO_EVENT1_2" 0 $TRACE_PATH
609 trace_matches "$DEMO_EVENT2" 0 $TRACE_PATH
610 trace_matches "$DEMO_EVENT3" 0 $TRACE_PATH
611 return $?
612}
613
614plan_tests $NUM_TESTS
615
e3bef725
CB
616print_test_banner "$TEST_DESC"
617
ecce1eb6
CB
618TESTS=(
619 "test_enable_wildcard_filter"
620 "test_enable_wildcard_filter_2"
621 "test_enable_wildcard_filter_3"
622 "test_enable_wildcard_filter_4"
623 "test_enable_wildcard_filter_5"
624 "test_enable_wildcard_filter_6"
625 "test_enable_wildcard_filter_7"
626 "test_enable_wildcard_filter_8"
627 "test_enable_same_wildcard_filter"
628 "test_enable_same_wildcard_filter_2"
629 "test_enable_same_wildcard_filter_3"
630 "test_enable_same_wildcard_filter_4"
631 "test_enable_same_event_filter"
632 "test_enable_loglevel_only_overlap"
633 "test_enable_same_event_loglevels"
634 "test_enable_same_wildcard_loglevels"
635 "test_enable_bad_wildcard"
636 "test_enable_loglevel_overlap_2"
637 "test_enable_simple_wildcard"
638 "test_enable_simple_wildcard_2"
639 "test_enable_loglevel_overlap"
640 "test_disable_simple_wildcard"
641 "test_disable_wildcard_overlap"
642)
643
644TEST_COUNT=${#TESTS[@]}
645i=0
646
647start_lttng_sessiond
648
649while [ "$i" -lt "$TEST_COUNT" ]; do
650
651 TRACE_PATH=$(mktemp -d)
652
813e19a2 653 create_lttng_session $SESSION_NAME $TRACE_PATH
ecce1eb6
CB
654
655 # Execute test
656 ${TESTS[$i]}
ecce1eb6 657
813e19a2 658 destroy_lttng_session $SESSION_NAME
ecce1eb6
CB
659
660 rm -rf $TRACE_PATH
661
662 let "i++"
663done
26b53d3b 664
ecce1eb6 665stop_lttng_sessiond
This page took 0.053956 seconds and 4 git commands to generate.