Fix: add missing synchronization point for before app test case
[lttng-tools.git] / tests / regression / tools / streaming / test_ust
CommitLineData
f4e40ab6
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="Streaming - User space tracing"
f4e40ab6
DG
18
19CURDIR=$(dirname $0)/
9ac429ef 20TESTDIR=$CURDIR/../../..
ea3a3cae
CB
21NR_ITER=5
22NR_USEC_WAIT=1000000
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
f4e40ab6
DG
26SESSION_NAME="stream"
27EVENT_NAME="tp:tptest"
28PID_RELAYD=0
29
f02e1e8a
DG
30TRACE_PATH=$(mktemp -d)
31
993ae90d 32NUM_TESTS=16
d346ccad 33
9ac429ef 34source $TESTDIR/utils/utils.sh
f4e40ab6 35
ea3a3cae
CB
36if [ ! -x "$TESTAPP_BIN" ]; then
37 BAIL_OUT "No UST events binary detected."
f4e40ab6
DG
38fi
39
785d2d0d 40function lttng_create_session_uri
f4e40ab6
DG
41{
42 # Create session with default path
785d2d0d 43 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
d346ccad 44 ok $? "Create session with default path"
f4e40ab6
DG
45}
46
47function wait_apps
48{
ea3a3cae 49 while [ -n "$(pidof $TESTAPP_NAME)" ]; do
f4e40ab6
DG
50 sleep 0.5
51 done
d346ccad 52 pass "Wait for applications to end"
f4e40ab6
DG
53}
54
55# MUST set TESTDIR before calling those functions
56
57function test_ust_before_start ()
58{
0cc201a4
MD
59 local file_sync_after_first=$(mktemp -u)
60 local file_sync_before_last=$(mktemp -u)
61
d346ccad 62 diag "Test UST streaming BEFORE tracing starts"
785d2d0d 63 lttng_create_session_uri
f4e40ab6
DG
64 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
65
66 # Run 5 times with a 1 second delay
0cc201a4 67 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
f4e40ab6 68
993ae90d 69 start_lttng_tracing $SESSION_NAME
0cc201a4
MD
70
71 touch ${file_sync_before_last}
72
993ae90d
MD
73 # Wait for the applications started in background
74 wait
d346ccad 75
fb3268e3 76 stop_lttng_tracing $SESSION_NAME
f4e40ab6 77 destroy_lttng_session $SESSION_NAME
0cc201a4
MD
78 rm -f ${file_sync_after_first}
79 rm -f ${file_sync_before_last}
f4e40ab6
DG
80}
81
82function test_ust_after_start ()
83{
0cc201a4
MD
84 local file_sync_after_first=$(mktemp -u)
85
d346ccad 86 diag "Test UST streaming AFTER tracing starts"
785d2d0d 87 lttng_create_session_uri
f4e40ab6 88 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
fb3268e3 89 start_lttng_tracing $SESSION_NAME
f4e40ab6
DG
90
91 # Run 5 times with a 1 second delay
0cc201a4 92 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} >/dev/null 2>&1
d346ccad 93
0cc201a4
MD
94 while [ ! -f "${file_sync_after_first}" ]; do
95 sleep 0.5
96 done
993ae90d 97
fb3268e3 98 stop_lttng_tracing $SESSION_NAME
f4e40ab6 99 destroy_lttng_session $SESSION_NAME
993ae90d
MD
100
101 # Wait for the applications started in background
102 wait
0cc201a4 103 rm -f ${file_sync_after_first}
f4e40ab6
DG
104}
105
d346ccad
CB
106plan_tests $NUM_TESTS
107
e3bef725
CB
108print_test_banner "$TEST_DESC"
109
fb3268e3 110start_lttng_relayd "-o $TRACE_PATH"
7972aab2 111start_lttng_sessiond
f4e40ab6
DG
112
113tests=( test_ust_before_start test_ust_after_start )
114
115for fct_test in ${tests[@]};
116do
117 SESSION_NAME=$(randstring 16 0)
118 ${fct_test}
119
120 # Validate test
f02e1e8a 121 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
f4e40ab6
DG
122 if [ $? -eq 0 ]; then
123 # Only delete if successful
f02e1e8a 124 rm -rf $TRACE_PATH
f4e40ab6
DG
125 else
126 break
127 fi
128done
129
fb3268e3
CB
130stop_lttng_sessiond
131stop_lttng_relayd
f4e40ab6
DG
132
133exit $out
This page took 0.038098 seconds and 4 git commands to generate.