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)
149 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
150 enable_ust_lttng_channel_ok
$SESSION_NAME $channel_name --buffers-pid
151 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $channel_name
152 start_lttng_tracing_ok
$SESSION_NAME
154 # Generate 10 events that will sit in the buffers.
155 $TESTAPP_BIN -i 10 -w 0 \
156 --sync-before-last-event ${file_sync_before_last} \
157 --sync-before-last-event-touch ${file_sync_before_last_touch} >/dev
/null
2>&1 &
159 # Continue only when there is only the last event remaining.
160 while [ ! -f "${file_sync_before_last_touch}" ]; do
164 # Take a first snapshot and validate that the events are present.
165 lttng_snapshot_record
$SESSION_NAME
166 stop_lttng_tracing_ok
$SESSION_NAME
167 validate_trace_count
$EVENT_NAME $TRACE_PATH 9
169 # Clean the output path
170 clean_path
$TRACE_PATH
171 start_lttng_tracing_ok
$SESSION_NAME
173 lttng_clear_session_ok
$SESSION_NAME
175 # Make sure the subsequent snapshot is empty and valid.
176 lttng_snapshot_record
$SESSION_NAME
177 stop_lttng_tracing_ok
$SESSION_NAME
178 validate_trace_empty
$TRACE_PATH
180 touch ${file_sync_before_last}
182 destroy_lttng_session_ok
$SESSION_NAME
184 rm -f ${file_sync_before_last}
185 rm -f ${file_sync_before_last_touch}
188 plan_tests
$NUM_TESTS
190 print_test_banner
"$TEST_DESC"
195 test_ust_streaming_live
197 test_ust_streaming_snapshot
198 test_ust_local_snapshot
199 test_ust_local_snapshot_per_pid
202 start_lttng_relayd
"-o $TRACE_PATH"
205 for fct_test
in ${tests[@]};
207 SESSION_NAME
=$
(randstring
16 0)
209 clean_path
$TRACE_PATH