]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/encoding/readable.sh: join children at finish
authorSage Weil <sage@redhat.com>
Mon, 27 Feb 2017 21:10:34 +0000 (16:10 -0500)
committerSage Weil <sage@redhat.com>
Mon, 27 Feb 2017 21:27:14 +0000 (16:27 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/test/encoding/readable.sh

index 0e1e06b918572edbeff6123ace2fa3b1417127cb..ee0bd26223e2d5d16729bb1ac625d0e21a7a3222 100755 (executable)
@@ -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