Tests: consolidate session creation with a uri parameter in utils.sh
[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
f8ccb5c8 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
f4e40ab6
DG
40# MUST set TESTDIR before calling those functions
41
42function test_ust_before_start ()
43{
5fcaccbc
MD
44 local file_sync_after_first=$(mktemp -u)
45 local file_sync_before_last=$(mktemp -u)
46
d346ccad 47 diag "Test UST streaming BEFORE tracing starts"
f0d43d3d 48 create_lttng_session_uri $SESSION_NAME net://localhost
c4926bb5 49 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
f4e40ab6
DG
50
51 # Run 5 times with a 1 second delay
5fcaccbc 52 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
c7613334 53
e563bbdb 54 start_lttng_tracing_ok $SESSION_NAME
5fcaccbc
MD
55
56 touch ${file_sync_before_last}
57
f8ccb5c8 58 # Wait for the applications started in background
c7613334 59 wait
d346ccad 60
96340a01 61 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 62 destroy_lttng_session_ok $SESSION_NAME
5fcaccbc
MD
63 rm -f ${file_sync_after_first}
64 rm -f ${file_sync_before_last}
f4e40ab6
DG
65}
66
67function test_ust_after_start ()
68{
5fcaccbc
MD
69 local file_sync_after_first=$(mktemp -u)
70
d346ccad 71 diag "Test UST streaming AFTER tracing starts"
f0d43d3d 72 create_lttng_session_uri $SESSION_NAME net://localhost
c4926bb5 73 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
e563bbdb 74 start_lttng_tracing_ok $SESSION_NAME
f4e40ab6
DG
75
76 # Run 5 times with a 1 second delay
5fcaccbc 77 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} >/dev/null 2>&1
d346ccad 78
5fcaccbc
MD
79 while [ ! -f "${file_sync_after_first}" ]; do
80 sleep 0.5
81 done
c7613334 82
96340a01 83 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 84 destroy_lttng_session_ok $SESSION_NAME
c7613334
MD
85
86 # Wait for the applications started in background
87 wait
5fcaccbc 88 rm -f ${file_sync_after_first}
f4e40ab6
DG
89}
90
d346ccad
CB
91plan_tests $NUM_TESTS
92
e3bef725
CB
93print_test_banner "$TEST_DESC"
94
fb3268e3 95start_lttng_relayd "-o $TRACE_PATH"
7972aab2 96start_lttng_sessiond
f4e40ab6
DG
97
98tests=( test_ust_before_start test_ust_after_start )
99
100for fct_test in ${tests[@]};
101do
102 SESSION_NAME=$(randstring 16 0)
103 ${fct_test}
104
105 # Validate test
f02e1e8a 106 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
f4e40ab6
DG
107 if [ $? -eq 0 ]; then
108 # Only delete if successful
f02e1e8a 109 rm -rf $TRACE_PATH
f4e40ab6
DG
110 else
111 break
112 fi
113done
114
fb3268e3
CB
115stop_lttng_sessiond
116stop_lttng_relayd
f4e40ab6
DG
117
118exit $out
This page took 0.039414 seconds and 4 git commands to generate.