Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Fix up resources.test #435

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions tests/resources.test
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
#!/bin/sh
RETURN=0
SOCKS_PER_PROCESS=3

IPC_NAME=`cat ipc-test-name 2>/dev/null`
for d in /dev/shm /var/run $SOCKETDIR; do
leftovers=$(find $d -name qb-test*${IPC_NAME}* -size +0c 2>/dev/null | wc -l)

# 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
rm $dlocks
elif [ -n "${dlocks}" ]; then
echo
echo "Error: dlock shared memory segments not closed/unlinked"
echo
RETURN=1
fi

# Now look for other leftovers
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)"
if [ "$(printf '%s\n' "${leftovers}" | wc -l)" -eq 6 ]; then
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"
echo "${leftovers}" | tee /dev/stderr | xargs rm
Expand Down