Cleanup: tests: name all temporary files to better identify leakage
[lttng-tools.git] / tests / regression / tools / rotation / test_ust
... / ...
CommitLineData
1#!/bin/bash
2#
3# Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
4#
5# SPDX-License-Identifier: LGPL-2.1-only
6
7TEST_DESC="Rotation - User space tracing"
8
9CURDIR=$(dirname $0)/
10TESTDIR=$CURDIR/../../..
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"
17
18TRACE_PATH=$(mktemp --tmpdir -d -t tmp.test_ust_rotation_trace_path.XXXXXX)
19
20NUM_TESTS=136
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
29function enable_channel_per_pid ()
30{
31 sess_name=$1
32 channel_name=$2
33
34 enable_ust_lttng_channel_ok $sess_name $channel_name --buffers-pid
35}
36
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
48 $TESTAPP_BIN -i 10 -w $NR_USEC_WAIT > /dev/null 2>&1
49 rotate_session_ok $SESSION_NAME
50
51 $TESTAPP_BIN -i 20 -w $NR_USEC_WAIT > /dev/null 2>&1
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
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"
65 create_lttng_session_uri $SESSION_NAME net://localhost
66 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
67
68 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/uid/*/*/" 0
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
77 rotate_ust_test "${TRACE_PATH}/archives" "ust/uid/*/*/" 0
78}
79
80function test_ust_streaming_pid ()
81{
82 diag "Test UST streaming with session rotation per PID"
83 create_lttng_session_uri $SESSION_NAME net://localhost
84 enable_channel_per_pid $SESSION_NAME "channel0"
85 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
86
87 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/pid/*/" 1
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
97 rotate_ust_test "${TRACE_PATH}/archives" "ust/pid/*/" 1
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
108 $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1
109
110 rotate_timer_test "${TRACE_PATH}/archives" 0
111}
112
113function test_ust_streaming_timer_uid ()
114{
115 diag "Test ust remote with session rotation timer per-uid"
116 create_lttng_session_uri $SESSION_NAME net://localhost
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
121 $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1
122
123 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 0
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
135 $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1
136
137 rotate_timer_test "${TRACE_PATH}/archives" 1
138}
139
140function test_ust_streaming_timer_pid ()
141{
142 diag "Test ust remote with session rotation timer per-pid"
143 create_lttng_session_uri $SESSION_NAME net://localhost
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
149 $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1
150
151 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 1
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
160 create_lttng_session_uri $SESSION_NAME net://localhost --live
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
166 create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
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
172 create_lttng_session_uri $SESSION_NAME net://localhost --live
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
180 create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
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
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}
204 clean_path $TRACE_PATH
205done
206
207stop_lttng_sessiond
208stop_lttng_relayd
209
210# Remove tmp dir
211rm -rf $TRACE_PATH
This page took 0.023074 seconds and 4 git commands to generate.