summaryrefslogtreecommitdiffstats
path: root/tests/run.sh
diff options
context:
space:
mode:
authorSami Kerola2014-02-17 00:54:15 +0100
committerKarel Zak2014-02-17 15:01:02 +0100
commit40e6f7a06355cba0305e987ca6536b212e0718cf (patch)
tree641cc4f0cafd1abb18d54be86389495111372fca /tests/run.sh
parenttests: fdisk now prints SGI system partitions too (diff)
downloadkernel-qcow2-util-linux-40e6f7a06355cba0305e987ca6536b212e0718cf.tar.gz
kernel-qcow2-util-linux-40e6f7a06355cba0305e987ca6536b212e0718cf.tar.xz
kernel-qcow2-util-linux-40e6f7a06355cba0305e987ca6536b212e0718cf.zip
tests: make tests to run parallel
Unarguably this change makes test output to be more messy, but when I compare run time tells with clear numbers parallel is quicker. For me the quickness is important factor. Running test suite always after a change is preferrably quick, and if something is indicated to be broken it is ok to spend time in drilling down what happen. $ time ./tests/run.sh --parallel=5 [...] real 1m48.037s Same without parallelization. $ time ./tests/run.sh real 3m16.687s The default is changed to be parallel, where job count is same as number of CPUs. [kzak@redhat.com: - propagate --parallel into function.sh - don't use extra title for non-parallel execution - disable by default] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
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 "---------------------------------------------------------------------"