3 # Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com>
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.
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
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
17 TEST_DESC
="Streaming - User space tracing"
20 TESTDIR
=$CURDIR/..
/..
/..
23 TESTAPP_PATH
="$TESTDIR/utils/testapp"
24 TESTAPP_NAME
="gen-ust-events"
25 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
27 EVENT_NAME
="tp:tptest"
30 TRACE_PATH
=$
(mktemp
-d)
34 source $TESTDIR/utils
/utils.sh
36 if [ ! -x "$TESTAPP_BIN" ]; then
37 BAIL_OUT
"No UST events binary detected."
40 function lttng_create_session_uri
42 # Create session with default path
43 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME -U net
://localhost
>/dev
/null
2>&1
44 ok $?
"Create session with default path"
47 function lttng_create_session_uri_live
49 # Create session with default path
50 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME --live -U net
://localhost
>/dev
/null
2>&1
51 ok $?
"Create live session"
54 function enable_channel_per_pid
()
59 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-pid -u $channel_name -s $sess_name >/dev
/null
2>&1
60 ok $?
"Enable channel $channel_name per PID for session $sess_name"
63 # MUST set TESTDIR before calling those functions
65 function test_ust_streaming
()
67 local file_sync_after_first
=$
(mktemp
-u)
68 local file_sync_before_last
=$
(mktemp
-u)
70 diag
"Test UST streaming with metadata regeneration"
71 lttng_create_session_uri
72 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
74 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
75 --sync-after-first-event ${file_sync_after_first} \
76 --sync-before-last-event ${file_sync_before_last} >/dev
/null
2>&1 &
78 start_lttng_tracing_ok
$SESSION_NAME
80 touch ${file_sync_before_last}
82 # Wait for the applications started in background
84 regenerate_metadata_ok
$SESSION_NAME
86 stop_lttng_tracing_ok
$SESSION_NAME
87 destroy_lttng_session_ok
$SESSION_NAME
89 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
91 # Only delete if successful
94 rm -f ${file_sync_after_first}
95 rm -f ${file_sync_before_last}
98 function test_ust_local
()
100 local file_sync_after_first
=$
(mktemp
-u)
101 local file_sync_before_last
=$
(mktemp
-u)
103 diag
"Test UST local with metadata regeneration"
104 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
105 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
107 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
108 --sync-after-first-event ${file_sync_after_first} \
109 --sync-before-last-event ${file_sync_before_last} > /dev
/null
2>&1 &
111 start_lttng_tracing_ok
$SESSION_NAME
113 touch ${file_sync_before_last}
115 # Wait for the applications started in background
117 regenerate_metadata_ok
$SESSION_NAME
119 stop_lttng_tracing_ok
$SESSION_NAME
120 destroy_lttng_session_ok
$SESSION_NAME
122 validate_trace
$EVENT_NAME $TRACE_PATH
123 if [ $?
-eq 0 ]; then
124 # Only delete if successful
127 rm -f ${file_sync_after_first}
128 rm -f ${file_sync_before_last}
131 function test_ust_pid
()
133 local file_sync_after_first
=$
(mktemp
-u)
134 local file_sync_before_last
=$
(mktemp
-u)
136 diag
"Test UST per-pid with metadata regeneration (expect failure)"
137 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
138 enable_channel_per_pid
$SESSION_NAME "channel0"
139 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
141 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
142 --sync-after-first-event ${file_sync_after_first} \
143 --sync-before-last-event ${file_sync_before_last} >/dev
/null
2>&1 &
145 start_lttng_tracing_ok
$SESSION_NAME
147 touch ${file_sync_before_last}
149 # Wait for the applications started in background
151 regenerate_metadata_fail
$SESSION_NAME
153 stop_lttng_tracing_ok
$SESSION_NAME
154 destroy_lttng_session_ok
$SESSION_NAME
156 validate_trace
$EVENT_NAME $TRACE_PATH
157 if [ $?
-eq 0 ]; then
158 # Only delete if successful
161 rm -f ${file_sync_after_first}
162 rm -f ${file_sync_before_last}
165 function test_ust_live
()
167 local file_sync_after_first
=$
(mktemp
-u)
168 local file_sync_before_last
=$
(mktemp
-u)
170 diag
"Test UST live with metadata regeneration (expect failure)"
171 lttng_create_session_uri_live
$SESSION_NAME $TRACE_PATH
172 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
174 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
175 --sync-after-first-event ${file_sync_after_first} \
176 --sync-before-last-event ${file_sync_before_last} >/dev
/null
2>&1 &
178 start_lttng_tracing_ok
$SESSION_NAME
180 touch ${file_sync_before_last}
182 # Wait for the applications started in background
184 regenerate_metadata_fail
$SESSION_NAME
186 stop_lttng_tracing_ok
$SESSION_NAME
187 destroy_lttng_session_ok
$SESSION_NAME
189 validate_trace
$EVENT_NAME $TRACE_PATH
190 if [ $?
-eq 0 ]; then
191 # Only delete if successful
194 rm -f ${file_sync_after_first}
195 rm -f ${file_sync_before_last}
198 plan_tests
$NUM_TESTS
200 print_test_banner
"$TEST_DESC"
202 start_lttng_relayd
"-o $TRACE_PATH"
205 tests
=( test_ust_streaming test_ust_local test_ust_pid test_ust_live
)
207 for fct_test
in ${tests[@]};
209 SESSION_NAME
=$
(randstring
16 0)