Gen-ust-events: use options instead of arguments
[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
29 TRACE_PATH=$(mktemp -d)
30
31 NUM_TESTS=33
32
33 source $TESTDIR/utils/utils.sh
34
35 if [ ! -x "$TESTAPP_BIN" ]; then
36 BAIL_OUT "No UST events binary detected."
37 fi
38
39 function 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
50 function 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"
56 create_lttng_session_uri $SESSION_NAME net://localhost
57 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
58
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 &
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
69 regenerate_metadata_ok $SESSION_NAME
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
83 function 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
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 &
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
102 regenerate_metadata_ok $SESSION_NAME
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
116 function 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
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 &
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
136 regenerate_metadata_fail $SESSION_NAME
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
150 function 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)"
156 create_lttng_session_uri $SESSION_NAME net://localhost --live
157 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
158
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 &
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
169 regenerate_metadata_fail $SESSION_NAME
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
183 plan_tests $NUM_TESTS
184
185 print_test_banner "$TEST_DESC"
186
187 start_lttng_relayd "-o $TRACE_PATH"
188 start_lttng_sessiond
189
190 tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live )
191
192 for fct_test in ${tests[@]};
193 do
194 SESSION_NAME=$(randstring 16 0)
195 ${fct_test}
196 done
197
198 stop_lttng_sessiond
199 stop_lttng_relayd
200
201 exit $out
This page took 0.050403 seconds and 5 git commands to generate.