summaryrefslogtreecommitdiffstats
path: root/tests/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.sh')
-rwxr-xr-xtests/run.sh41
1 files changed, 28 insertions, 13 deletions
diff --git a/tests/run.sh b/tests/run.sh
index 8a7924ae1..a20da4785 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -22,6 +22,7 @@ OPTS=
top_srcdir=
top_builddir=
+paraller_jobs=1
while [ -n "$1" ]; do
case "$1" in
@@ -49,6 +50,14 @@ while [ -n "$1" ]; do
--builddir=*)
top_builddir="${1##--builddir=}"
;;
+ --parallel=*)
+ paraller_jobs="${1##--parallel=}"
+ OPTS="$OPTS --parallel"
+ ;;
+ --parallel)
+ paraller_jobs=$(lscpu -bp | grep -cv '^#')
+ OPTS="$OPTS --parallel"
+ ;;
--*)
echo "Unknown option $1"
echo "Usage: "
@@ -61,6 +70,7 @@ while [ -n "$1" ]; do
echo " --nonroot ignore test suite if user is root"
echo " --srcdir=<path> autotools top source directory"
echo " --builddir=<path> autotools top build directory"
+ echo " --parallel=<num> number of parallel test jobs, default: num cpus"
echo
exit 1
;;
@@ -87,12 +97,12 @@ fi
OPTS="$OPTS --srcdir=$top_srcdir --builddir=$top_builddir"
+declare -a comps
if [ -n "$SUBTESTS" ]; then
# selected tests only
for s in $SUBTESTS; do
if [ -d "$top_srcdir/tests/ts/$s" ]; then
- co=$(find $top_srcdir/tests/ts/$s -type f -perm /a+x -regex ".*/[^\.~]*" | sort)
- comps="$comps $co"
+ comps+=( $(find $top_srcdir/tests/ts/$s -type f -perm /a+x -regex ".*/[^\.~]*") )
else
echo "Unknown test component '$s'"
exit 1
@@ -104,7 +114,7 @@ else
exit 1
fi
- comps=$(find $top_srcdir/tests/ts/ -type f -perm /a+x -regex ".*/[^\.~]*" | sort)
+ comps=( $(find $top_srcdir/tests/ts/ -type f -perm /a+x -regex ".*/[^\.~]*") )
fi
@@ -119,21 +129,26 @@ echo " For development purpose only. "
echo " Don't execute on production system! "
echo
-res=0
-count=0
-for ts in $comps; do
- $ts "$OPTS"
- res=$(( $res + $? ))
- count=$(( $count + 1 ))
-done
+if [ $paraller_jobs -gt 1 ]; then
+ echo " Executing the tests in parallel ($paraller_jobs jobs) "
+ echo
+fi
+count=0
+>| $top_srcdir/tests/failures
+printf "%s\n" ${comps[*]} |
+ xargs -I '{}' -P $paraller_jobs -n 1 bash -c "'{}' \"$OPTS\" ||
+ echo 1 >> $top_srcdir/tests/failures"
+declare -a fail_file
+fail_file=( $( < $top_srcdir/tests/failures ) )
+rm -f $top_srcdir/tests/failures
echo
echo "---------------------------------------------------------------------"
-if [ $res -eq 0 ]; then
- echo " All $count tests PASSED"
+if [ ${#fail_file[@]} -eq 0 ]; then
+ echo " All ${#comps[@]} tests PASSED"
res=0
else
- echo " $res tests of $count FAILED"
+ echo " ${#fail_file[@]} tests of ${#comps[@]} FAILED"
res=1
fi
echo "---------------------------------------------------------------------"