Commit | Line | Data |
---|---|---|
e7716c6a JD |
1 | #!/bin/bash |
2 | # | |
9d16b343 | 3 | # Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com> |
e7716c6a | 4 | # |
9d16b343 MJ |
5 | # SPDX-License-Identifier: LGPL-2.1-only |
6 | ||
e7716c6a JD |
7 | TEST_DESC="Rotation - User space tracing" |
8 | ||
9 | CURDIR=$(dirname $0)/ | |
10 | TESTDIR=$CURDIR/../../.. | |
e7716c6a JD |
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 | EVENT_NAME="tp:tptest" | |
e7716c6a JD |
17 | |
18 | TRACE_PATH=$(mktemp -d) | |
19 | ||
3050aa92 | 20 | NUM_TESTS=136 |
e7716c6a JD |
21 | |
22 | source $TESTDIR/utils/utils.sh | |
23 | source $CURDIR/rotate_utils.sh | |
24 | ||
25 | if [ ! -x "$TESTAPP_BIN" ]; then | |
26 | BAIL_OUT "No UST events binary detected." | |
27 | fi | |
28 | ||
d09115ee | 29 | function enable_channel_per_pid () |
e7716c6a JD |
30 | { |
31 | sess_name=$1 | |
32 | channel_name=$2 | |
33 | ||
da0e4484 | 34 | enable_ust_lttng_channel_ok $sess_name $channel_name --buffers-pid |
e7716c6a JD |
35 | } |
36 | ||
e7716c6a JD |
37 | # MUST set TESTDIR before calling those functions |
38 | ||
39 | function rotate_ust_test () | |
40 | { | |
41 | local_path=$1 | |
42 | app_path=$2 | |
43 | per_pid=$3 | |
44 | ||
45 | start_lttng_tracing_ok $SESSION_NAME | |
46 | today=$(date +%Y%m%d) | |
47 | ||
6c4a91d6 | 48 | $TESTAPP_BIN -i 10 -w $NR_USEC_WAIT > /dev/null 2>&1 |
e7716c6a JD |
49 | rotate_session_ok $SESSION_NAME |
50 | ||
6c4a91d6 | 51 | $TESTAPP_BIN -i 20 -w $NR_USEC_WAIT > /dev/null 2>&1 |
e7716c6a JD |
52 | stop_lttng_tracing_ok $SESSION_NAME |
53 | ||
54 | # Third chunk contains no event (rotate after stop). | |
55 | rotate_session_ok $SESSION_NAME | |
56 | ||
57 | destroy_lttng_session_ok $SESSION_NAME | |
58 | ||
e7716c6a JD |
59 | validate_test_chunks "${local_path}" $today $app_path ust $per_pid |
60 | } | |
61 | ||
62 | function test_ust_streaming_uid () | |
63 | { | |
64 | diag "Test UST streaming with session rotation per UID" | |
f0d43d3d | 65 | create_lttng_session_uri $SESSION_NAME net://localhost |
e7716c6a JD |
66 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME |
67 | ||
3b33e9e7 | 68 | rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/uid/*/*/" 0 |
e7716c6a JD |
69 | } |
70 | ||
71 | function test_ust_local_uid () | |
72 | { | |
73 | diag "Test UST local with session rotation per UID" | |
74 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
75 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME | |
76 | ||
3b33e9e7 | 77 | rotate_ust_test "${TRACE_PATH}/archives" "ust/uid/*/*/" 0 |
e7716c6a JD |
78 | } |
79 | ||
80 | function test_ust_streaming_pid () | |
81 | { | |
82 | diag "Test UST streaming with session rotation per PID" | |
f0d43d3d | 83 | create_lttng_session_uri $SESSION_NAME net://localhost |
e7716c6a JD |
84 | enable_channel_per_pid $SESSION_NAME "channel0" |
85 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0" | |
86 | ||
3b33e9e7 | 87 | rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/pid/*/" 1 |
e7716c6a JD |
88 | } |
89 | ||
90 | function test_ust_local_pid () | |
91 | { | |
92 | diag "Test UST local with session rotation per PID" | |
93 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
94 | enable_channel_per_pid $SESSION_NAME "channel0" | |
95 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0" | |
96 | ||
3b33e9e7 | 97 | rotate_ust_test "${TRACE_PATH}/archives" "ust/pid/*/" 1 |
e7716c6a JD |
98 | } |
99 | ||
100 | function test_ust_local_timer_uid () | |
101 | { | |
102 | diag "Test ust local with session rotation timer per-uid" | |
103 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
104 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME | |
105 | lttng_enable_rotation_timer_ok $SESSION_NAME 500ms | |
106 | start_lttng_tracing_ok $SESSION_NAME | |
107 | # We just want the app to register, no event generated | |
6c4a91d6 | 108 | $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1 |
e7716c6a | 109 | |
3b33e9e7 | 110 | rotate_timer_test "${TRACE_PATH}/archives" 0 |
e7716c6a JD |
111 | } |
112 | ||
113 | function test_ust_streaming_timer_uid () | |
114 | { | |
115 | diag "Test ust remote with session rotation timer per-uid" | |
f0d43d3d | 116 | create_lttng_session_uri $SESSION_NAME net://localhost |
e7716c6a JD |
117 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME |
118 | lttng_enable_rotation_timer_ok $SESSION_NAME 500ms | |
119 | start_lttng_tracing_ok $SESSION_NAME | |
120 | # We just want the app to register, no event generated | |
6c4a91d6 | 121 | $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1 |
e7716c6a | 122 | |
3b33e9e7 | 123 | rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 0 |
e7716c6a JD |
124 | } |
125 | ||
126 | function test_ust_local_timer_pid () | |
127 | { | |
128 | diag "Test ust local with session rotation timer per-pid" | |
129 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
130 | enable_channel_per_pid $SESSION_NAME "channel0" | |
131 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0" | |
132 | lttng_enable_rotation_timer_ok $SESSION_NAME 500ms | |
133 | start_lttng_tracing_ok $SESSION_NAME | |
134 | # We just want the app to register, no event generated | |
6c4a91d6 | 135 | $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1 |
e7716c6a | 136 | |
3b33e9e7 | 137 | rotate_timer_test "${TRACE_PATH}/archives" 1 |
e7716c6a JD |
138 | } |
139 | ||
140 | function test_ust_streaming_timer_pid () | |
141 | { | |
142 | diag "Test ust remote with session rotation timer per-pid" | |
f0d43d3d | 143 | create_lttng_session_uri $SESSION_NAME net://localhost |
e7716c6a JD |
144 | enable_channel_per_pid $SESSION_NAME "channel0" |
145 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0" | |
146 | lttng_enable_rotation_timer_ok $SESSION_NAME 500ms | |
147 | start_lttng_tracing_ok $SESSION_NAME | |
148 | # We just want the app to register, no event generated | |
6c4a91d6 | 149 | $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1 |
e7716c6a | 150 | |
3b33e9e7 | 151 | rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 1 |
e7716c6a JD |
152 | } |
153 | ||
154 | function test_incompatible_sessions () | |
155 | { | |
156 | diag "Check incompatible session types with rotation" | |
157 | ||
158 | diag "Live session with rotate timer" | |
159 | # Should not be able to enable a rotation timer with a live session | |
308a8946 | 160 | create_lttng_session_uri $SESSION_NAME net://localhost --live |
e7716c6a JD |
161 | lttng_enable_rotation_timer_fail $SESSION_NAME 500ms |
162 | destroy_lttng_session_ok $SESSION_NAME | |
163 | ||
164 | diag "Snapshot session with rotate timer" | |
165 | # Should not be able to enable a rotation timer with a snapshot session | |
308a8946 | 166 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot |
e7716c6a JD |
167 | lttng_enable_rotation_timer_fail $SESSION_NAME 500ms |
168 | destroy_lttng_session_ok $SESSION_NAME | |
169 | ||
170 | diag "Live session with rotate" | |
171 | # Should not be able to rotate a live session | |
308a8946 | 172 | create_lttng_session_uri $SESSION_NAME net://localhost --live |
e7716c6a JD |
173 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME |
174 | start_lttng_tracing_ok $SESSION_NAME | |
175 | rotate_session_fail $SESSION_NAME | |
176 | destroy_lttng_session_ok $SESSION_NAME | |
177 | ||
178 | diag "Snapshot session with rotate" | |
179 | # Should not be able to rotate a snapshot session | |
308a8946 | 180 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot |
e7716c6a JD |
181 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME |
182 | start_lttng_tracing_ok $SESSION_NAME | |
183 | rotate_session_fail $SESSION_NAME | |
184 | destroy_lttng_session_ok $SESSION_NAME | |
e7716c6a JD |
185 | } |
186 | ||
187 | plan_tests $NUM_TESTS | |
188 | ||
189 | print_test_banner "$TEST_DESC" | |
190 | ||
191 | start_lttng_relayd "-o $TRACE_PATH" | |
192 | start_lttng_sessiond | |
193 | ||
194 | tests=( test_ust_streaming_uid test_ust_local_uid \ | |
195 | test_ust_streaming_pid test_ust_local_pid \ | |
196 | test_ust_local_timer_uid test_ust_streaming_timer_uid \ | |
197 | test_ust_local_timer_pid test_ust_streaming_timer_pid \ | |
198 | test_incompatible_sessions ) | |
199 | ||
200 | for fct_test in ${tests[@]}; | |
201 | do | |
202 | SESSION_NAME=$(randstring 16 0) | |
203 | ${fct_test} | |
8f2d0517 | 204 | clean_path $TRACE_PATH |
e7716c6a JD |
205 | done |
206 | ||
207 | stop_lttng_sessiond | |
208 | stop_lttng_relayd | |
9dc506ae JR |
209 | |
210 | # Remove tmp dir | |
211 | rm -rf $TRACE_PATH |