Tests: fix bad argument parsing in test app
[lttng-tools.git] / tests / regression / ust / before-after / test_before_after
CommitLineData
b19155c0
DG
1#!/bin/bash
2#
3# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c38b5107 17TEST_DESC="UST tracer - Start tracing before and after execution"
b19155c0
DG
18
19CURDIR=$(dirname $0)/
9ac429ef 20TESTDIR=$CURDIR/../../..
b19155c0 21NR_ITER=100
6cb45b17
CB
22NR_USEC_WAIT=100000
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
b19155c0 26SESSION_NAME="per-session"
6cb45b17 27EVENT_NAME="tp:tptest"
f38839af 28NUM_TESTS=16
b19155c0 29
9ac429ef 30source $TESTDIR/utils/utils.sh
b19155c0 31
6cb45b17 32if [ ! -x "$TESTAPP_BIN" ]; then
f38839af 33 BAIL_OUT "No UST nevents binary detected."
b19155c0
DG
34fi
35
36# MUST set TESTDIR before calling those functions
37
38test_before_apps() {
b19155c0
DG
39 # BEFORE application is spawned
40 create_lttng_session $SESSION_NAME $TRACE_PATH
41 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
fb3268e3 42 start_lttng_tracing $SESSION_NAME
f38839af 43
6cb45b17 44 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
f38839af
CB
45 ok $? "Start application to trace"
46
fb3268e3 47 stop_lttng_tracing $SESSION_NAME
b19155c0
DG
48 destroy_lttng_session $SESSION_NAME
49
50 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
51
52 return $?
53}
54
55test_after_apps() {
56 local out
57
6cb45b17 58 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
f38839af 59 ok $? "Start application to trace"
b19155c0
DG
60
61 # BEFORE application is spawned
62 create_lttng_session $SESSION_NAME $TRACE_PATH
63 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
fb3268e3 64 start_lttng_tracing $SESSION_NAME
b19155c0
DG
65
66 # At least hit one event
67 sleep 2
68
fb3268e3 69 stop_lttng_tracing $SESSION_NAME
b19155c0
DG
70 destroy_lttng_session $SESSION_NAME
71
72 out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
73 if [ $out -eq 0 ]; then
f38839af
CB
74 fail "Trace validation"
75 diag "No event(s) found. We are supposed to have at least one."
b19155c0
DG
76 out=1
77 else
f38839af
CB
78 pass "Trace validation"
79 diag "Found $out event(s). Coherent."
b19155c0
DG
80 out=0
81 fi
82
83 return $out
84}
85
86# MUST set TESTDIR before calling those functions
f38839af 87plan_tests $NUM_TESTS
b19155c0 88
e3bef725
CB
89print_test_banner "$TEST_DESC"
90
fb3268e3 91start_lttng_sessiond
b19155c0 92
f38839af 93diag "Start application BEFORE tracing was started"
b19155c0
DG
94
95TRACE_PATH=$(mktemp -d)
96
97test_before_apps
98out=$?
99if [ $out -ne 0 ]; then
fb3268e3 100 stop_lttng_sessiond
b19155c0
DG
101 exit $out
102fi
103
104rm -rf $TRACE_PATH
105
f38839af 106diag "Start application AFTER tracing was started"
b19155c0
DG
107
108TRACE_PATH=$(mktemp -d)
109
110test_after_apps
111out=$?
112if [ $out -ne 0 ]; then
fb3268e3 113 stop_lttng_sessiond
b19155c0
DG
114 exit $out
115fi
116
fb3268e3 117stop_lttng_sessiond
b19155c0
DG
118
119rm -rf $TRACE_PATH
This page took 0.03365 seconds and 4 git commands to generate.