Skip to content

Commit

Permalink
Tidy some scripts (#454)
Browse files Browse the repository at this point in the history
* Tidy some scripts

Errors reported by Centos covscan

I changed %N to %s as BSD's date command doesn't support %N.
Seconds + PID should be enough ....

* 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

* Increase timeout of thread check.

It's been seen to time out too early and fail the tests
  • Loading branch information
chrissie-c authored Jan 19, 2022
1 parent 176eae8 commit 73472e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions tests/check_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/check_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/resources.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions tests/start.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# which sockets are our and which we can ignore.
# The test programs all add "qb-test-<name>-" to the front of this.
#
NAME="$$-`date +%N`"
echo -n "$NAME" > ipc-test-name

NAME="$$-`date +%s`"

printf "$NAME" > ipc-test-name
mkdir -p $SOCKETDIR

0 comments on commit 73472e0

Please sign in to comment.