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 - 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 clean_path
()
38 function test_kernel_streaming
()
40 diag
"Test kernel streaming clear"
41 create_lttng_session_uri
$SESSION_NAME net
://localhost
42 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
43 start_lttng_tracing_ok
$SESSION_NAME
44 # TODO: place holder, support for streaming MUST be implemented
45 # This validate that for now we fail correctly
46 lttng_clear_session_fail
$SESSION_NAME
48 destroy_lttng_session_ok
$SESSION_NAME
51 function test_kernel_streaming_live
()
53 diag
"Test kernel streaming live clear"
54 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--live"
55 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
56 start_lttng_tracing_ok
$SESSION_NAME
57 # TODO: place holder, support for streaming MUST be implemented
58 # This validate that for now we fail correctly
59 lttng_clear_session_fail
$SESSION_NAME
61 destroy_lttng_session_ok
$SESSION_NAME
64 function test_kernel_local
()
66 diag
"Test kernel local"
67 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
68 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
69 start_lttng_tracing_ok
$SESSION_NAME
70 # TODO: place holder, support for local MUST be implemented
71 lttng_clear_session_fail
$SESSION_NAME
72 # TODO: validate that the previous chunk IS no more present
74 destroy_lttng_session_ok
$SESSION_NAME
77 function do_kernel_snapshot
()
82 lttng_enable_kernel_event
$session_name $EVENT_NAME
83 start_lttng_tracing_ok
$session_name
85 # Generate 10 events that will sit in the buffers.
86 echo -n "10" > /proc
/lttng-test-filter-event
88 # Take a first snapshot and validate that the events are present.
89 lttng_snapshot_record
$session_name
90 stop_lttng_tracing_ok
$session_name
91 validate_trace_count
$EVENT_NAME $trace_path 10
93 # Clean the output path
94 clean_path
$trace_path
95 start_lttng_tracing_ok
$session_name
97 lttng_clear_session_ok
$session_name
99 # Make sure the subsequent snapshot is empty and valid.
100 lttng_snapshot_record
$session_name
101 stop_lttng_tracing_ok
$session_name
102 validate_trace_empty
$trace_path
104 # Clean the output path
105 clean_path
$trace_path
106 start_lttng_tracing_ok
$session_name
108 # Make sure that everything still works, generate events and take a
110 echo -n "10" > /proc
/lttng-test-filter-event
111 lttng_snapshot_record
$session_name
112 stop_lttng_tracing_ok
$session_name
113 validate_trace_count
$EVENT_NAME $trace_path 10
116 function test_kernel_streaming_snapshot
()
118 diag
"Test kernel streaming snapshot clear"
120 create_lttng_session_uri
$SESSION_NAME net
://localhost
"--snapshot"
121 do_kernel_snapshot
$SESSION_NAME $TRACE_PATH
122 destroy_lttng_session_ok
$SESSION_NAME
125 function test_kernel_local_snapshot
()
127 diag
"Test kernel local snapshot clear"
129 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH "--snapshot"
130 do_kernel_snapshot
$SESSION_NAME $TRACE_PATH
131 destroy_lttng_session_ok
$SESSION_NAME
134 plan_tests
$NUM_TESTS
136 print_test_banner
"$TEST_DESC"
138 if [ "$(id -u)" == "0" ]; then
144 tests
=( test_kernel_streaming
145 test_kernel_streaming_live
147 test_kernel_streaming_snapshot
148 test_kernel_local_snapshot
151 skip
$isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
153 validate_lttng_modules_present
155 start_lttng_relayd
"-o $TRACE_PATH"
159 for fct_test
in ${tests[@]};
161 SESSION_NAME
=$
(randstring
16 0)
163 clean_path
$TRACE_PATH
171 clean_path
$TRACE_PATH