3 # Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="Rotation - Kernel tracing"
10 TESTDIR
=$CURDIR/..
/..
/..
12 TESTAPP_PATH
="$TESTDIR/utils/testapp"
13 TESTAPP_NAME
="gen-ust-events"
14 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
16 UST_EVENT_NAME
="tp:tptest"
17 KERNEL_EVENT_NAME
="lttng_test_filter_event"
19 TRACE_PATH
=$
(mktemp
-d -t tmp.rotation_ust_kernel_tracing.XXXXXX
)
23 source $TESTDIR/utils
/utils.sh
24 source $CURDIR/rotate_utils.sh
26 function rotate_ust_kernel_test
()
30 local expected_domains
32 expected_domains
=("ust" "kernel")
34 enable_ust_lttng_event_ok
$SESSION_NAME $UST_EVENT_NAME
35 lttng_enable_kernel_event
$SESSION_NAME $KERNEL_EVENT_NAME
37 start_lttng_tracing_ok
$SESSION_NAME
41 # First chunk contains 10 events of each domain.
42 echo -n "10" > /proc
/lttng-test-filter-event
43 $TESTAPP_BIN -i 10 -w $NR_USEC_WAIT > /dev
/null
2>&1
44 rotate_session_ok
$SESSION_NAME
46 # Second chunk contains 20 events of each domain.
47 echo -n "20" > /proc
/lttng-test-filter-event
48 $TESTAPP_BIN -i 20 -w $NR_USEC_WAIT > /dev
/null
2>&1
49 stop_lttng_tracing_ok
$SESSION_NAME
51 # Third chunk contains no event (rotate after stop).
52 rotate_session_ok
$SESSION_NAME
54 destroy_lttng_session_ok
$SESSION_NAME
56 diag
"Validate kernel domain chunks"
57 EVENT_NAME
=$KERNEL_EVENT_NAME
58 validate_test_chunks
$local_path $today kernel
"${expected_domains[@]}"
60 diag
"Validate user space domain chunks"
61 EVENT_NAME
=$UST_EVENT_NAME
62 validate_test_chunks
$local_path $today "ust/uid/*/*/" "${expected_domains[@]}"
65 function test_ust_kernel_streaming
()
67 diag
"Test combined UST + kernel streaming with session rotation"
68 create_lttng_session_uri
$SESSION_NAME net
://localhost
69 rotate_ust_kernel_test
"${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/uid/*/*/"
72 function test_ust_kernel_local
()
74 diag
"Test combined UST + kernel local with session rotation"
75 create_lttng_session_ok
$SESSION_NAME "$TRACE_PATH"
76 rotate_ust_kernel_test
"${TRACE_PATH}/archives" "ust/uid/*/*/"
79 if [ ! -x "$TESTAPP_BIN" ]; then
80 BAIL_OUT
"No UST events binary detected."
85 print_test_banner
"$TEST_DESC"
86 bail_out_if_no_babeltrace
88 if [ "$(id -u)" == "0" ]; then
94 skip
$isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
96 validate_lttng_modules_present
98 start_lttng_relayd
"-o $TRACE_PATH"
102 tests
=( test_ust_kernel_streaming test_ust_kernel_local
)
104 for fct_test
in "${tests[@]}";
106 SESSION_NAME
=$
(randstring
16 0)
108 clean_path
"$TRACE_PATH"
111 modprobe
--remove lttng-test