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