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