summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/lttng/lttng-tools/Fix-regression-tests.patch
blob: 42f2074f9579f8336a850bcbea74513c9686b7a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
From 971c0ba5c008735b3c5013ca6e0e2e96ab63db90 Mon Sep 17 00:00:00 2001
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date: Thu, 24 Sep 2015 12:23:58 -0400
Subject: [PATCH] Fix: regression tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix racy session/relayd wait-after-kill scheme.
Fix racy live test where application may not have generated events yet
when we attach to the live trace.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>

Conflicts:
	tests/utils/utils.sh

Upstream-Status: Backport
---
 tests/regression/tools/health/test_health.sh       |   4 +-
 tests/regression/tools/live/test_kernel            |  47 +---------
 tests/regression/tools/live/test_ust               |  60 ++++--------
 .../regression/tools/live/test_ust_tracefile_count |  60 ++++--------
 tests/regression/tools/save-load/test_load         |   6 +-
 tests/utils/utils.sh                               | 103 ++++++++++++++++-----
 6 files changed, 120 insertions(+), 160 deletions(-)

diff --git a/tests/regression/tools/health/test_health.sh b/tests/regression/tools/health/test_health.sh
index 6ae8885..ddc104c 100644
--- a/tests/regression/tools/health/test_health.sh
+++ b/tests/regression/tools/health/test_health.sh
@@ -146,7 +146,9 @@ function test_health
 	fi
 
 	if [ ${test_relayd} -eq 1 ]; then
-		stop_lttng_relayd_nocheck
+		# We may fail to stop relayd here, and this is OK, since
+		# it may have been killed volountarily by testpoint.
+		stop_lttng_relayd_notap
 	fi
 	stop_lttng_sessiond
 
diff --git a/tests/regression/tools/live/test_kernel b/tests/regression/tools/live/test_kernel
index 4b958df..0e542da 100755
--- a/tests/regression/tools/live/test_kernel
+++ b/tests/regression/tools/live/test_kernel
@@ -62,22 +62,8 @@ else
 	exit 0
 fi
 
-if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
-	$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
-	if [ $? -eq 1 ]; then
-		echo "Fail to start lttng-sessiond"
-		exit 1
-	fi
-fi
-
-opt="--background -o $TRACE_PATH"
-if [ -z $(pidof lt-$RELAYD_BIN) ]; then
-	$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1
-	if [ $? -eq 1 ]; then
-		echo "Fail to start lttng-relayd (opt: $opt)"
-		return 1
-	fi
-fi
+start_lttng_sessiond_notap
+start_lttng_relayd_notap "-o $TRACE_PATH"
 
 setup_live_tracing
 
@@ -86,30 +72,5 @@ $TESTDIR/regression/tools/live/live_test
 
 clean_live_tracing
 
-# Kill the relayd
-PID_RELAYD=`pidof lt-$RELAYD_BIN`
-kill $PID_RELAYD
-if [ $? -eq 1 ]; then
-	echo "Kill lttng-relayd (pid: $PID_RELAYD)"
-	exit 1
-else
-	out=1
-	while [ -n "$out" ]; do
-		out=$(pidof lt-$RELAYD_BIN)
-		sleep 0.5
-	done
-fi
-
-# Kill the sessiond
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
-kill $PID_SESSIOND
-if [ $? -eq 1 ]; then
-	echo "Kill sessiond daemon"
-	exit 1
-else
-	out=1
-	while [ -n "$out" ]; do
-		out=$(pidof lt-$SESSIOND_BIN)
-		sleep 0.5
-	done
-fi
+stop_lttng_relayd_notap
+stop_lttng_sessiond_notap
diff --git a/tests/regression/tools/live/test_ust b/tests/regression/tools/live/test_ust
index ae69195..0b96858 100755
--- a/tests/regression/tools/live/test_ust
+++ b/tests/regression/tools/live/test_ust
@@ -59,57 +59,29 @@ function clean_live_tracing()
 	rm -rf $TRACE_PATH
 }
 
-if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
-	$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
-	if [ $? -eq 1 ]; then
-		echo "Fail to start lttng-sessiond"
-		exit 1
-	fi
-fi
-
-opt="-o $TRACE_PATH --background"
-if [ -z $(pidof lt-$RELAYD_BIN) ]; then
-	$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1
-	if [ $? -eq 1 ]; then
-		echo "Fail to start lttng-relayd (opt: $opt)"
-		return 1
-	fi
-fi
+file_sync_after_first=$(mktemp -u)
+
+start_lttng_sessiond_notap
+start_lttng_relayd_notap "-o $TRACE_PATH"
 
 setup_live_tracing
 
 # Run app in background
-$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
+$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} >/dev/null 2>&1
+
+while [ ! -f "${file_sync_after_first}" ]; do
+	sleep 0.5
+done
 
 # Start the live test
 $TESTDIR/regression/tools/live/live_test
 
+# Wait for the applications started in background
+wait
+
 clean_live_tracing
 
-# Kill the relayd
-PID_RELAYD=`pidof lt-$RELAYD_BIN`
-kill $PID_RELAYD
-if [ $? -eq 1 ]; then
-	echo "Kill lttng-relayd (pid: $PID_RELAYD)"
-	exit 1
-else
-	out=1
-	while [ -n "$out" ]; do
-		out=$(pidof lt-$RELAYD_BIN)
-		sleep 0.5
-	done
-fi
-
-# Kill the sessiond
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
-kill $PID_SESSIOND
-if [ $? -eq 1 ]; then
-	echo "Kill sessiond daemon"
-	exit 1
-else
-	out=1
-	while [ -n "$out" ]; do
-		out=$(pidof lt-$SESSIOND_BIN)
-		sleep 0.5
-	done
-fi
+rm -f ${file_sync_after_first}
+
+stop_lttng_relayd_notap
+stop_lttng_sessiond_notap
diff --git a/tests/regression/tools/live/test_ust_tracefile_count b/tests/regression/tools/live/test_ust_tracefile_count
index 68e3722..54d6a52 100755
--- a/tests/regression/tools/live/test_ust_tracefile_count
+++ b/tests/regression/tools/live/test_ust_tracefile_count
@@ -60,57 +60,29 @@ function clean_live_tracing()
 	rm -rf $TRACE_PATH
 }
 
-if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
-	$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
-	if [ $? -eq 1 ]; then
-		echo "Fail to start lttng-sessiond"
-		exit 1
-	fi
-fi
-
-opt="-o $TRACE_PATH --background"
-if [ -z $(pidof lt-$RELAYD_BIN) ]; then
-	$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1
-	if [ $? -eq 1 ]; then
-		echo "Fail to start lttng-relayd (opt: $opt)"
-		return 1
-	fi
-fi
+file_sync_after_first=$(mktemp -u)
+
+start_lttng_sessiond_notap
+start_lttng_relayd_notap "-o $TRACE_PATH"
 
 setup_live_tracing
 
 # Run app in background
-$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
+$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} >/dev/null 2>&1
+
+while [ ! -f "${file_sync_after_first}" ]; do
+	sleep 0.5
+done
 
 # Start the live test
 $TESTDIR/regression/tools/live/live_test
 
+# Wait for the applications started in background
+wait
+
 clean_live_tracing
 
-# Kill the relayd
-PID_RELAYD=`pidof lt-$RELAYD_BIN`
-kill $PID_RELAYD
-if [ $? -eq 1 ]; then
-	echo "Kill lttng-relayd (pid: $PID_RELAYD)"
-	exit 1
-else
-	out=1
-	while [ -n "$out" ]; do
-		out=$(pidof lt-$RELAYD_BIN)
-		sleep 0.5
-	done
-fi
-
-# Kill the sessiond
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
-kill $PID_SESSIOND
-if [ $? -eq 1 ]; then
-	echo "Kill sessiond daemon"
-	exit 1
-else
-	out=1
-	while [ -n "$out" ]; do
-		out=$(pidof lt-$SESSIOND_BIN)
-		sleep 0.5
-	done
-fi
+rm -f ${file_sync_after_first}
+
+stop_lttng_relayd_notap
+stop_lttng_sessiond_notap
diff --git a/tests/regression/tools/save-load/test_load b/tests/regression/tools/save-load/test_load
index 6b892cf..fc07924 100755
--- a/tests/regression/tools/save-load/test_load
+++ b/tests/regression/tools/save-load/test_load
@@ -29,7 +29,7 @@ EVENT_NAME="tp:tptest"
 
 DIR=$(readlink -f $TESTDIR)
 
-NUM_TESTS=21
+NUM_TESTS=23
 
 source $TESTDIR/utils/utils.sh
 
@@ -92,7 +92,7 @@ function test_complex_load()
 	fi
 	destroy_lttng_session $sess
 
-	stop_lttng_relayd_nocheck
+	stop_lttng_relayd
 }
 
 function test_all_load()
@@ -108,7 +108,7 @@ function test_all_load()
 	destroy_lttng_session $SESSION_NAME
 	destroy_lttng_session "$SESSION_NAME-complex"
 
-	stop_lttng_relayd_nocheck
+	stop_lttng_relayd
 }
 
 function test_overwrite()
diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
index 2510da5..1d19e64 100644
--- a/tests/utils/utils.sh
+++ b/tests/utils/utils.sh
@@ -233,9 +233,10 @@ function lttng_disable_kernel_channel_fail()
 	lttng_disable_kernel_channel 1 ${*}
 }
 
-function start_lttng_relayd
+function start_lttng_relayd_opt()
 {
-	local opt=$1
+	local withtap=$1
+	local opt=$2
 
 	DIR=$(readlink -f $TESTDIR)
 
@@ -243,52 +244,77 @@ function start_lttng_relayd
 		$DIR/../src/bin/lttng-relayd/$RELAYD_BIN -b $opt >$OUTPUT_DEST
 		#$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
 		if [ $? -eq 1 ]; then
-			fail "Start lttng-relayd (opt: $opt)"
+			if [ $withtap -eq "1" ]; then
+				fail "Start lttng-relayd (opt: $opt)"
+			fi
 			return 1
 		else
-			pass "Start lttng-relayd (opt: $opt)"
+			if [ $withtap -eq "1" ]; then
+				pass "Start lttng-relayd (opt: $opt)"
+			fi
 		fi
 	else
 		pass "Start lttng-relayd (opt: $opt)"
 	fi
 }
 
-function stop_lttng_relayd_nocheck
+function start_lttng_relayd()
 {
+	start_lttng_relayd_opt 1 "$@"
+}
+
+function start_lttng_relayd_notap()
+{
+	start_lttng_relayd_opt 0 "$@"
+}
+
+function stop_lttng_relayd_opt()
+{
+	local withtap=$1
+
 	PID_RELAYD=`pidof lt-$RELAYD_BIN`
 
-	diag "Killing lttng-relayd (pid: $PID_RELAYD)"
+	if [ $withtap -eq "1" ]; then
+		diag "Killing lttng-relayd (pid: $PID_RELAYD)"
+	fi
 	kill $PID_RELAYD >$OUTPUT_DEST
 	retval=$?
 
-	if [ $retval -eq 1 ]; then
+	if [ $? -eq 1 ]; then
+		if [ $withtap -eq "1" ]; then
+			fail "Kill relay daemon"
+		fi
+		return 1
+	else
 		out=1
 		while [ -n "$out" ]; do
 			out=$(pidof lt-$RELAYD_BIN)
 			sleep 0.5
 		done
+		if [ $withtap -eq "1" ]; then
+			pass "Kill relay daemon"
+		fi
 	fi
 	return $retval
 }
 
-function stop_lttng_relayd
+function stop_lttng_relayd()
 {
-	stop_lttng_relayd_nocheck
+	stop_lttng_relayd_opt 1 "$@"
+}
 
-	if [ $? -eq 1 ]; then
-		fail "Killed lttng-relayd (pid: $PID_RELAYD)"
-		return 1
-	else
-		pass "Killed lttng-relayd (pid: $PID_RELAYD)"
-		return 0
-	fi
+function stop_lttng_relayd_notap()
+{
+	stop_lttng_relayd_opt 0 "$@"
 }
 
-#First argument: load path for automatic loading
-function start_lttng_sessiond()
+#First arg: show tap output
+#Second argument: load path for automatic loading
+function start_lttng_sessiond_opt()
 {
+	local withtap=$1
+	local load_path=$2
 
-	local load_path="$1"
 	if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
 		# Env variable requested no session daemon
 		return
@@ -306,19 +332,33 @@ function start_lttng_sessiond()
 
 	if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
 		# Have a load path ?
-		if [ -n "$1" ]; then
+		if [ -n "$load_path" ]; then
 			$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --load "$1" --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
 		else
 			$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
 		fi
 		#$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1
 		status=$?
-		ok $status "Start session daemon"
+		if [ $withtap -eq "1" ]; then
+			ok $status "Start session daemon"
+		fi
 	fi
 }
 
-function stop_lttng_sessiond ()
+function start_lttng_sessiond()
+{
+	start_lttng_sessiond_opt 1 "$@"
+}
+
+function start_lttng_sessiond_notap()
 {
+	start_lttng_sessiond_opt 0 "$@"
+}
+
+function stop_lttng_sessiond_opt()
+{
+	local withtap=$1
+
 	if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then
 		# Env variable requested no session daemon
 		return
@@ -329,8 +369,9 @@ function stop_lttng_sessiond ()
 	kill $PID_SESSIOND >$OUTPUT_DEST
 
 	if [ $? -eq 1 ]; then
-		fail "Kill sessions daemon"
-		return 1
+		if [ $withtap -eq "1" ]; then
+			fail "Kill sessions daemon"
+		fi
 	else
 		out=1
 		while [ -n "$out" ]; do
@@ -342,10 +383,22 @@ function stop_lttng_sessiond ()
 			out=$(pidof $CONSUMERD_BIN)
 			sleep 0.5
 		done
-		pass "Kill session daemon"
+		if [ $withtap -eq "1" ]; then
+			pass "Kill session daemon"
+		fi
 	fi
 }
 
+function stop_lttng_sessiond()
+{
+	stop_lttng_sessiond_opt 1 "$@"
+}
+
+function stop_lttng_sessiond_notap()
+{
+	stop_lttng_sessiond_opt 0 "$@"
+}
+
 function list_lttng_with_opts ()
 {
 	local opts=$1
-- 
1.9.1