Commit | Line | Data |
---|---|---|
6f7eb8e1 JG |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
4 | # | |
5 | # SPDX-License-Identifier: LGPL-2.1-only | |
6 | ||
7 | TEST_DESC="Rotation - Kernel tracing" | |
8 | ||
9 | CURDIR=$(dirname $0)/ | |
10 | TESTDIR=$CURDIR/../../.. | |
11 | NR_USEC_WAIT=0 | |
12 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
13 | TESTAPP_NAME="gen-ust-events" | |
14 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
15 | SESSION_NAME="stream" | |
16 | UST_EVENT_NAME="tp:tptest" | |
17 | KERNEL_EVENT_NAME="lttng_test_filter_event" | |
18 | ||
8d5a3312 | 19 | TRACE_PATH=$(mktemp -d -t tmp.rotation_ust_kernel_tracing.XXXXXX) |
6f7eb8e1 JG |
20 | |
21 | NUM_TESTS=64 | |
22 | ||
23 | source $TESTDIR/utils/utils.sh | |
24 | source $CURDIR/rotate_utils.sh | |
25 | ||
26 | function rotate_ust_kernel_test () | |
27 | { | |
28 | local local_path=$1 | |
29 | local today | |
30 | local expected_domains | |
31 | ||
32 | expected_domains=("ust" "kernel") | |
33 | ||
34 | enable_ust_lttng_event_ok $SESSION_NAME $UST_EVENT_NAME | |
35 | lttng_enable_kernel_event $SESSION_NAME $KERNEL_EVENT_NAME | |
36 | ||
37 | start_lttng_tracing_ok $SESSION_NAME | |
38 | ||
39 | today=$(date +%Y%m%d) | |
40 | ||
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 | |
45 | ||
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 | |
50 | ||
51 | # Third chunk contains no event (rotate after stop). | |
52 | rotate_session_ok $SESSION_NAME | |
53 | ||
54 | destroy_lttng_session_ok $SESSION_NAME | |
55 | ||
56 | diag "Validate kernel domain chunks" | |
57 | EVENT_NAME=$KERNEL_EVENT_NAME | |
58 | validate_test_chunks $local_path $today kernel "${expected_domains[@]}" | |
59 | ||
60 | diag "Validate user space domain chunks" | |
61 | EVENT_NAME=$UST_EVENT_NAME | |
62 | validate_test_chunks $local_path $today "ust/uid/*/*/" "${expected_domains[@]}" | |
63 | } | |
64 | ||
65 | function test_ust_kernel_streaming () | |
66 | { | |
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/*/*/" | |
70 | } | |
71 | ||
72 | function test_ust_kernel_local () | |
73 | { | |
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/*/*/" | |
77 | } | |
78 | ||
79 | if [ ! -x "$TESTAPP_BIN" ]; then | |
80 | BAIL_OUT "No UST events binary detected." | |
81 | fi | |
82 | ||
83 | plan_tests $NUM_TESTS | |
84 | ||
85 | print_test_banner "$TEST_DESC" | |
86 | bail_out_if_no_babeltrace | |
87 | ||
88 | if [ "$(id -u)" == "0" ]; then | |
89 | isroot=1 | |
90 | else | |
91 | isroot=0 | |
92 | fi | |
93 | ||
94 | skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS || | |
95 | { | |
96 | validate_lttng_modules_present | |
97 | ||
98 | start_lttng_relayd "-o $TRACE_PATH" | |
99 | start_lttng_sessiond | |
100 | modprobe lttng-test | |
101 | ||
102 | tests=( test_ust_kernel_streaming test_ust_kernel_local ) | |
103 | ||
104 | for fct_test in "${tests[@]}"; | |
105 | do | |
106 | SESSION_NAME=$(randstring 16 0) | |
107 | ${fct_test} | |
108 | clean_path "$TRACE_PATH" | |
109 | done | |
110 | ||
111 | modprobe --remove lttng-test | |
112 | stop_lttng_sessiond | |
113 | stop_lttng_relayd | |
114 | } | |
115 | ||
116 | rm -rf "$TRACE_PATH" |