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 enable_channel_per_pid
()
45 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-pid -u $channel_name -s $sess_name >/dev
/null
2>&1
46 ok $?
"Enable channel $channel_name per PID for session $sess_name"
49 # MUST set TESTDIR before calling those functions
51 function test_ust_streaming
()
53 local file_sync_after_first
=$
(mktemp
-u)
54 local file_sync_before_last
=$
(mktemp
-u)
56 diag
"Test UST streaming with metadata regeneration"
57 create_lttng_session_uri
$SESSION_NAME net
://localhost
58 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
60 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev
/null
2>&1 &
62 start_lttng_tracing_ok
$SESSION_NAME
64 touch ${file_sync_before_last}
66 # Wait for the applications started in background
68 regenerate_metadata_ok
$SESSION_NAME
70 stop_lttng_tracing_ok
$SESSION_NAME
71 destroy_lttng_session_ok
$SESSION_NAME
73 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
75 # Only delete if successful
78 rm -f ${file_sync_after_first}
79 rm -f ${file_sync_before_last}
82 function test_ust_local
()
84 local file_sync_after_first
=$
(mktemp
-u)
85 local file_sync_before_last
=$
(mktemp
-u)
87 diag
"Test UST local with metadata regeneration"
88 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
89 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
91 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev
/null
2>&1 &
93 start_lttng_tracing_ok
$SESSION_NAME
95 touch ${file_sync_before_last}
97 # Wait for the applications started in background
99 regenerate_metadata_ok
$SESSION_NAME
101 stop_lttng_tracing_ok
$SESSION_NAME
102 destroy_lttng_session_ok
$SESSION_NAME
104 validate_trace
$EVENT_NAME $TRACE_PATH
105 if [ $?
-eq 0 ]; then
106 # Only delete if successful
109 rm -f ${file_sync_after_first}
110 rm -f ${file_sync_before_last}
113 function test_ust_pid
()
115 local file_sync_after_first
=$
(mktemp
-u)
116 local file_sync_before_last
=$
(mktemp
-u)
118 diag
"Test UST per-pid with metadata regeneration (expect failure)"
119 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
120 enable_channel_per_pid
$SESSION_NAME "channel0"
121 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
123 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev
/null
2>&1 &
125 start_lttng_tracing_ok
$SESSION_NAME
127 touch ${file_sync_before_last}
129 # Wait for the applications started in background
131 regenerate_metadata_fail
$SESSION_NAME
133 stop_lttng_tracing_ok
$SESSION_NAME
134 destroy_lttng_session_ok
$SESSION_NAME
136 validate_trace
$EVENT_NAME $TRACE_PATH
137 if [ $?
-eq 0 ]; then
138 # Only delete if successful
141 rm -f ${file_sync_after_first}
142 rm -f ${file_sync_before_last}
145 function test_ust_live
()
147 local file_sync_after_first
=$
(mktemp
-u)
148 local file_sync_before_last
=$
(mktemp
-u)
150 diag
"Test UST live with metadata regeneration (expect failure)"
151 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
152 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
154 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev
/null
2>&1 &
156 start_lttng_tracing_ok
$SESSION_NAME
158 touch ${file_sync_before_last}
160 # Wait for the applications started in background
162 regenerate_metadata_fail
$SESSION_NAME
164 stop_lttng_tracing_ok
$SESSION_NAME
165 destroy_lttng_session_ok
$SESSION_NAME
167 validate_trace
$EVENT_NAME $TRACE_PATH
168 if [ $?
-eq 0 ]; then
169 # Only delete if successful
172 rm -f ${file_sync_after_first}
173 rm -f ${file_sync_before_last}
176 plan_tests
$NUM_TESTS
178 print_test_banner
"$TEST_DESC"
180 start_lttng_relayd
"-o $TRACE_PATH"
183 tests
=( test_ust_streaming test_ust_local test_ust_pid test_ust_live
)
185 for fct_test
in ${tests[@]};
187 SESSION_NAME
=$
(randstring
16 0)