Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/encoding: fix readable.sh bugs; fix ceph-object-corpus #13678

Merged
merged 3 commits into from Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 27 additions & 20 deletions src/test/encoding/readable.sh
Expand Up @@ -132,13 +132,13 @@ test_object() {
failed=$(($failed + 1))
fi
numtests=$(($numtests + 1))
echo "failed=$failed" > $output_file
echo "numtests=$numtests" >> $output_file
done
else
echo "skipping unrecognized type $type"
fi

echo "failed=$failed" > $output_file
echo "numtests=$numtests" >> $output_file
rm -f $tmp1 $tmp2
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 $!"
Expand All @@ -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
Expand Down