Cleanup: tests: name all temporary files to better identify leakage
[lttng-tools.git] / tests / regression / tools / rotation / test_ust
CommitLineData
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
7TEST_DESC="Rotation - User space tracing"
8
9CURDIR=$(dirname $0)/
10TESTDIR=$CURDIR/../../..
e7716c6a
JD
11NR_USEC_WAIT=0
12TESTAPP_PATH="$TESTDIR/utils/testapp"
13TESTAPP_NAME="gen-ust-events"
14TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
15SESSION_NAME="stream"
16EVENT_NAME="tp:tptest"
e7716c6a 17
33e55711 18TRACE_PATH=$(mktemp --tmpdir -d -t tmp.test_ust_rotation_trace_path.XXXXXX)
e7716c6a 19
3050aa92 20NUM_TESTS=136
e7716c6a
JD
21
22source $TESTDIR/utils/utils.sh
23source $CURDIR/rotate_utils.sh
24
25if [ ! -x "$TESTAPP_BIN" ]; then
26 BAIL_OUT "No UST events binary detected."
27fi
28
d09115ee 29function 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
39function 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
62function 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
71function 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
80function 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
90function 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
100function 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
113function 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
126function 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
140function 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
154function 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
187plan_tests $NUM_TESTS
188
189print_test_banner "$TEST_DESC"
190
191start_lttng_relayd "-o $TRACE_PATH"
192start_lttng_sessiond
193
194tests=( 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
200for fct_test in ${tests[@]};
201do
202 SESSION_NAME=$(randstring 16 0)
203 ${fct_test}
8f2d0517 204 clean_path $TRACE_PATH
e7716c6a
JD
205done
206
207stop_lttng_sessiond
208stop_lttng_relayd
9dc506ae
JR
209
210# Remove tmp dir
211rm -rf $TRACE_PATH
This page took 0.039757 seconds and 4 git commands to generate.