Gen-ust-events: use options instead of arguments
[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# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17TEST_DESC="Rotation - User space tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21NR_USEC_WAIT=0
22TESTAPP_PATH="$TESTDIR/utils/testapp"
23TESTAPP_NAME="gen-ust-events"
24TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
25SESSION_NAME="stream"
26EVENT_NAME="tp:tptest"
27
28TRACE_PATH=$(mktemp -d)
29
30NUM_TESTS=142
31
32source $TESTDIR/utils/utils.sh
33source $CURDIR/rotate_utils.sh
34
35if [ ! -x "$TESTAPP_BIN" ]; then
36 BAIL_OUT "No UST events binary detected."
37fi
38
39function enable_channel_per_pid ()
40{
41 sess_name=$1
42 channel_name=$2
43
44 enable_ust_lttng_channel_ok $sess_name $channel_name --buffers-pid
45}
46
47# MUST set TESTDIR before calling those functions
48
49function rotate_ust_test ()
50{
51 local_path=$1
52 app_path=$2
53 per_pid=$3
54
55 start_lttng_tracing_ok $SESSION_NAME
56 today=$(date +%Y%m%d)
57
58 $TESTAPP_BIN -i 10 -w $NR_USEC_WAIT >/dev/null 2>&1
59 rotate_session_ok $SESSION_NAME
60
61 $TESTAPP_BIN -i 20 -w $NR_USEC_WAIT >/dev/null 2>&1
62 stop_lttng_tracing_ok $SESSION_NAME
63
64 # Third chunk contains no event (rotate after stop).
65 rotate_session_ok $SESSION_NAME
66
67 destroy_lttng_session_ok $SESSION_NAME
68
69 validate_test_chunks "${local_path}" $today $app_path ust $per_pid
70}
71
72function test_ust_streaming_uid ()
73{
74 diag "Test UST streaming with session rotation per UID"
75 create_lttng_session_uri $SESSION_NAME net://localhost
76 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
77
78 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
79}
80
81function test_ust_local_uid ()
82{
83 diag "Test UST local with session rotation per UID"
84 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
85 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
86
87 rotate_ust_test "${TRACE_PATH}" "ust/uid/*/*/" 0
88}
89
90function test_ust_streaming_pid ()
91{
92 diag "Test UST streaming with session rotation per PID"
93 create_lttng_session_uri $SESSION_NAME net://localhost
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}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
98}
99
100function test_ust_local_pid ()
101{
102 diag "Test UST local with session rotation per PID"
103 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
104 enable_channel_per_pid $SESSION_NAME "channel0"
105 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
106
107 rotate_ust_test "${TRACE_PATH}" "ust/pid/*/" 1
108}
109
110function test_ust_local_timer_uid ()
111{
112 diag "Test ust local with session rotation timer per-uid"
113 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
114 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
115 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
116 start_lttng_tracing_ok $SESSION_NAME
117 # We just want the app to register, no event generated
118 $TESTAPP_BIN -i 0 -w 0 >/dev/null 2>&1
119
120 rotate_timer_test "${TRACE_PATH}" 0
121}
122
123function test_ust_streaming_timer_uid ()
124{
125 diag "Test ust remote with session rotation timer per-uid"
126 create_lttng_session_uri $SESSION_NAME net://localhost
127 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
128 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
129 start_lttng_tracing_ok $SESSION_NAME
130 # We just want the app to register, no event generated
131 $TESTAPP_BIN -i 0 -w 0 >/dev/null 2>&1
132
133 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
134}
135
136function test_ust_local_timer_pid ()
137{
138 diag "Test ust local with session rotation timer per-pid"
139 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
140 enable_channel_per_pid $SESSION_NAME "channel0"
141 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
142 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
143 start_lttng_tracing_ok $SESSION_NAME
144 # We just want the app to register, no event generated
145 $TESTAPP_BIN -i 0 -w 0 >/dev/null 2>&1
146
147 rotate_timer_test "${TRACE_PATH}" 1
148}
149
150function test_ust_streaming_timer_pid ()
151{
152 diag "Test ust remote with session rotation timer per-pid"
153 create_lttng_session_uri $SESSION_NAME net://localhost
154 enable_channel_per_pid $SESSION_NAME "channel0"
155 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
156 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
157 start_lttng_tracing_ok $SESSION_NAME
158 # We just want the app to register, no event generated
159 $TESTAPP_BIN -i 0 -w 0 >/dev/null 2>&1
160
161 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
162}
163
164function test_incompatible_sessions ()
165{
166 diag "Check incompatible session types with rotation"
167
168 diag "Live session with rotate timer"
169 # Should not be able to enable a rotation timer with a live session
170 create_lttng_session_uri $SESSION_NAME net://localhost --live
171 lttng_enable_rotation_timer_fail $SESSION_NAME 500ms
172 destroy_lttng_session_ok $SESSION_NAME
173
174 diag "Snapshot session with rotate timer"
175 # Should not be able to enable a rotation timer with a snapshot session
176 create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
177 lttng_enable_rotation_timer_fail $SESSION_NAME 500ms
178 destroy_lttng_session_ok $SESSION_NAME
179
180 diag "Live session with rotate"
181 # Should not be able to rotate a live session
182 create_lttng_session_uri $SESSION_NAME net://localhost --live
183 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
184 start_lttng_tracing_ok $SESSION_NAME
185 rotate_session_fail $SESSION_NAME
186 destroy_lttng_session_ok $SESSION_NAME
187
188 diag "Snapshot session with rotate"
189 # Should not be able to rotate a snapshot session
190 create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
191 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
192 start_lttng_tracing_ok $SESSION_NAME
193 rotate_session_fail $SESSION_NAME
194 destroy_lttng_session_ok $SESSION_NAME
195}
196
197plan_tests $NUM_TESTS
198
199print_test_banner "$TEST_DESC"
200
201start_lttng_relayd "-o $TRACE_PATH"
202start_lttng_sessiond
203
204tests=( test_ust_streaming_uid test_ust_local_uid \
205 test_ust_streaming_pid test_ust_local_pid \
206 test_ust_local_timer_uid test_ust_streaming_timer_uid \
207 test_ust_local_timer_pid test_ust_streaming_timer_pid \
208 test_incompatible_sessions )
209
210for fct_test in ${tests[@]};
211do
212 SESSION_NAME=$(randstring 16 0)
213 ${fct_test}
214 clean_path $TRACE_PATH
215done
216
217stop_lttng_sessiond
218stop_lttng_relayd
219
220# Remove tmp dir
221rm -rf $TRACE_PATH
This page took 0.024097 seconds and 5 git commands to generate.