3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4 # David Goulet <dgoulet@efficios.com>
6 # This library is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation; version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this library; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 BIN_NAME
="gen-ust-events"
23 EVENT_NAME
="tp:tptest"
26 TRACE_PATH
=$
(mktemp
-d)
28 source $TESTDIR/utils.sh
31 echo -e "---------------------------"
32 echo -e " Streaming - URI switching "
33 echo -e "---------------------------"
35 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
36 echo -e "No UST nevents binary detected. Skipping."
40 function lttng_create_session
43 # Create session with custom URI
44 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
-U $URI $SESSION_NAME >/dev
/null
2>&1
47 function lttng_enable_consumer
50 # Create session with custom URI
51 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-consumer
-u $URI >/dev
/null
2>&1
56 # Run 5 times with a 1 second delay
59 .
/$CURDIR/$BIN_NAME $COUNT $APP_DELAY >/dev
/null
2>&1 &
65 echo -n "Waiting for applications to end"
66 while [ -n "$(pidof $BIN_NAME)" ]; do
73 function test_uri_switch_localhost_folder
76 echo -e "\n=== Testing switch of localhost folder ($IPVER)\n"
78 if [ "$IPVER" == "IPv6" ]; then
79 BASE_URI
="net6://localhost"
81 BASE_URI
="net://localhost"
88 lttng_create_session
$BASE_URI
90 echo -e "Randomizing output folder on $BASE_URI..."
91 while [ "$i" -le $RANDCOUNT ]
93 RAND
=$
(randstring
16 0)
94 lttng_enable_consumer
"$BASE_URI/$RAND"
98 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
99 start_tracing
$SESSION_NAME
102 stop_tracing
$SESSION_NAME
103 destroy_lttng_session
$SESSION_NAME
104 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$RAND
106 if [ $?
-eq 0 ]; then
107 # Only delete if successful
114 function test_uri_switch_file_network
118 echo -e "=== Testing switch file -> network ($IPVER)"
120 TMP_PATH
=$
(mktemp
-d)
121 FILE_URI
="file://$TMP_PATH"
123 if [ "$IPVER" == "IPv6" ]; then
124 NETWORK_URIS
=("net6://localhost" "net6://[::1]")
126 NETWORK_URIS
=("net://localhost" "net://127.0.0.1")
129 NET_PATHS
=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".")
131 for NETWORK_URI
in ${NETWORK_URIS[@]};
133 for NET_PATH
in ${NET_PATHS[@]};
135 SESSION_NAME
=$
(randstring
16 0)
137 echo "$FILE_URI -> $NETWORK_URI/$NET_PATH"
139 lttng_create_session
$FILE_URI
140 lttng_enable_consumer
"$NETWORK_URI/$NET_PATH"
141 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
142 start_tracing
$SESSION_NAME
145 stop_tracing
$SESSION_NAME
146 destroy_lttng_session
$SESSION_NAME
147 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH
149 if [ $?
-eq 0 ]; then
150 # Only delete if successful
160 function test_uri_switch_network_file
164 echo -e "=== Testing switch network ($IPVER) -> file"
166 if [ "$IPVER" == "IPv6" ]; then
167 NETWORK_URI
="net6://localhost"
169 NETWORK_URI
="net://localhost"
172 FILE_PATHS
=("." "foo/bar" "42")
174 for FILE_PATH
in ${FILE_PATHS[@]};
176 TMP_PATH
=$
(mktemp
-d)
177 FILE_URI
="file://$TMP_PATH"
178 SESSION_NAME
=$
(randstring
16 0)
181 echo "$NETWORK_URI -> $FILE_URI/$FILE_PATH"
183 lttng_create_session
$NETWORK_URI
184 lttng_enable_consumer
"$FILE_URI/$FILE_PATH"
185 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
186 start_tracing
$SESSION_NAME
189 stop_tracing
$SESSION_NAME
190 destroy_lttng_session
$SESSION_NAME
191 validate_trace
$EVENT_NAME $TMP_PATH/$FILE_PATH
193 if [ $?
-eq 0 ]; then
194 # Only delete if successful
206 echo "=== Testing with IPv4"
207 lttng_start_relayd
"-o $TRACE_PATH"
208 test_uri_switch_localhost_folder
"IPv4"
209 test_uri_switch_file_network
"IPv4"
210 test_uri_switch_network_file
"IPv4"
214 echo "=== Testing with IPv6"
215 lttng_start_relayd
"-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343"
216 test_uri_switch_localhost_folder
"IPv6"
217 test_uri_switch_file_network
"IPv6"
218 test_uri_switch_network_file
"IPv6"