tests: Move to kernel style SPDX license identifiers
[lttng-tools.git] / tests / regression / tools / exclusion / test_exclusion
CommitLineData
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
8TEST_DESC="Event exclusion"
9
10CURDIR=$(dirname $0)/
11TESTDIR=$CURDIR/../../..
345121ec
DG
12STATS_BIN="$TESTDIR/utils/babelstats.pl"
13SESSION_NAME="test-exclusion"
345121ec
DG
14TESTAPP_PATH="$TESTDIR/utils/testapp"
15TESTAPP_NAME="gen-ust-nevents"
16TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
17NR_ITER=100
18NR_USEC_WAIT=1
062f6132 19NUM_TESTS=149
345121ec
DG
20
21source $TESTDIR/utils/utils.sh
22
23function 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
31function run_apps
32{
6c4a91d6 33 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev/null 2>&1
345121ec
DG
34}
35
36function 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
65function 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
84plan_tests $NUM_TESTS
85
86print_test_banner $TEST_DESC
87
88start_lttng_sessiond
89
062f6132
PP
90test_exclusion 'tp:tptest2' 'tp:tptest2'
91test_exclusion 'tp:tptest3' 'tp:tptest3'
92test_exclusion 'tp:tptest*' 'tp:tptest1'
93test_exclusion 'tp:tptest*' 'tp:tptest2'
94test_exclusion 'tp:tptest*' 'tp:tptest3'
95test_exclusion 'tp:tptest*' 'tp:tptest4'
96test_exclusion 'tp:tptest*' 'tp:tptest5'
97test_exclusion 'tp*tptest*' 'tp:tptest1'
98test_exclusion 'tp*tptest*' 'tp:tptest2'
99test_exclusion 'tp*tptest*' 'tp:tptest3'
100test_exclusion 'tp*tptest*' 'tp:tptest4'
101test_exclusion 'tp*tptest*' 'tp:tptest5'
102test_exclusion '*test2' 'tp:tptest2'
103test_exclusion '*test5' 'tp:tptest5'
104test_exclusion '*p*test*' 'tp:tptest1'
105test_exclusion '*p*test*' 'tp:tptest2'
106test_exclusion '*p*test*' 'tp:tptest3'
107test_exclusion '*p***test*' 'tp:tptest4'
108test_exclusion '*p*test*' 'tp:tptest5'
109test_exclusion '*3' 'tp:tptest3'
110test_exclusion 'tp*test3,*2' 'tp:tptest2'
111test_exclusion '**tp*test3,*2' 'tp:tptest3'
112
113# Cannot use exclusions with non-globbing event name
114test_exclusion_fail "allo" "lol"
115test_exclusion_fail "allo" "meow,lol"
116test_exclusion_fail "allo" "z*em"
117
118# Exclusion name excludes all possible event names
119test_exclusion_fail "allo*" "all*"
120test_exclusion_fail "allo*" "ze,all*,yes"
345121ec
DG
121
122stop_lttng_sessiond
This page took 0.038769 seconds and 4 git commands to generate.