Gen-ust-events: use options instead of arguments
[lttng-tools.git] / tests / regression / tools / regen-metadata / test_ust
CommitLineData
801236b0
JD
1#!/bin/bash
2#
3# Copyright (C) - 2015 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="Streaming - User space tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21NR_ITER=1
22NR_USEC_WAIT=0
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26SESSION_NAME="stream"
27EVENT_NAME="tp:tptest"
801236b0
JD
28
29TRACE_PATH=$(mktemp -d)
30
31NUM_TESTS=33
32
33source $TESTDIR/utils/utils.sh
34
35if [ ! -x "$TESTAPP_BIN" ]; then
36 BAIL_OUT "No UST events binary detected."
37fi
38
801236b0
JD
39function enable_channel_per_pid()
40{
41 sess_name=$1
42 channel_name=$2
43
44 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name >/dev/null 2>&1
45 ok $? "Enable channel $channel_name per PID for session $sess_name"
46}
47
48# MUST set TESTDIR before calling those functions
49
50function test_ust_streaming ()
51{
52 local file_sync_after_first=$(mktemp -u)
53 local file_sync_before_last=$(mktemp -u)
54
55 diag "Test UST streaming with metadata regeneration"
f0d43d3d 56 create_lttng_session_uri $SESSION_NAME net://localhost
801236b0
JD
57 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
58
a4c30524
JR
59 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
60 --sync-after-first-event ${file_sync_after_first} \
61 --sync-before-last-event ${file_sync_before_last} >/dev/null 2>&1 &
801236b0
JD
62
63 start_lttng_tracing_ok $SESSION_NAME
64
65 touch ${file_sync_before_last}
66
67 # Wait for the applications started in background
68 wait
eded6438 69 regenerate_metadata_ok $SESSION_NAME
801236b0
JD
70
71 stop_lttng_tracing_ok $SESSION_NAME
72 destroy_lttng_session_ok $SESSION_NAME
73 # Validate test
74 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
75 if [ $? -eq 0 ]; then
76 # Only delete if successful
77 rm -rf $TRACE_PATH
78 fi
79 rm -f ${file_sync_after_first}
80 rm -f ${file_sync_before_last}
81}
82
83function test_ust_local ()
84{
85 local file_sync_after_first=$(mktemp -u)
86 local file_sync_before_last=$(mktemp -u)
87
88 diag "Test UST local with metadata regeneration"
89 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
90 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
91
a4c30524
JR
92 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
93 --sync-after-first-event ${file_sync_after_first} \
94 --sync-before-last-event ${file_sync_before_last} > /dev/null 2>&1 &
801236b0
JD
95
96 start_lttng_tracing_ok $SESSION_NAME
97
98 touch ${file_sync_before_last}
99
100 # Wait for the applications started in background
101 wait
eded6438 102 regenerate_metadata_ok $SESSION_NAME
801236b0
JD
103
104 stop_lttng_tracing_ok $SESSION_NAME
105 destroy_lttng_session_ok $SESSION_NAME
106 # Validate test
107 validate_trace $EVENT_NAME $TRACE_PATH
108 if [ $? -eq 0 ]; then
109 # Only delete if successful
110 rm -rf $TRACE_PATH
111 fi
112 rm -f ${file_sync_after_first}
113 rm -f ${file_sync_before_last}
114}
115
116function test_ust_pid ()
117{
118 local file_sync_after_first=$(mktemp -u)
119 local file_sync_before_last=$(mktemp -u)
120
121 diag "Test UST per-pid with metadata regeneration (expect failure)"
122 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
123 enable_channel_per_pid $SESSION_NAME "channel0"
124 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
125
a4c30524
JR
126 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
127 --sync-after-first-event ${file_sync_after_first} \
128 --sync-before-last-event ${file_sync_before_last} >/dev/null 2>&1 &
801236b0
JD
129
130 start_lttng_tracing_ok $SESSION_NAME
131
132 touch ${file_sync_before_last}
133
134 # Wait for the applications started in background
135 wait
eded6438 136 regenerate_metadata_fail $SESSION_NAME
801236b0
JD
137
138 stop_lttng_tracing_ok $SESSION_NAME
139 destroy_lttng_session_ok $SESSION_NAME
140 # Validate test
141 validate_trace $EVENT_NAME $TRACE_PATH
142 if [ $? -eq 0 ]; then
143 # Only delete if successful
144 rm -rf $TRACE_PATH
145 fi
146 rm -f ${file_sync_after_first}
147 rm -f ${file_sync_before_last}
148}
149
150function test_ust_live ()
151{
152 local file_sync_after_first=$(mktemp -u)
153 local file_sync_before_last=$(mktemp -u)
154
155 diag "Test UST live with metadata regeneration (expect failure)"
f0d43d3d 156 create_lttng_session_uri $SESSION_NAME net://localhost --live
801236b0
JD
157 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
158
a4c30524
JR
159 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
160 --sync-after-first-event ${file_sync_after_first} \
161 --sync-before-last-event ${file_sync_before_last} >/dev/null 2>&1 &
801236b0
JD
162
163 start_lttng_tracing_ok $SESSION_NAME
164
165 touch ${file_sync_before_last}
166
167 # Wait for the applications started in background
168 wait
eded6438 169 regenerate_metadata_fail $SESSION_NAME
801236b0
JD
170
171 stop_lttng_tracing_ok $SESSION_NAME
172 destroy_lttng_session_ok $SESSION_NAME
173 # Validate test
174 validate_trace $EVENT_NAME $TRACE_PATH
175 if [ $? -eq 0 ]; then
176 # Only delete if successful
177 rm -rf $TRACE_PATH
178 fi
179 rm -f ${file_sync_after_first}
180 rm -f ${file_sync_before_last}
181}
182
183plan_tests $NUM_TESTS
184
185print_test_banner "$TEST_DESC"
186
187start_lttng_relayd "-o $TRACE_PATH"
188start_lttng_sessiond
189
190tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live )
191
192for fct_test in ${tests[@]};
193do
194 SESSION_NAME=$(randstring 16 0)
195 ${fct_test}
196done
197
198stop_lttng_sessiond
199stop_lttng_relayd
200
201exit $out
This page took 0.061377 seconds and 5 git commands to generate.