3 # Copyright (C) - 2019 Mathieu Desnoyers <mathieu.desnoyers@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 Base Path Override - 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"
26 EVENT_NAME
="tp:tptest"
28 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 ust_app_stream_base_path
()
40 local session_name
=$
(randstring
16 0)
41 local base_path
="my/custom/path1"
43 diag
"Test base path override for trace streaming"
44 create_lttng_session_uri
$session_name net
://localhost
/$base_path
45 enable_ust_lttng_event_ok
$session_name $EVENT_NAME
47 start_lttng_tracing_ok
$session_name
49 $TESTAPP_BIN > /dev
/null
2>&1
51 stop_lttng_tracing_ok
$session_name
52 destroy_lttng_session_ok
$session_name
55 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$base_path
57 # only delete if successful
62 function ust_app_snapshot_create_base_path
()
64 local session_name
=$
(randstring
16 0)
65 local base_path
="my/custom/path2"
67 diag
"Test base path override for remote trace snapshot (URI on create)"
68 create_lttng_session_uri
$session_name net
://localhost
/$base_path \
70 enable_ust_lttng_event_ok
$session_name $EVENT_NAME
72 start_lttng_tracing_ok
$session_name
74 $TESTAPP_BIN > /dev
/null
2>&1
76 stop_lttng_tracing_ok
$session_name
78 lttng_snapshot_record
$session_name
80 destroy_lttng_session_ok
$session_name
83 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$base_path
85 # only delete if successful
90 function ust_app_snapshot_base_path
()
92 local session_name
=$
(randstring
16 0)
93 local base_path
="my/custom/path3"
95 diag
"Test base path override for remote trace snapshot (URI on snapshot)"
96 create_lttng_session_no_output
$session_name --snapshot
97 enable_ust_lttng_event_ok
$session_name $EVENT_NAME
99 start_lttng_tracing_ok
$session_name
101 $TESTAPP_BIN > /dev
/null
2>&1
103 stop_lttng_tracing_ok
$session_name
105 lttng_snapshot_record
$session_name net
://localhost
/$base_path
107 destroy_lttng_session_ok
$session_name
110 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$base_path
111 if [ $?
-eq 0 ]; then
112 # only delete if successful
117 function ust_app_snapshot_add_output_base_path
()
119 local session_name
=$
(randstring
16 0)
120 local base_path
="my/custom/path4"
122 diag
"Test base path override for remote trace snapshot (URI on add-output)"
123 create_lttng_session_no_output
$session_name --snapshot
124 enable_ust_lttng_event_ok
$session_name $EVENT_NAME
126 start_lttng_tracing_ok
$session_name
128 $TESTAPP_BIN > /dev
/null
2>&1
130 stop_lttng_tracing_ok
$session_name
132 lttng_snapshot_add_output_ok
$session_name net
://localhost
/$base_path
133 lttng_snapshot_record
$session_name
135 destroy_lttng_session_ok
$session_name
138 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$base_path
139 if [ $?
-eq 0 ]; then
140 # only delete if successful
145 function ust_app_stream_base_path_via_load
()
147 local session_name
="load-stream-extra-path"
148 local base_path
="my/custom/path5"
150 diag
"Test base path override for trace streaming using lttng load"
151 lttng_load_ok
"-i $CURDIR/$session_name.lttng"
152 start_lttng_tracing_ok
$session_name
154 $TESTAPP_BIN > /dev
/null
2>&1
156 stop_lttng_tracing_ok
$session_name
157 destroy_lttng_session_ok
$session_name
160 if validate_trace
$EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
161 # only delete if successful
166 plan_tests
$NUM_TESTS
168 print_test_banner
"$TEST_DESC"
170 start_lttng_relayd
"-o $TRACE_PATH"
173 tests
=( ust_app_stream_base_path
174 ust_app_snapshot_create_base_path
175 ust_app_snapshot_base_path
176 ust_app_snapshot_add_output_base_path
177 ust_app_stream_base_path_via_load
179 for fct_test
in ${tests[@]};