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