Commit | Line | Data |
---|---|---|
345121ec DG |
1 | #!/bin/bash |
2 | # | |
9d16b343 | 3 | # Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com> |
345121ec | 4 | # |
9d16b343 | 5 | # SPDX-License-Identifier: GPL-2.0-only |
345121ec | 6 | # |
345121ec DG |
7 | |
8 | TEST_DESC="Event exclusion" | |
9 | ||
10 | CURDIR=$(dirname $0)/ | |
11 | TESTDIR=$CURDIR/../../.. | |
345121ec DG |
12 | STATS_BIN="$TESTDIR/utils/babelstats.pl" |
13 | SESSION_NAME="test-exclusion" | |
345121ec DG |
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 | |
062f6132 | 19 | NUM_TESTS=149 |
345121ec DG |
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 | ||
062f6132 | 28 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -a -s $sess_name -u -x "$exclusion" |
345121ec DG |
29 | } |
30 | ||
31 | function run_apps | |
32 | { | |
6c4a91d6 | 33 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev/null 2>&1 |
345121ec DG |
34 | } |
35 | ||
36 | function test_exclusion | |
37 | { | |
062f6132 PP |
38 | exclusions="$1" |
39 | event_name_expected_to_be_missing="$2" | |
345121ec DG |
40 | trace_path=$(mktemp -d) |
41 | ||
42 | # Create session | |
bf6ae429 | 43 | create_lttng_session_ok $SESSION_NAME $trace_path |
345121ec | 44 | |
062f6132 PP |
45 | enable_ust_lttng_all_event_exclusion $SESSION_NAME "$exclusions" |
46 | ok $? "Enable lttng event with event \"$exclusions\" excluded" | |
345121ec DG |
47 | |
48 | # Trace apps | |
e563bbdb | 49 | start_lttng_tracing_ok $SESSION_NAME |
345121ec | 50 | run_apps |
96340a01 | 51 | stop_lttng_tracing_ok $SESSION_NAME |
345121ec DG |
52 | |
53 | # Destroy session | |
67b4c664 | 54 | destroy_lttng_session_ok $SESSION_NAME |
345121ec | 55 | |
062f6132 | 56 | stats=`babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index` |
345121ec | 57 | if [ ! -z "$stats" ]; then |
062f6132 | 58 | fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!" |
345121ec DG |
59 | else |
60 | ok 0 "Validate trace exclusion output" | |
61 | rm -rf $trace_path | |
62 | fi | |
63 | } | |
64 | ||
062f6132 PP |
65 | function test_exclusion_fail |
66 | { | |
67 | event_name="$1" | |
68 | exclusions="$2" | |
69 | ||
70 | create_lttng_session_ok $SESSION_NAME $trace_path | |
6efba076 | 71 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -u "$event_name" -s $sess_name -x "$exclusions" >/dev/null 2>&1 |
062f6132 PP |
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 | ||
345121ec DG |
84 | plan_tests $NUM_TESTS |
85 | ||
86 | print_test_banner $TEST_DESC | |
87 | ||
88 | start_lttng_sessiond | |
89 | ||
062f6132 PP |
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" | |
345121ec DG |
121 | |
122 | stop_lttng_sessiond |