3 # Copyright (C) - 2019 Jonathan Rajotte-Julien <jonathan.rajotte-julien@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
18 TEST_DESC
="Clear - UST tracing"
21 TESTDIR
=$CURDIR/..
/..
/..
22 EVENT_NAME
="tp:tptest"
24 TESTAPP_PATH
="$TESTDIR/utils/testapp"
25 TESTAPP_NAME
="gen-ust-events"
26 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
30 TRACE_PATH
=$
(mktemp
-d)
32 source $TESTDIR/utils
/utils.sh
34 if [ ! -x "$TESTAPP_BIN" ]; then
35 BAIL_OUT
"No UST events binary detected."
38 function clean_path
()
46 function test_ust_streaming
()
48 diag
"Test ust streaming clear"
49 create_lttng_session_uri
$SESSION_NAME net
://localhost
50 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
51 start_lttng_tracing_ok
$SESSION_NAME
52 # TODO: place holder, support for streaming MUST be implemented
53 # This validate that for now we fail correctly
54 lttng_clear_session_fail
$SESSION_NAME
56 destroy_lttng_session_ok
$SESSION_NAME
59 function test_ust_streaming_live
()
61 diag
"Test ust streaming live clear"
62 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live"
63 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
64 start_lttng_tracing_ok
$SESSION_NAME
65 # TODO: place holder, support for streaming MUST be implemented
66 # This validate that for now we fail correctly
67 lttng_clear_session_fail
$SESSION_NAME
69 destroy_lttng_session_ok
$SESSION_NAME
72 function test_ust_local
()
75 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
76 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
77 start_lttng_tracing_ok
$SESSION_NAME
78 # TODO: place holder, support for local MUST be implemented
79 lttng_clear_session_fail
$SESSION_NAME
80 # TODO: validate that the previous chunk IS no more present
82 destroy_lttng_session_ok
$SESSION_NAME
85 function do_ust_snapshot
()
90 enable_ust_lttng_event_ok
$session_name $EVENT_NAME
91 start_lttng_tracing_ok
$session_name
93 # Generate 10 events that will sit in the buffers.
96 # Take a first snapshot and validate that the events are present.
97 lttng_snapshot_record
$session_name
98 stop_lttng_tracing_ok
$session_name
99 validate_trace_count
$EVENT_NAME $trace_path 10
101 # Clean the output path
102 clean_path
$trace_path
103 start_lttng_tracing_ok
$session_name
105 lttng_clear_session_ok
$session_name
107 # Make sure the subsequent snapshot is empty and valid.
108 lttng_snapshot_record
$session_name
109 stop_lttng_tracing_ok
$session_name
110 validate_trace_empty
$trace_path
112 # Clean the output path
113 clean_path
$trace_path
114 start_lttng_tracing_ok
$session_name
116 # Make sure that everything still works, generate events and take a
119 lttng_snapshot_record
$session_name
120 stop_lttng_tracing_ok
$session_name
121 validate_trace_count
$EVENT_NAME $trace_path 10
124 function test_ust_streaming_snapshot
()
126 diag
"Test ust streaming snapshot clear"
128 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--snapshot"
129 do_ust_snapshot
$SESSION_NAME $TRACE_PATH
130 destroy_lttng_session_ok
$SESSION_NAME
133 function test_ust_local_snapshot
()
135 diag
"Test ust local snapshot clear"
137 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
138 do_ust_snapshot
$SESSION_NAME $TRACE_PATH
139 destroy_lttng_session_ok
$SESSION_NAME
142 function test_ust_local_snapshot_per_pid
()
144 diag
"Test ust local snapshot clear per pid "
145 local channel_name
="channel0"
146 local file_sync_before_last
=$
(mktemp
-u)
147 local file_sync_before_last_touch
=$
(mktemp
-u)
148 local file_sync_before_exit
=$
(mktemp
-u)
149 local file_sync_before_exit_touch
=$
(mktemp
-u)
151 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
152 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-pid
153 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
154 start_lttng_tracing_ok
$SESSION_NAME
156 # Generate 10 events that will sit in the buffers.
157 $TESTAPP_BIN -i 10 -w 0 \
158 --sync-before-last-event ${file_sync_before_last} \
159 --sync-before-last-event-touch ${file_sync_before_last_touch} \
160 --sync-before-exit ${file_sync_before_exit} \
161 --sync-before-exit-touch ${file_sync_before_exit_touch} >/dev
/null
2>&1 &
163 # Continue only when there is only the last event remaining.
164 while [ ! -f "${file_sync_before_last_touch}" ]; do
168 # Take a first snapshot and validate that the events are present.
169 lttng_snapshot_record
$SESSION_NAME
170 stop_lttng_tracing_ok
$SESSION_NAME
171 validate_trace_count
$EVENT_NAME $TRACE_PATH 9
173 # Clean the output path
174 clean_path
$TRACE_PATH
175 start_lttng_tracing_ok
$SESSION_NAME
177 lttng_clear_session_ok
$SESSION_NAME
179 # Make sure the subsequent snapshot is empty and valid.
180 lttng_snapshot_record
$SESSION_NAME
181 stop_lttng_tracing_ok
$SESSION_NAME
182 validate_trace_empty
$TRACE_PATH
184 # Validate that tracing still works and subsequent snapshots are valid.
185 # Clean the output path.
186 clean_path
$TRACE_PATH
187 start_lttng_tracing_ok
$SESSION_NAME
189 # Continue over the last event.
190 touch ${file_sync_before_last}
192 # Wait for the before exit sync point. This ensure that we went over the
194 while [ ! -f "${file_sync_before_exit_touch}" ]; do
198 # Make sure the snapshot contains the last event.
199 lttng_snapshot_record
$SESSION_NAME
200 stop_lttng_tracing_ok
$SESSION_NAME
201 validate_trace_count
$EVENT_NAME $TRACE_PATH 1
203 # Release the application.
204 touch ${file_sync_before_exit}
206 destroy_lttng_session_ok
$SESSION_NAME
208 rm -f ${file_sync_before_last}
209 rm -f ${file_sync_before_last_touch}
210 rm -f ${file_sync_before_exit}
211 rm -f ${file_sync_before_exit_touch}
214 plan_tests
$NUM_TESTS
216 print_test_banner
"$TEST_DESC"
221 test_ust_streaming_live
223 test_ust_streaming_snapshot
224 test_ust_local_snapshot
225 test_ust_local_snapshot_per_pid
228 start_lttng_relayd
"-o $TRACE_PATH"
231 for fct_test
in ${tests[@]};
233 SESSION_NAME
=$
(randstring
16 0)
235 clean_path
$TRACE_PATH