Tests: Fix problems with "run_all --fast" on OpenBSD

This commit is contained in:
Wilhelm Schuermann 2015-05-06 22:06:11 +02:00
parent 5fee3ef27c
commit accd51bc35

View file

@ -6,7 +6,7 @@ export TASKD_USE_PATH=1
runlog_cleanup() {
if [ -f "_run_all_parallel.txt" ]; then
rm _run_all_parallel.txt
rm _run_all_parallel.txt
fi
if [ -f "_run_all_serial.txt" ]; then
rm _run_all_serial.txt
@ -20,6 +20,29 @@ runlog_cleanup() {
done
}
get_numprocs() {
numprocs=""
# Most Linux systems and OSX have getconf and _NPROCESSORS_ONLN.
if command -v getconf >/dev/null 2>&1; then
numprocs=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
fi
# OpenBSD doesn't know _NPROCESSORS_ONLN, but it does have hw.ncpu
if [ "$numprocs" = "" ] && command -v sysctl >/dev/null 2>&1; then
numprocs=$(sysctl -n hw.ncpu 2>/dev/null)
fi
# If we still haven't found the number of CPU cores available, give up.
if [ "$numprocs" = "" ] || [ "$numprocs" -lt 1 ]; then
echo "Couldn't find number of CPU cores for parallelization. Assuming 2." 1>&2
numprocs=2
else
numprocs=$((numprocs+1))
fi
echo $numprocs
}
rc=0
if [ x"$1" = x"--verbose" ];
@ -57,10 +80,12 @@ elif [ "$1" = "--fast" ]; then
# Clean up after aborted runs
runlog_cleanup
numprocs=$(get_numprocs)
for i in ${TESTBLOB}; do
if [ -x "$i" ]; then
# Only Python tests are guaranteed to run isolated.
if head -c 21 "$i" | grep -q '#!/usr/bin/env python'; then
if head -n 1 "$i" | grep -q '/usr/bin/env python'; then
echo $i >> _run_all_parallel.txt
else
echo $i >> _run_all_serial.txt
@ -79,13 +104,6 @@ elif [ "$1" = "--fast" ]; then
fi
done < _run_all_serial.txt
if command -v getconf >/dev/null 2>&1; then
numprocs=$(getconf _NPROCESSORS_ONLN)
numprocs=$((numprocs+1))
else
numprocs=2
fi
cat _run_all_parallel.txt | xargs -n 1 -P $numprocs sh -c 'echo "#" $0 > $0.runlog; $0 >> $0.runlog 2>&1'
if [ $? -ne 0 ]; then
rc=1