From db7a5d4ca7a838ea1d92476f162d14c1cee8fcd3 Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Wed, 12 Jan 2022 08:49:25 +0000 Subject: [PATCH 1/6] Tidy some scripts Errors reported by Centos covscan /bin/bash in start.test is for echo -n --- tests/resources.test | 8 ++++---- tests/start.test | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/resources.test b/tests/resources.test index e3fc52391..c072e4c84 100755 --- a/tests/resources.test +++ b/tests/resources.test @@ -6,8 +6,8 @@ IPC_NAME=`cat ipc-test-name 2>/dev/null` for d in /dev/shm /var/run $SOCKETDIR; do # Tidy up the deadlock checker sockets first - dlocks=$(find $d -name qb-*-test_*dlock*${IPC_NAME}* -size +0c 2>/dev/null) - if [ `echo $dlocks|wc -w` -eq $(($SOCKS_PER_PROCESS * 6)) ]; then + dlocks=$(find $d -name "qb-*-test_*dlock*${IPC_NAME}*" -size +0c 2>/dev/null) + if [ "`echo $dlocks|wc -w`" -eq $(($SOCKS_PER_PROCESS * 6)) ]; then rm $dlocks elif [ -n "${dlocks}" ]; then echo @@ -17,14 +17,14 @@ for d in /dev/shm /var/run $SOCKETDIR; do fi # Now look for other leftovers - leftovers=$(find $d -name qb-*-test_*${IPC_NAME}* -size +0c 2>/dev/null | wc -l) + leftovers=$(find $d -name "qb-*-test_*${IPC_NAME}*" -size +0c 2>/dev/null | wc -l) if [ "${leftovers}" -gt 0 ]; then echo echo "Error: shared memory segments not closed/unlinked" echo RETURN=1 fi - leftovers="$(find $d -name qb-*-test_*${IPC_NAME}* -size 0c 2>/dev/null)" + leftovers="$(find $d -name "qb-*-test_*${IPC_NAME}*" -size 0c 2>/dev/null)" if [ "$(printf '%s\n' "${leftovers}" | wc -l)" -eq $(($SOCKS_PER_PROCESS * 2)) ]; then echo echo "There were some empty leftovers (expected), removing them" diff --git a/tests/start.test b/tests/start.test index 91c0223f1..2440860f6 100755 --- a/tests/start.test +++ b/tests/start.test @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Generate a unique(ish) name for the IPCs we will use in the tests and From b32667418a8a3becffd424dcd3c97b9223049ddc Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Wed, 12 Jan 2022 11:21:52 +0000 Subject: [PATCH 2/6] Revert start.test part as bash is not installed on *BSD and echo -n works anyway --- tests/start.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/start.test b/tests/start.test index 2440860f6..91c0223f1 100755 --- a/tests/start.test +++ b/tests/start.test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Generate a unique(ish) name for the IPCs we will use in the tests and From 867c66abab5fa0d2cad6192e86c0bd50c7dd7b07 Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Wed, 12 Jan 2022 12:44:28 +0000 Subject: [PATCH 3/6] Use printf - OF COURSE it should use printf --- tests/start.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/start.test b/tests/start.test index 91c0223f1..1ddc963d0 100755 --- a/tests/start.test +++ b/tests/start.test @@ -6,6 +6,6 @@ # which sockets are our and which we can ignore. # The test programs all add "qb-test--" to the front of this. # -NAME="$$-`date +%N`" -echo -n "$NAME" > ipc-test-name + +printf "$$-$RANDOM" > ipc-test-name mkdir -p $SOCKETDIR From eb60ad22a63731e187641dcaf1806d4dbb3a4383 Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Wed, 12 Jan 2022 16:19:40 +0000 Subject: [PATCH 4/6] Revert the DATE call (with change) because $RANDOM is a bashism I changed %N to %s as BSD's date command doesn't support %N. Seconds + PID should be enough .... --- tests/start.test | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/start.test b/tests/start.test index 1ddc963d0..91d1734f0 100755 --- a/tests/start.test +++ b/tests/start.test @@ -7,5 +7,7 @@ # The test programs all add "qb-test--" to the front of this. # -printf "$$-$RANDOM" > ipc-test-name +NAME="$$-`date +%s`" + +printf "$NAME" > ipc-test-name mkdir -p $SOCKETDIR From 880c7b789696acbf3cf033d2e24b0d2c86ab4509 Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Fri, 14 Jan 2022 11:13:07 +0000 Subject: [PATCH 5/6] Shrink the name of the dlock tests as they cause random failures When the PID numbers get big, the socket name overflows the allowed limit --- tests/check_ipc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/check_ipc.c b/tests/check_ipc.c index 6090354ad..1883b85c5 100644 --- a/tests/check_ipc.c +++ b/tests/check_ipc.c @@ -1778,7 +1778,7 @@ READY_SIGNALLER(connected_signaller, _) request_server_exit(); } -START_TEST(test_ipc_dispatch_us_native_prio_dlock) +START_TEST(test_ipc_us_native_prio_dlock) { pid_t server_pid, alphaclient_pid; struct dispatch_data data; @@ -1817,7 +1817,7 @@ START_TEST(test_ipc_dispatch_us_native_prio_dlock) END_TEST #if HAVE_GLIB -START_TEST(test_ipc_dispatch_us_glib_prio_dlock) +START_TEST(test_ipc_us_glib_prio_dlock) { pid_t server_pid, alphaclient_pid; struct dispatch_data data; @@ -2407,9 +2407,9 @@ make_soc_suite(void) add_tcase(s, tc, test_ipc_disconnect_after_created_us, 9); add_tcase(s, tc, test_ipc_service_ref_count_us, 9); add_tcase(s, tc, test_ipc_stress_connections_us, 3600 /* ? */); - add_tcase(s, tc, test_ipc_dispatch_us_native_prio_dlock, 15); + add_tcase(s, tc, test_ipc_us_native_prio_dlock, 15); #if HAVE_GLIB - add_tcase(s, tc, test_ipc_dispatch_us_glib_prio_dlock, 15); + add_tcase(s, tc, test_ipc_us_glib_prio_dlock, 15); #endif return s; From 3ddb2801329d6d469f855a455dd48c525d12b2dc Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Mon, 17 Jan 2022 08:36:53 +0000 Subject: [PATCH 6/6] Increase timeout of thread check. It's been seen to time out too early and fail the tests --- tests/check_loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/check_loop.c b/tests/check_loop.c index ff54d786f..4f9fe27dc 100644 --- a/tests/check_loop.c +++ b/tests/check_loop.c @@ -445,7 +445,7 @@ static void *loop_timer_thread(void *arg) qb_loop_t *l = (qb_loop_t *)arg; qb_loop_timer_handle test_tht; - res = qb_loop_timer_add(l, QB_LOOP_LOW, 5*QB_TIME_NS_IN_MSEC, l, one_shot_tmo, &test_tht); + res = qb_loop_timer_add(l, QB_LOOP_LOW, 10*QB_TIME_NS_IN_MSEC, l, one_shot_tmo, &test_tht); ck_assert_int_eq(res, 0); res = qb_loop_timer_is_running(l, test_tht);