3 source $
(dirname $0)/..
/detect-build-env-vars.sh
5 [ -z "$CEPH_ROOT" ] && CEPH_ROOT
=..
7 dir
=$CEPH_ROOT/ceph-object-corpus
15 if [ -x .
/ceph-dencoder
]; then
16 CEPH_DENCODER
=.
/ceph-dencoder
18 CEPH_DENCODER
=ceph-dencoder
21 myversion
=`$CEPH_DENCODER version`
24 debug
() { if [ "$DEBUG" -gt 0 ]; then echo "DEBUG: $*" >&2; fi }
32 tmp1
=`mktemp /tmp/typ-XXXXXXXXX`
33 tmp2
=`mktemp /tmp/typ-XXXXXXXXX`
36 if $CEPH_DENCODER type $type 2>/dev
/null
; then
38 echo " $vdir/objects/$type"
40 # is there a fwd incompat change between $arversion and $version?
44 for iv
in `ls $dir/archive | sort -n`; do
45 if [ "$iv" = "$arversion" ]; then
49 if [ $sawarversion -eq 1 ] && [ -e "$dir/archive/$iv/forward_incompat/$type" ]; then
52 # Check if we'll be ignoring only specified objects, not whole type. If so, remember
53 # all paths for this type into variable. Assuming that this path won't contain any
54 # whitechars (implication of above for loop).
55 if [ -d "$dir/archive/$iv/forward_incompat/$type" ]; then
56 if [ -n "`ls $dir/archive/$iv/forward_incompat/$type/ | sort -n`" ]; then
57 incompat_paths
="$incompat_paths $dir/archive/$iv/forward_incompat/$type"
59 echo "type $type directory empty, ignoring whole type instead of single objects"
64 if [ "$iv" = "$version" ]; then
69 if [ -n "$incompat" ]; then
70 if [ -z "$incompat_paths" ]; then
71 echo "skipping incompat $type version $arversion, changed at $incompat < code $myversion"
74 # If we are ignoring not whole type, but objects that are in $incompat_path,
75 # we don't skip here, just give info.
76 echo "postponed skip one of incompact $type version $arversion, changed at $incompat < code $myversion"
80 for f
in `ls $vdir/objects/$type`; do
83 # Check if processed object $f of $type should be skipped (postponed skip)
84 if [ -n "$incompat_paths" ]; then
85 for i_path
in $incompat_paths; do
86 # Check if $f is a symbolic link and if it's pointing to existing target
87 if [ -L "$i_path/$f" ]; then
88 echo "skipping object $f of type $type"
95 if [ $skip -ne 0 ]; then
99 $CEPH_DENCODER type $type import
$vdir/objects
/$type/$f decode dump_json
> $tmp1 &
101 $CEPH_DENCODER type $type import
$vdir/objects
/$type/$f decode encode decode dump_json
> $tmp2 &
103 #echo "\t$vdir/$type/$f"
104 if ! wait $pid1; then
105 echo "**** failed to decode $vdir/objects/$type/$f ****"
106 failed
=$
(($failed + 1))
110 if ! wait $pid2; then
111 echo "**** failed to decode+encode+decode $vdir/objects/$type/$f ****"
112 failed
=$
(($failed + 1))
117 # nondeterministic classes may dump
118 # nondeterministically. compare the sorted json
119 # output. this is a weaker test, but is better than
121 if ! $CEPH_DENCODER type $type is_deterministic
; then
122 echo " sorting json output for nondeterministic object"
123 for f
in $tmp1 $tmp2; do
124 sort $f |
sed 's/,$//' > $f.new
129 if ! cmp $tmp1 $tmp2; then
130 echo "**** reencode of $vdir/objects/$type/$f resulted in a different dump ****"
132 failed
=$
(($failed + 1))
134 numtests
=$
(($numtests + 1))
137 echo "skipping unrecognized type $type"
140 echo "failed=$failed" > $output_file
141 echo "numtests=$numtests" >> $output_file
146 ## Wait for children to exit and indicate whether all exited with 0 status.
149 debug
"Processes remaining: $*"
152 if kill -0 "$pid" 2>/dev
/null
; then
153 debug
"$pid is still alive."
155 elif wait "$pid"; then
156 debug
"$pid exited with zero exit status."
158 debug
"$pid exited with non-zero exit status."
159 errors
=$
(($errors + 1))
162 [ $# -eq 0 ] && break
163 sleep ${WAITALL_DELAY:-1}
175 # Reading the output of jobs to compute failed & numtests
176 # Tests are run in parallel but sum should be done sequentialy to avoid
177 # races between threads
178 while [ "$running_jobs" -ge 0 ]; do
179 if [ -f $output_file.
$running_jobs ]; then
180 read_failed
=$
(grep "^failed=" $output_file.
$running_jobs | cut
-d "=" -f 2)
181 read_numtests
=$
(grep "^numtests=" $output_file.
$running_jobs | cut
-d "=" -f 2)
182 rm -f $output_file.
$running_jobs
183 failed
=$
(($failed + $read_failed))
184 numtests
=$
(($numtests + $read_numtests))
186 running_jobs
=$
(($running_jobs - 1))
191 # Using $MAX_PARALLEL_JOBS jobs if defined, unless the number of logical
193 if [ `uname` == FreeBSD
]; then
194 NPROC
=`sysctl -n hw.ncpu`
195 max_parallel_jobs
=${MAX_PARALLEL_JOBS:-${NPROC}}
197 max_parallel_jobs
=${MAX_PARALLEL_JOBS:-$(nproc)}
200 output_file
=`mktemp /tmp/typ-XXXXXXXXX`
203 for arversion
in `ls $dir/archive | sort -n`; do
204 vdir="$dir/archive/$arversion"
207 if [ ! -d "$vdir/objects" ]; then
211 for type in `ls $vdir/objects`; do
212 test_object
$type $output_file.
$running_jobs &
214 running_jobs
=$
(($running_jobs + 1))
216 # Once we spawned enough jobs, let's wait them to complete
217 # Every spawned job have almost the same execution time so
218 # it's not a big deal having them not ending at the same time
219 if [ "$running_jobs" -eq "$max_parallel_jobs" ]; then
227 if [ $failed -gt 0 ]; then
228 echo "FAILED $failed / $numtests tests."
231 echo "passed $numtests tests."