3 # Copyright (C) 2015 Julien Desfossez <jdesfossez@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="Streaming - Kernel tracing"
10 TESTDIR
=$CURDIR/..
/..
/..
11 EVENT_NAME
="lttng_test_filter_event"
14 TRACE_PATH
=$
(mktemp
-d -t tmp.test_regen_metadata_kernel_trace_path.XXXXXX
)
18 source $TESTDIR/utils
/utils.sh
20 function test_kernel_streaming
()
24 diag
"Test kernel streaming with metadata regeneration"
25 create_lttng_session_uri
$SESSION_NAME net
://localhost
26 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
27 start_lttng_tracing_ok
$SESSION_NAME
28 echo -n "100" > /proc
/lttng-test-filter-event
31 stop_lttng_tracing_ok
$SESSION_NAME
32 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
34 # Find the metadata file
35 metadata_path
=$
(find "$TRACE_PATH/$HOSTNAME/$SESSION_NAME"* -name "metadata")
37 # Empty the metadata file
38 echo -n > "$metadata_path"
40 start_lttng_tracing_ok
$SESSION_NAME
41 regenerate_metadata_ok
$SESSION_NAME
42 stop_lttng_tracing_ok
$SESSION_NAME
44 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
45 destroy_lttng_session_ok
$SESSION_NAME
49 function test_kernel_local
()
53 diag
"Test kernel local with metadata regeneration"
54 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
55 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
56 start_lttng_tracing_ok
$SESSION_NAME
59 echo -n "100" > /proc
/lttng-test-filter-event
60 stop_lttng_tracing_ok
$SESSION_NAME
61 validate_trace
$EVENT_NAME "$TRACE_PATH"
63 # Find the metadata file
64 metadata_path
=$
(find "$TRACE_PATH"* -name "metadata")
66 # Empty the metadata file
67 echo -n > "$metadata_path"
69 start_lttng_tracing_ok
$SESSION_NAME
70 regenerate_metadata_ok
$SESSION_NAME
71 stop_lttng_tracing_ok
$SESSION_NAME
73 validate_trace
$EVENT_NAME $TRACE_PATH
74 destroy_lttng_session_ok
$SESSION_NAME
79 function test_kernel_local_snapshot_after_regenerate_metadata
()
81 diag
"Test kernel local snapshot after regenerate metadata"
82 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH" --snapshot
83 lttng_enable_kernel_event
$SESSION_NAME $EVENT_NAME
84 start_lttng_tracing_ok
$SESSION_NAME
86 echo -n "100" > /proc
/lttng-test-filter-event
88 regenerate_metadata_ok
$SESSION_NAME
89 lttng_snapshot_record
$SESSION_NAME "$TRACE_PATH"
90 stop_lttng_tracing_ok
$SESSION_NAME
92 validate_trace
$EVENT_NAME "$TRACE_PATH"
93 destroy_lttng_session_ok
$SESSION_NAME
100 print_test_banner
"$TEST_DESC"
102 if [ "$(id -u)" == "0" ]; then
108 skip
$isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
110 validate_lttng_modules_present
112 start_lttng_relayd
"-o $TRACE_PATH"
116 tests
=( test_kernel_streaming test_kernel_local
117 test_kernel_local_snapshot_after_regenerate_metadata
)
119 for fct_test
in ${tests[@]};
121 SESSION_NAME
=$
(randstring
16 0)
125 modprobe
--remove lttng-test