3 # Copyright (C) - 2018 Jonathan Rajotte <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
="LTTng relayd filesystem grouping - Kernel tracing"
21 TESTDIR
=$CURDIR/..
/..
/..
22 EVENT_NAME
="lttng_test_filter_event"
24 TRACE_PATH
=$
(mktemp
-d)
28 source $TESTDIR/utils
/utils.sh
30 function test_kernel_live_static_name
()
32 local session_name
=$
(randstring
16 0)
33 local channel_name
=$
(randstring
8 0)
35 diag
"Test kernel live with session name"
37 create_lttng_session_uri
$session_name net
://localhost
--live
38 lttng_enable_kernel_channel_ok
$session_name $channel_name
39 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
40 start_lttng_tracing_ok
$session_name
42 echo -n "10" > /proc
/lttng-test-filter-event
44 stop_lttng_tracing_ok
$session_name
45 destroy_lttng_session_ok
$session_name
47 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*
50 function test_kernel_live_static_name_custom_output
()
52 local session_name
=$
(randstring
16 0)
53 local channel_name
=$
(randstring
8 0)
54 local custom_output
="my_live_custom_output"
56 diag
"Test kernel live with session name, custom output"
58 create_lttng_session_uri
$session_name net
://localhost
/$custom_output --live
59 lttng_enable_kernel_channel_ok
$session_name $channel_name
60 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
61 start_lttng_tracing_ok
$session_name
63 echo -n "10" > /proc
/lttng-test-filter-event
65 stop_lttng_tracing_ok
$session_name
66 destroy_lttng_session_ok
$session_name
68 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$custom_output
71 function test_kernel_streaming_static_name
()
73 local session_name
=$
(randstring
16 0)
74 local channel_name
=$
(randstring
8 0)
76 diag
"Test kernel streaming with session name"
78 create_lttng_session_uri
$session_name net
://localhost
79 lttng_enable_kernel_channel_ok
$session_name $channel_name
80 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
81 start_lttng_tracing_ok
$session_name
83 echo -n "10" > /proc
/lttng-test-filter-event
85 stop_lttng_tracing_ok
$session_name
86 destroy_lttng_session_ok
$session_name
88 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*
91 function test_kernel_streaming_static_name_custom_output
()
93 local session_name
=$
(randstring
16 0)
94 local channel_name
=$
(randstring
8 0)
95 local custom_output
="custom_second_token"
97 diag
"Test kernel streaming with session name, custom output"
99 create_lttng_session_uri
$session_name net
://localhost
/$custom_output
100 lttng_enable_kernel_channel_ok
$session_name $channel_name
101 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
102 start_lttng_tracing_ok
$session_name
104 echo -n "10" > /proc
/lttng-test-filter-event
106 stop_lttng_tracing_ok
$session_name
107 destroy_lttng_session_ok
$session_name
109 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$custom_output
112 function test_kernel_streaming_rotate_static_name
()
114 local session_name
=$
(randstring
16 0)
115 local channel_name
=$
(randstring
8 0)
117 diag
"Test kernel rotate with session name"
119 create_lttng_session_uri
$session_name net
://localhost
120 lttng_enable_kernel_channel_ok
$session_name $channel_name
121 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
122 start_lttng_tracing_ok
$session_name
124 echo -n "10" > /proc
/lttng-test-filter-event
125 rotate_session_ok
$session_name
127 stop_lttng_tracing_ok
$session_name
128 destroy_lttng_session_ok
$session_name
130 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*
133 function test_kernel_streaming_rotate_static_name_custom_output
()
135 local session_name
=$
(randstring
16 0)
136 local channel_name
=$
(randstring
8 0)
137 local custom_output
="rotate_custom_path"
139 diag
"Test kernel rotate with session name, custom output"
141 create_lttng_session_uri
$session_name net
://localhost
/$custom_output
142 lttng_enable_kernel_channel_ok
$session_name $channel_name
143 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
144 start_lttng_tracing_ok
$session_name
146 echo -n "10" > /proc
/lttng-test-filter-event
147 rotate_session_ok
$session_name
149 stop_lttng_tracing_ok
$session_name
150 destroy_lttng_session_ok
$session_name
152 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$custom_output
155 function test_kernel_streaming_snapshot_static_name
()
157 local session_name
=$
(randstring
16 0)
158 local channel_name
=$
(randstring
8 0)
160 diag
"Test kernel snapshot streaming with session name using 'create --snapshot'"
162 create_lttng_session_uri
$session_name net
://localhost
--snapshot
163 lttng_enable_kernel_channel_ok
$session_name $channel_name
164 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
165 start_lttng_tracing_ok
$session_name
167 echo -n "10" > /proc
/lttng-test-filter-event
168 lttng_snapshot_record
$session_name
170 stop_lttng_tracing_ok
$session_name
171 destroy_lttng_session_ok
$session_name
173 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/snapshot-1
*
176 function test_kernel_streaming_snapshot_add_output_default_name
()
178 local session_name
=$
(randstring
16 0)
179 local channel_name
=$
(randstring
8 0)
180 diag
"Test kernel snapshot using 'add-output' with default snapshot name"
182 create_lttng_session_no_output
$session_name
183 enable_lttng_mmap_overwrite_kernel_channel
$session_name $channel_name
184 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
185 start_lttng_tracing_ok
$session_name
187 echo -n "10" > /proc
/lttng-test-filter-event
189 lttng_snapshot_add_output_ok
$session_name "net://localhost"
190 lttng_snapshot_record
$session_name
192 stop_lttng_tracing_ok
$session_name
193 destroy_lttng_session_ok
$session_name
195 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/snapshot-1
*
198 function test_kernel_streaming_snapshot_add_output_custom_name
()
200 local session_name
=$
(randstring
16 0)
201 local channel_name
=$
(randstring
8 0)
202 local snapshot_name
="this_is_my_snapshot"
203 diag
"Test kernel snapshot using 'add-output' with custom snapshot name"
205 create_lttng_session_no_output
$session_name
206 enable_lttng_mmap_overwrite_kernel_channel
$session_name $channel_name
207 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
208 start_lttng_tracing_ok
$session_name
210 echo -n "10" > /proc
/lttng-test-filter-event
212 lttng_snapshot_add_output_ok
$session_name "net://localhost" "-n $snapshot_name"
213 lttng_snapshot_record
$session_name
215 stop_lttng_tracing_ok
$session_name
216 destroy_lttng_session_ok
$session_name
218 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$snapshot_name*
221 function test_kernel_streaming_snapshot_add_output_custom_name_custom_output
()
223 local session_name
=$
(randstring
16 0)
224 local channel_name
=$
(randstring
8 0)
225 local snapshot_name
="this_is_my_snapshot"
226 local custom_output
="this/is/my/custom/path"
227 diag
"Test kernel snapshot using 'add-output' with custom snapshot name and custom output"
229 create_lttng_session_no_output
$session_name
230 enable_lttng_mmap_overwrite_kernel_channel
$session_name $channel_name
231 enable_kernel_lttng_event_ok
$session_name $EVENT_NAME $channel_name
232 start_lttng_tracing_ok
$session_name
234 echo -n "10" > /proc
/lttng-test-filter-event
236 lttng_snapshot_add_output_ok
$session_name "net://localhost/$custom_output" "-n $snapshot_name"
237 lttng_snapshot_record
$session_name
239 stop_lttng_tracing_ok
$session_name
240 destroy_lttng_session_ok
$session_name
242 validate_trace
$EVENT_NAME $TRACE_PATH/$session_name/$HOSTNAME*/$custom_output/$snapshot_name*
245 plan_tests
$NUM_TESTS
247 print_test_banner
"$TEST_DESC"
249 if [ "$(id -u)" == "0" ]; then
255 skip
$isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
257 validate_lttng_modules_present
259 start_lttng_relayd
"-o $TRACE_PATH --group-output-by-session"
264 test_kernel_live_static_name
265 test_kernel_live_static_name_custom_output
266 test_kernel_streaming_static_name
267 test_kernel_streaming_static_name_custom_output
268 # Rotation does not exists on stable 2.9
269 # test_kernel_streaming_rotate_static_name
270 # test_kernel_streaming_rotate_static_name_custom_output
271 test_kernel_streaming_snapshot_static_name
272 test_kernel_streaming_snapshot_add_output_default_name
273 test_kernel_streaming_snapshot_add_output_custom_name
274 test_kernel_streaming_snapshot_add_output_custom_name_custom_output
276 for fct_test
in ${tests[@]};