Doc: document tracefile max size discarded event limitation
[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"
4986e6a6 28NUM_TESTS=17
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
4986e6a6
DG
38function wait_app()
39{
40 while [ -n "$(pidof $TESTAPP_NAME)" ]; do
41 sleep 0.5
42 done
43 pass "Application $TESTAPP_NAME ended."
44}
45
46function test_before_apps()
47{
b19155c0
DG
48 # BEFORE application is spawned
49 create_lttng_session $SESSION_NAME $TRACE_PATH
50 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
fb3268e3 51 start_lttng_tracing $SESSION_NAME
f38839af 52
6cb45b17 53 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
4986e6a6 54 ok $? "Traced application stopped."
f38839af 55
fb3268e3 56 stop_lttng_tracing $SESSION_NAME
b19155c0
DG
57 destroy_lttng_session $SESSION_NAME
58
59 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
60
61 return $?
62}
63
4986e6a6
DG
64function test_after_apps()
65{
b19155c0
DG
66 local out
67
6cb45b17 68 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
4986e6a6 69 ok $? "Application started in background."
b19155c0
DG
70
71 # BEFORE application is spawned
72 create_lttng_session $SESSION_NAME $TRACE_PATH
73 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
fb3268e3 74 start_lttng_tracing $SESSION_NAME
b19155c0 75
4986e6a6
DG
76 # Since the start is done after the application is started, there is a
77 # bootstrap time needed between the session daemon and the UST tracer.
78 # Waiting for the application to end tells us when to stop everything and
79 # validate that at least one event is seen.
80 wait_app
b19155c0 81
fb3268e3 82 stop_lttng_tracing $SESSION_NAME
b19155c0
DG
83 destroy_lttng_session $SESSION_NAME
84
4986e6a6
DG
85 validate_trace $EVENT_NAME $TRACE_PATH
86 out=$?
b19155c0
DG
87
88 return $out
89}
90
91# MUST set TESTDIR before calling those functions
f38839af 92plan_tests $NUM_TESTS
b19155c0 93
e3bef725
CB
94print_test_banner "$TEST_DESC"
95
fb3268e3 96start_lttng_sessiond
b19155c0 97
4986e6a6 98diag "Start tracing BEFORE application is started"
b19155c0
DG
99
100TRACE_PATH=$(mktemp -d)
101
102test_before_apps
103out=$?
104if [ $out -ne 0 ]; then
fb3268e3 105 stop_lttng_sessiond
b19155c0
DG
106 exit $out
107fi
108
109rm -rf $TRACE_PATH
110
4986e6a6 111diag "Start tracing AFTER application is started"
b19155c0
DG
112
113TRACE_PATH=$(mktemp -d)
114
115test_after_apps
116out=$?
117if [ $out -ne 0 ]; then
fb3268e3 118 stop_lttng_sessiond
b19155c0
DG
119 exit $out
120fi
121
fb3268e3 122stop_lttng_sessiond
b19155c0
DG
123
124rm -rf $TRACE_PATH
This page took 0.040518 seconds and 5 git commands to generate.