6cd808c6d7ac13101c9ac87a5aa26614d0f7dea9
[lttng-tools.git] / tests / regression / tools / exclusion / test_exclusion
1 #!/bin/bash
2 #
3 # Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
4 #
5 # SPDX-License-Identifier: GPL-2.0-only
6 #
7
8 TEST_DESC="Event exclusion"
9
10 CURDIR=$(dirname $0)/
11 TESTDIR=$CURDIR/../../..
12 STATS_BIN="$TESTDIR/utils/babelstats.pl"
13 SESSION_NAME="test-exclusion"
14 TESTAPP_PATH="$TESTDIR/utils/testapp"
15 TESTAPP_NAME="gen-ust-nevents"
16 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
17 NR_ITER=100
18 NR_USEC_WAIT=1
19 NUM_TESTS=149
20
21 source $TESTDIR/utils/utils.sh
22
23 function enable_ust_lttng_all_event_exclusion()
24 {
25 sess_name="$1"
26 exclusion="$2"
27
28 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -a -s $sess_name -u -x "$exclusion"
29 }
30
31 function run_apps
32 {
33 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev/null 2>&1
34 }
35
36 function test_exclusion
37 {
38 exclusions="$1"
39 event_name_expected_to_be_missing="$2"
40 trace_path=$(mktemp -d)
41
42 # Create session
43 create_lttng_session_ok $SESSION_NAME $trace_path
44
45 enable_ust_lttng_all_event_exclusion $SESSION_NAME "$exclusions"
46 ok $? "Enable lttng event with event \"$exclusions\" excluded"
47
48 # Trace apps
49 start_lttng_tracing_ok $SESSION_NAME
50 run_apps
51 stop_lttng_tracing_ok $SESSION_NAME
52
53 # Destroy session
54 destroy_lttng_session_ok $SESSION_NAME
55
56 stats=`babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index`
57 if [ ! -z "$stats" ]; then
58 fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!"
59 else
60 ok 0 "Validate trace exclusion output"
61 rm -rf $trace_path
62 fi
63 }
64
65 function test_exclusion_fail
66 {
67 event_name="$1"
68 exclusions="$2"
69
70 create_lttng_session_ok $SESSION_NAME $trace_path
71 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -u "$event_name" -s $sess_name -x "$exclusions" >/dev/null 2>&1
72 res=$?
73 destroy_lttng_session_ok $SESSION_NAME
74
75 if [ $res -eq 0 ]; then
76 fail "Enable LTTng event \"$event_name\" with exclusion \"$exclusions\" passes"
77 return 1
78 else
79 pass "Enable LTTng event \"$event_name\" with exclusion \"$exclusions\" fails"
80 return 0
81 fi
82 }
83
84 plan_tests $NUM_TESTS
85
86 print_test_banner $TEST_DESC
87
88 start_lttng_sessiond
89
90 test_exclusion 'tp:tptest2' 'tp:tptest2'
91 test_exclusion 'tp:tptest3' 'tp:tptest3'
92 test_exclusion 'tp:tptest*' 'tp:tptest1'
93 test_exclusion 'tp:tptest*' 'tp:tptest2'
94 test_exclusion 'tp:tptest*' 'tp:tptest3'
95 test_exclusion 'tp:tptest*' 'tp:tptest4'
96 test_exclusion 'tp:tptest*' 'tp:tptest5'
97 test_exclusion 'tp*tptest*' 'tp:tptest1'
98 test_exclusion 'tp*tptest*' 'tp:tptest2'
99 test_exclusion 'tp*tptest*' 'tp:tptest3'
100 test_exclusion 'tp*tptest*' 'tp:tptest4'
101 test_exclusion 'tp*tptest*' 'tp:tptest5'
102 test_exclusion '*test2' 'tp:tptest2'
103 test_exclusion '*test5' 'tp:tptest5'
104 test_exclusion '*p*test*' 'tp:tptest1'
105 test_exclusion '*p*test*' 'tp:tptest2'
106 test_exclusion '*p*test*' 'tp:tptest3'
107 test_exclusion '*p***test*' 'tp:tptest4'
108 test_exclusion '*p*test*' 'tp:tptest5'
109 test_exclusion '*3' 'tp:tptest3'
110 test_exclusion 'tp*test3,*2' 'tp:tptest2'
111 test_exclusion '**tp*test3,*2' 'tp:tptest3'
112
113 # Cannot use exclusions with non-globbing event name
114 test_exclusion_fail "allo" "lol"
115 test_exclusion_fail "allo" "meow,lol"
116 test_exclusion_fail "allo" "z*em"
117
118 # Exclusion name excludes all possible event names
119 test_exclusion_fail "allo*" "all*"
120 test_exclusion_fail "allo*" "ze,all*,yes"
121
122 stop_lttng_sessiond
This page took 0.047655 seconds and 4 git commands to generate.