Tests: consolidate session creation with a uri parameter in utils.sh
[lttng-tools.git] / tests / regression / tools / regen-metadata / test_ust
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
17 TEST_DESC="Streaming - User space tracing"
18
19 CURDIR=$(dirname $0)/
20 TESTDIR=$CURDIR/../../..
21 NR_ITER=1
22 NR_USEC_WAIT=0
23 TESTAPP_PATH="$TESTDIR/utils/testapp"
24 TESTAPP_NAME="gen-ust-events"
25 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26 SESSION_NAME="stream"
27 EVENT_NAME="tp:tptest"
28 PID_RELAYD=0
29
30 TRACE_PATH=$(mktemp -d)
31
32 NUM_TESTS=33
33
34 source $TESTDIR/utils/utils.sh
35
36 if [ ! -x "$TESTAPP_BIN" ]; then
37 BAIL_OUT "No UST events binary detected."
38 fi
39
40 function 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
51 function 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"
57 create_lttng_session_uri $SESSION_NAME net://localhost
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
68 regenerate_metadata_ok $SESSION_NAME
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
82 function 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
99 regenerate_metadata_ok $SESSION_NAME
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
113 function 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
131 regenerate_metadata_fail $SESSION_NAME
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
145 function 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)"
151 create_lttng_session_uri $SESSION_NAME net://localhost --live
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
162 regenerate_metadata_fail $SESSION_NAME
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
176 plan_tests $NUM_TESTS
177
178 print_test_banner "$TEST_DESC"
179
180 start_lttng_relayd "-o $TRACE_PATH"
181 start_lttng_sessiond
182
183 tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live )
184
185 for fct_test in ${tests[@]};
186 do
187 SESSION_NAME=$(randstring 16 0)
188 ${fct_test}
189 done
190
191 stop_lttng_sessiond
192 stop_lttng_relayd
193
194 exit $out
This page took 0.036237 seconds and 5 git commands to generate.