Commit | Line | Data |
---|---|---|
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 | ||
18 | TEST_DESC="Event exclusion" | |
19 | ||
20 | CURDIR=$(dirname $0)/ | |
21 | TESTDIR=$CURDIR/../../.. | |
22 | LTTNG_BIN="lttng" | |
23 | STATS_BIN="$TESTDIR/utils/babelstats.pl" | |
24 | SESSION_NAME="test-exclusion" | |
25 | EV_EXCLUDE_NAME="tp:tptest2" | |
26 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
27 | TESTAPP_NAME="gen-ust-nevents" | |
28 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
29 | NR_ITER=100 | |
30 | NR_USEC_WAIT=1 | |
31 | NUM_TESTS=9 | |
32 | ||
33 | source $TESTDIR/utils/utils.sh | |
34 | ||
35 | function 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 | ||
45 | function run_apps | |
46 | { | |
47 | $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 & | |
48 | } | |
49 | ||
50 | function wait_apps | |
51 | { | |
52 | while [ -n "$(pidof $BIN_NAME)" ]; do | |
53 | sleep 1 | |
54 | done | |
55 | pass "Wait for application end" | |
56 | } | |
57 | ||
58 | function test_exclusion | |
59 | { | |
60 | trace_path=$(mktemp -d) | |
61 | ||
62 | # Create session | |
63 | create_lttng_session $SESSION_NAME $trace_path | |
64 | ||
65 | enable_ust_lttng_all_event_exclusion $SESSION_NAME $EV_EXCLUDE_NAME | |
66 | ||
67 | # Trace apps | |
68 | start_lttng_tracing $SESSION_NAME | |
69 | run_apps | |
70 | wait_apps | |
71 | stop_lttng_tracing $SESSION_NAME | |
72 | ||
73 | # Destroy session | |
74 | destroy_lttng_session $SESSION_NAME | |
75 | ||
76 | stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $EV_EXCLUDE_NAME | grep -v index` | |
77 | if [ ! -z "$stats" ]; then | |
78 | fail "Excluded event $EV_EXCLUDE_NAME was found in trace!" | |
79 | else | |
80 | ok 0 "Validate trace exclusion output" | |
81 | rm -rf $trace_path | |
82 | fi | |
83 | } | |
84 | ||
85 | plan_tests $NUM_TESTS | |
86 | ||
87 | print_test_banner $TEST_DESC | |
88 | ||
89 | start_lttng_sessiond | |
90 | ||
91 | test_exclusion | |
92 | ||
93 | stop_lttng_sessiond |