Refactor: test: wrapper for stop_lttng_tracing
[lttng-tools.git] / tests / regression / tools / exclusion / test_exclusion
CommitLineData
345121ec
DG
1#!/bin/bash
2#
3# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4#
5# This program is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License, version 2 only, as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12# more details.
13#
14# You should have received a copy of the GNU General Public License along with
15# this program; if not, write to the Free Software Foundation, Inc., 51
16# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18TEST_DESC="Event exclusion"
19
20CURDIR=$(dirname $0)/
21TESTDIR=$CURDIR/../../..
22LTTNG_BIN="lttng"
23STATS_BIN="$TESTDIR/utils/babelstats.pl"
24SESSION_NAME="test-exclusion"
25EV_EXCLUDE_NAME="tp:tptest2"
26TESTAPP_PATH="$TESTDIR/utils/testapp"
27TESTAPP_NAME="gen-ust-nevents"
28TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
29NR_ITER=100
30NR_USEC_WAIT=1
d7ee608c 31NUM_TESTS=8
345121ec
DG
32
33source $TESTDIR/utils/utils.sh
34
35function enable_ust_lttng_all_event_exclusion()
36{
37 sess_name="$1"
38 exclusion="$2"
39
40 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event -a -s $sess_name -u -x "$exclusion" 2>&1 >/dev/null
41
42 ok $? "Enable lttng event with event $EV_EXCLUDE_NAME excluded"
43}
44
45function run_apps
46{
d7ee608c 47 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
345121ec
DG
48}
49
50function test_exclusion
51{
52 trace_path=$(mktemp -d)
53
54 # Create session
bf6ae429 55 create_lttng_session_ok $SESSION_NAME $trace_path
345121ec
DG
56
57 enable_ust_lttng_all_event_exclusion $SESSION_NAME $EV_EXCLUDE_NAME
58
59 # Trace apps
e563bbdb 60 start_lttng_tracing_ok $SESSION_NAME
345121ec 61 run_apps
96340a01 62 stop_lttng_tracing_ok $SESSION_NAME
345121ec
DG
63
64 # Destroy session
65 destroy_lttng_session $SESSION_NAME
66
67 stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $EV_EXCLUDE_NAME | grep -v index`
68 if [ ! -z "$stats" ]; then
69 fail "Excluded event $EV_EXCLUDE_NAME was found in trace!"
70 else
71 ok 0 "Validate trace exclusion output"
72 rm -rf $trace_path
73 fi
74}
75
76plan_tests $NUM_TESTS
77
78print_test_banner $TEST_DESC
79
80start_lttng_sessiond
81
82test_exclusion
83
84stop_lttng_sessiond
This page took 0.032152 seconds and 5 git commands to generate.