From: Sage Weil Date: Mon, 27 Feb 2017 21:10:34 +0000 (-0500) Subject: test/encoding/readable.sh: join children at finish X-Git-Tag: v12.0.1~187^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c8a349eb4603be295a6f0e1683105cb93bfcd066;p=ceph-ci.git test/encoding/readable.sh: join children at finish Signed-off-by: Sage Weil --- diff --git a/src/test/encoding/readable.sh b/src/test/encoding/readable.sh index 0e1e06b9185..ee0bd26223e 100755 --- a/src/test/encoding/readable.sh +++ b/src/test/encoding/readable.sh @@ -169,6 +169,25 @@ waitall() { # PID... # MAIN ###### +do_join() { + waitall $pids + pids="" + # Reading the output of jobs to compute failed & numtests + # Tests are run in parallel but sum should be done sequentialy to avoid + # races between threads + while [ "$running_jobs" -ge 0 ]; do + if [ -f $output_file.$running_jobs ]; then + read_failed=$(grep "^failed=" $output_file.$running_jobs | cut -d "=" -f 2) + read_numtests=$(grep "^numtests=" $output_file.$running_jobs | cut -d "=" -f 2) + rm -f $output_file.$running_jobs + failed=$(($failed + $read_failed)) + numtests=$(($numtests + $read_numtests)) + fi + running_jobs=$(($running_jobs - 1)) + done + running_jobs=0 +} + # Using $MAX_PARALLEL_JOBS jobs if defined, unless the number of logical # processors if [ `uname` == FreeBSD ]; then @@ -178,6 +197,9 @@ else max_parallel_jobs=${MAX_PARALLEL_JOBS:-$(nproc)} fi +output_file=`mktemp /tmp/typ-XXXXXXXXX` +running_jobs=0 + for arversion in `ls $dir/archive | sort -n`; do vdir="$dir/archive/$arversion" #echo $vdir @@ -186,8 +208,6 @@ for arversion in `ls $dir/archive | sort -n`; do continue; fi - output_file=`mktemp /tmp/typ-XXXXXXXXX` - running_jobs=0 for type in `ls $vdir/objects`; do test_object $type $output_file.$running_jobs & pids="$pids $!" @@ -197,26 +217,13 @@ for arversion in `ls $dir/archive | sort -n`; do # Every spawned job have almost the same execution time so # it's not a big deal having them not ending at the same time if [ "$running_jobs" -eq "$max_parallel_jobs" ]; then - waitall $pids - pids="" - # Reading the output of jobs to compute failed & numtests - # Tests are run in parallel but sum should be done sequentialy to avoid - # races between threads - while [ "$running_jobs" -ge 0 ]; do - if [ -f $output_file.$running_jobs ]; then - read_failed=$(grep "^failed=" $output_file.$running_jobs | cut -d "=" -f 2) - read_numtests=$(grep "^numtests=" $output_file.$running_jobs | cut -d "=" -f 2) - rm -f $output_file.$running_jobs - failed=$(($failed + $read_failed)) - numtests=$(($numtests + $read_numtests)) - fi - running_jobs=$(($running_jobs - 1)) - done - running_jobs=0 + do_join fi done done +do_join + if [ $failed -gt 0 ]; then echo "FAILED $failed / $numtests tests." exit 1