libqb/tests/resources.test
Chrissie Caulfield a3aedbc419
tests: allow -j to work (#485)
build: fix several issues with building tests

- MAINTAINERCLEANFILES should not rely on conditionals
  that could or could not clean files.

- EXTRA_DIST should not rely on conditonals that could
  or could not add files to the final tarball.
  sources should always ship.

- CLEANFILES should not rely on conditionals as
  ./configure can be done in between builds leaving
  stray files around.

- (cosmetic) move distclean-local: target with clean-local.

- drop old ipc_sock.test, start.test and resources.test
  shell files.

- fix make distcheck -j:
  - stop shipping or not shipping libstat_wrapper.so.
    libtool will only generate the .so when installing
    a shared library (--enable-install-tests).
  - make libstat_wrapper a module in a similar fashion
    of _failure_injection.
  - build ipc_sock.test in a similar fashion as ipc.test
    and link as module _libstat_wrapper.la.
    this solves multiple issues of having the binary
    in the final test builddir, no need to detect if
    libstat_wrapper.so is installed or not and workaround
    libtool different linking methods for inst vs noinst
    libraries.

- fix ipc.test linking with GLIB that should not be
  dependent on HAVE_FAILURE_INJECTION.

Run tests in parallel with dependancies
Make sure the two IPC tests use different socket names
Shortedn some names so they fit with the new ipc-names
remove ipc-test-name-sock
Fix resources.test now that ipc_sock is being run properly

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2023-05-26 20:21:43 +02:00

92 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
RETURN=0
SOCKS_PER_PROCESS=3
EXPECTED_DLOCK=6
EXPECTED_LEFTOVER=2
tidy_qb_dirs()
{
for dd in "$@"; do
rm $dd
rmdir $(dirname $dd) 2> /dev/null
done
}
tidy_dlock_sockets()
{
IPC_NAME=$1
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 * $EXPECTED_DLOCK)) ]; then
tidy_qb_dirs $dlocks
rm $dlocks
elif [ -n "${dlocks}" ]; then
echo
echo "Error: dlock shared memory segments not closed/unlinked"
echo
RETURN=1
fi
# Now look for other expected 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)"
expected=$(($SOCKS_PER_PROCESS * $EXPECTED_LEFTOVER))
if [ "$(printf '%s\n' "${leftovers}" | wc -l)" -eq "$expected" ]; then
echo
echo "There were some empty leftovers (expected), removing them"
echo "${leftovers}"
echo
tidy_qb_dirs $leftovers
elif [ -n "${leftovers}" ]; then
echo
echo "Error: unexpected number of empty leftovers. expected ${expected}"
echo "${leftovers}"
echo
RETURN=1
fi
done
return $RETURN
}
IPC_NAME=$(cat ipc-test-name 2>/dev/null)
tidy_dlock_sockets $IPC_NAME
RETURN=$?
# Linux also runs filesystem socket tests
if [ "$(uname -s)" = "Linux" ] && [ "`id -u`" = "0" ]
then
IPC_NAME=$(cat ipc-test-name-sock 2>/dev/null)
tidy_dlock_sockets $IPC_NAME
if [ $? -ne 0 ]
then
RETURN=$?
fi
fi
# Clean up empty /dev/shm directories left over by some tests
DIRS=$(grep "Free'ing ringbuffer" ipc.log sock_ipc_wrapper.log| cut -f4 -d ' '|cut -f-4 -d'/'|sort|uniq)
for i in $DIRS
do
rmdir $i 2>/dev/null
done
ps aux | grep -v grep | grep -E 'lt-.*\.test'
if [ $? -eq 0 ]; then
echo "test program frozen"
RETURN=1
fi
# Keep it tidy - distcheck checks we have not left a mess
rm -f ipc-test-name*
rm -f crash_test_dummy.core
exit $RETURN