# 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
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
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 $!"
# 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