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
112 function test_uri_switch_file_network
116 echo -e "=== Testing switch file -> network ($IPVER)"
118 TMP_PATH
=$
(mktemp
-d)
119 FILE_URI
="file://$TMP_PATH"
121 if [ "$IPVER" == "IPv6" ]; then
122 NETWORK_URIS
=("net6://localhost" "net6://[::1]")
124 NETWORK_URIS
=("net://localhost" "net://127.0.0.1")
127 NET_PATHS
=("foo/bar" "OohEehOohAhAahTingTangWallaWallaBingBang" ".")
129 for NETWORK_URI
in ${NETWORK_URIS[@]};
131 for NET_PATH
in ${NET_PATHS[@]};
133 SESSION_NAME
=$
(randstring
16 0)
135 echo "$FILE_URI -> $NETWORK_URI/$NET_PATH"
137 lttng_create_session
$FILE_URI
138 lttng_enable_consumer
"$NETWORK_URI/$NET_PATH"
139 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
140 start_tracing
$SESSION_NAME
143 stop_tracing
$SESSION_NAME
144 destroy_lttng_session
$SESSION_NAME
145 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$NET_PATH
147 if [ $?
-eq 0 ]; then
148 # Only delete if successful
158 function test_uri_switch_network_file
162 echo -e "=== Testing switch network ($IPVER) -> file"
164 if [ "$IPVER" == "IPv6" ]; then
165 NETWORK_URI
="net6://localhost"
167 NETWORK_URI
="net://localhost"
170 FILE_PATHS
=("." "foo/bar" "42")
172 for FILE_PATH
in ${FILE_PATHS[@]};
174 TMP_PATH
=$
(mktemp
-d)
175 FILE_URI
="file://$TMP_PATH"
176 SESSION_NAME
=$
(randstring
16 0)
179 echo "$NETWORK_URI -> $FILE_URI/$FILE_PATH"
181 lttng_create_session
$NETWORK_URI
182 lttng_enable_consumer
"$FILE_URI/$FILE_PATH"
183 enable_ust_lttng_event
$SESSION_NAME $EVENT_NAME
184 start_tracing
$SESSION_NAME
187 stop_tracing
$SESSION_NAME
188 destroy_lttng_session
$SESSION_NAME
189 validate_trace
$EVENT_NAME $TMP_PATH/$FILE_PATH
191 if [ $?
-eq 0 ]; then
192 # Only delete if successful
204 echo "=== Testing with IPv4"
205 lttng_start_relayd
"-o $TRACE_PATH"
206 test_uri_switch_localhost_folder
"IPv4"
207 test_uri_switch_file_network
"IPv4"
208 test_uri_switch_network_file
"IPv4"
212 echo "=== Testing with IPv6"
213 lttng_start_relayd
"-o $TRACE_PATH -C tcp6://localhost:5342 -D tcp6://localhost:5343"
214 test_uri_switch_localhost_folder
"IPv6"
215 test_uri_switch_file_network
"IPv6"
216 test_uri_switch_network_file
"IPv6"