Skip to content

Commit

Permalink
Check for the right number of leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissie-c committed Jan 13, 2022
1 parent bca3a15 commit 4d32ad0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/resources.test
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#!/bin/sh
RETURN=0
SOCKS_PER_PROCESS=3
EXPECTED_DLOCK=6
EXPECTED_LEFTOVER=2

# Linux also runs filesystem socket tests
if [ "`uname -s`" = "Linux" ]
then
EXPECTED_DLOCK=12
EXPECTED_LEFTOVER=4
fi

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
if [ `echo $dlocks|wc -w` -eq $(($SOCKS_PER_PROCESS * $EXPECTED_DLOCK)) ]; then
rm $dlocks
elif [ -n "${dlocks}" ]; then
echo
Expand All @@ -25,7 +34,7 @@ for d in /dev/shm /var/run $SOCKETDIR; do
RETURN=1
fi
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
if [ "$(printf '%s\n' "${leftovers}" | wc -l)" -eq $(($SOCKS_PER_PROCESS * $EXPECTED_LEFTOVER)) ]; then
echo
echo "There were some empty leftovers (expected), removing them"
echo "${leftovers}" | tee /dev/stderr | xargs rm
Expand Down

0 comments on commit 4d32ad0

Please sign in to comment.