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"
29 TRACE_PATH
=$
(mktemp
-d)
33 source $TESTDIR/utils
/utils.sh
35 if [ ! -x "$TESTAPP_BIN" ]; then
36 BAIL_OUT
"No UST events binary detected."
39 function enable_channel_per_pid
()
44 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-pid -u $channel_name -s $sess_name >/dev
/null
2>&1
45 ok $?
"Enable channel $channel_name per PID for session $sess_name"
48 # MUST set TESTDIR before calling those functions
50 function test_ust_streaming
()
52 local file_sync_after_first
=$
(mktemp
-u)
53 local file_sync_before_last
=$
(mktemp
-u)
55 diag
"Test UST streaming with metadata regeneration"
56 create_lttng_session_uri
$SESSION_NAME net
://localhost
57 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
59 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
60 --sync-after-first-event ${file_sync_after_first} \
61 --sync-before-last-event ${file_sync_before_last} >/dev
/null
2>&1 &
63 start_lttng_tracing_ok
$SESSION_NAME
65 touch ${file_sync_before_last}
67 # Wait for the applications started in background
69 regenerate_metadata_ok
$SESSION_NAME
71 stop_lttng_tracing_ok
$SESSION_NAME
72 destroy_lttng_session_ok
$SESSION_NAME
74 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
76 # Only delete if successful
79 rm -f ${file_sync_after_first}
80 rm -f ${file_sync_before_last}
83 function test_ust_local
()
85 local file_sync_after_first
=$
(mktemp
-u)
86 local file_sync_before_last
=$
(mktemp
-u)
88 diag
"Test UST local with metadata regeneration"
89 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
90 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
92 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
93 --sync-after-first-event ${file_sync_after_first} \
94 --sync-before-last-event ${file_sync_before_last} > /dev
/null
2>&1 &
96 start_lttng_tracing_ok
$SESSION_NAME
98 touch ${file_sync_before_last}
100 # Wait for the applications started in background
102 regenerate_metadata_ok
$SESSION_NAME
104 stop_lttng_tracing_ok
$SESSION_NAME
105 destroy_lttng_session_ok
$SESSION_NAME
107 validate_trace
$EVENT_NAME $TRACE_PATH
108 if [ $?
-eq 0 ]; then
109 # Only delete if successful
112 rm -f ${file_sync_after_first}
113 rm -f ${file_sync_before_last}
116 function test_ust_pid
()
118 local file_sync_after_first
=$
(mktemp
-u)
119 local file_sync_before_last
=$
(mktemp
-u)
121 diag
"Test UST per-pid with metadata regeneration (expect failure)"
122 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
123 enable_channel_per_pid
$SESSION_NAME "channel0"
124 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME "channel0"
126 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
127 --sync-after-first-event ${file_sync_after_first} \
128 --sync-before-last-event ${file_sync_before_last} >/dev
/null
2>&1 &
130 start_lttng_tracing_ok
$SESSION_NAME
132 touch ${file_sync_before_last}
134 # Wait for the applications started in background
136 regenerate_metadata_fail
$SESSION_NAME
138 stop_lttng_tracing_ok
$SESSION_NAME
139 destroy_lttng_session_ok
$SESSION_NAME
141 validate_trace
$EVENT_NAME $TRACE_PATH
142 if [ $?
-eq 0 ]; then
143 # Only delete if successful
146 rm -f ${file_sync_after_first}
147 rm -f ${file_sync_before_last}
150 function test_ust_live
()
152 local file_sync_after_first
=$
(mktemp
-u)
153 local file_sync_before_last
=$
(mktemp
-u)
155 diag
"Test UST live with metadata regeneration (expect failure)"
156 create_lttng_session_uri
$SESSION_NAME net
://localhost
--live
157 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
159 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
160 --sync-after-first-event ${file_sync_after_first} \
161 --sync-before-last-event ${file_sync_before_last} >/dev
/null
2>&1 &
163 start_lttng_tracing_ok
$SESSION_NAME
165 touch ${file_sync_before_last}
167 # Wait for the applications started in background
169 regenerate_metadata_fail
$SESSION_NAME
171 stop_lttng_tracing_ok
$SESSION_NAME
172 destroy_lttng_session_ok
$SESSION_NAME
174 validate_trace
$EVENT_NAME $TRACE_PATH
175 if [ $?
-eq 0 ]; then
176 # Only delete if successful
179 rm -f ${file_sync_after_first}
180 rm -f ${file_sync_before_last}
183 plan_tests
$NUM_TESTS
185 print_test_banner
"$TEST_DESC"
187 start_lttng_relayd
"-o $TRACE_PATH"
190 tests
=( test_ust_streaming test_ust_local test_ust_pid test_ust_live
)
192 for fct_test
in ${tests[@]};
194 SESSION_NAME
=$
(randstring
16 0)