diff --git a/tests/ipc_sock.test b/tests/ipc_sock.test index 5806c50..0f77111 100755 --- a/tests/ipc_sock.test +++ b/tests/ipc_sock.test @@ -1,21 +1,21 @@ #!/bin/sh # # Run the IPC tests under the stat wrapper, # this simulates /etc/libqb/use-filesystem-sockets existing # so we can test both options without breaking other things # that might be running on this system. # # This creates sockets in /var/run so needs to be root # -if [ "$(uname -s)" = "Linux" -a "$UID" = "0" ] +if [ "$(uname -s)" = "Linux" ] && [ "`id -u`" = "0" ] then if [ -f "$(pwd)/.libs/libstat_wrapper.so" ] then export "LD_PRELOAD=$(pwd)/.libs/libstat_wrapper.so" else export "LD_PRELOAD=$(pwd)/libstat_wrapper.so" fi ./ipc.test else exit 0 fi diff --git a/tests/resources.test b/tests/resources.test index 5398d15..e18a837 100755 --- a/tests/resources.test +++ b/tests/resources.test @@ -1,70 +1,70 @@ #!/bin/sh RETURN=0 SOCKS_PER_PROCESS=3 EXPECTED_DLOCK=6 EXPECTED_LEFTOVER=2 # Linux also runs filesystem socket tests -if [ "$(uname -s)" = "Linux" -a "$UID" = "0" ] +if [ "$(uname -s)" = "Linux" ] && [ "`id -u`" = "0" ] then EXPECTED_DLOCK=12 EXPECTED_LEFTOVER=4 fi tidy_qb_dirs() { for dd in "$@"; do rm $dd rmdir $(dirname $dd) 2> /dev/null done } 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 * $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)" 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}" echo tidy_qb_dirs $leftovers elif [ -n "${leftovers}" ]; then echo echo "Error: unexpected number of empty leftovers" echo "${leftovers}" echo RETURN=1 fi 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