fate-run.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. #! /bin/sh
  2. export LC_ALL=C
  3. base=$(dirname $0)
  4. . "${base}/md5.sh"
  5. base64=tests/base64${HOSTEXECSUF}
  6. test="${1#fate-}"
  7. target_samples=$2
  8. target_exec=$3
  9. target_path=$4
  10. command=$5
  11. cmp=${6:-diff}
  12. ref=${7:-"${base}/ref/fate/${test}"}
  13. fuzz=${8:-1}
  14. threads=${9:-1}
  15. thread_type=${10:-frame+slice}
  16. cpuflags=${11:-all}
  17. cmp_shift=${12:-0}
  18. cmp_target=${13:-0}
  19. size_tolerance=${14:-0}
  20. cmp_unit=${15:-2}
  21. gen=${16:-no}
  22. hwaccel=${17:-none}
  23. report_type=${18:-standard}
  24. keep=${19:-0}
  25. outdir="tests/data/fate"
  26. outfile="${outdir}/${test}"
  27. errfile="${outdir}/${test}.err"
  28. cmpfile="${outdir}/${test}.diff"
  29. repfile="${outdir}/${test}.rep"
  30. target_path(){
  31. test ${1} = ${1#/} && p=${target_path}/
  32. echo ${p}${1}
  33. }
  34. # $1=value1, $2=value2, $3=threshold
  35. # prints 0 if absolute difference between value1 and value2 is <= threshold
  36. compare(){
  37. awk "BEGIN { v = $1 - $2; printf ((v < 0 ? -v : v) > $3) }"
  38. }
  39. do_tiny_psnr(){
  40. psnr=$(tests/tiny_psnr${HOSTEXECSUF} "$1" "$2" $cmp_unit $cmp_shift 0) || return 1
  41. val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
  42. size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
  43. size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
  44. val_cmp=$(compare $val $cmp_target $fuzz)
  45. size_cmp=$(compare $size1 $size2 $size_tolerance)
  46. if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
  47. echo "$psnr"
  48. if [ "$val_cmp" != 0 ]; then
  49. echo "$3: |$val - $cmp_target| >= $fuzz"
  50. fi
  51. if [ "$size_cmp" != 0 ]; then
  52. echo "size: |$size1 - $size2| >= $size_tolerance"
  53. fi
  54. return 1
  55. fi
  56. }
  57. oneoff(){
  58. do_tiny_psnr "$1" "$2" MAXDIFF
  59. }
  60. stddev(){
  61. do_tiny_psnr "$1" "$2" stddev
  62. }
  63. oneline(){
  64. printf '%s\n' "$1" | diff -u -b - "$2"
  65. }
  66. run(){
  67. test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
  68. $target_exec $target_path/"$@"
  69. }
  70. runecho(){
  71. test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
  72. $target_exec $target_path/"$@" >&3
  73. }
  74. probefmt(){
  75. run ffprobe${PROGSUF}${EXECSUF} -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@"
  76. }
  77. probetags(){
  78. run ffprobe${PROGSUF}${EXECSUF} -show_entries format_tags -v 0 "$@"
  79. }
  80. runlocal(){
  81. test "${V:-0}" -gt 0 && echo ${base}/"$@" ${base} >&3
  82. ${base}/"$@" ${base}
  83. }
  84. probeframes(){
  85. run ffprobe${PROGSUF}${EXECSUF} -show_frames -v 0 "$@"
  86. }
  87. probechapters(){
  88. run ffprobe${PROGSUF}${EXECSUF} -show_chapters -v 0 "$@"
  89. }
  90. probegaplessinfo(){
  91. filename="$1"
  92. shift
  93. run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -show_entries format=start_time,duration:stream=index,start_pts,duration_ts -v 0 "$filename" "$@"
  94. pktfile1="${outdir}/${test}.pkts"
  95. framefile1="${outdir}/${test}.frames"
  96. cleanfiles="$cleanfiles $pktfile1 $framefile1"
  97. run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -of compact -count_packets -show_entries packet=pts,dts,duration,flags:stream=nb_read_packets -v 0 "$filename" "$@" > "$pktfile1"
  98. head -n 8 "$pktfile1"
  99. tail -n 9 "$pktfile1"
  100. run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -of compact -count_frames -show_entries frame=pkt_pts,pkt_dts,best_effort_timestamp,pkt_duration,nb_samples:stream=nb_read_frames -v 0 "$filename" "$@" > "$framefile1"
  101. head -n 8 "$framefile1"
  102. tail -n 9 "$framefile1"
  103. }
  104. ffmpeg(){
  105. dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
  106. ffmpeg_args="-nostdin -nostats -cpuflags $cpuflags"
  107. for arg in $@; do
  108. [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
  109. ffmpeg_args="${ffmpeg_args} ${arg}"
  110. done
  111. run ffmpeg${PROGSUF}${EXECSUF} ${ffmpeg_args}
  112. }
  113. framecrc(){
  114. ffmpeg "$@" -bitexact -f framecrc -
  115. }
  116. ffmetadata(){
  117. ffmpeg "$@" -bitexact -f ffmetadata -
  118. }
  119. framemd5(){
  120. ffmpeg "$@" -bitexact -f framemd5 -
  121. }
  122. crc(){
  123. ffmpeg "$@" -f crc -
  124. }
  125. md5pipe(){
  126. ffmpeg "$@" md5:
  127. }
  128. md5(){
  129. encfile="${outdir}/${test}.out"
  130. cleanfiles="$cleanfiles $encfile"
  131. ffmpeg "$@" $(target_path $encfile)
  132. do_md5sum $encfile | awk '{print $1}'
  133. }
  134. pcm(){
  135. ffmpeg "$@" -vn -f s16le -
  136. }
  137. fmtstdout(){
  138. fmt=$1
  139. shift 1
  140. ffmpeg -bitexact "$@" -f $fmt -
  141. }
  142. enc_dec_pcm(){
  143. out_fmt=$1
  144. dec_fmt=$2
  145. pcm_fmt=$3
  146. src_file=$(target_path $4)
  147. shift 4
  148. encfile="${outdir}/${test}.${out_fmt}"
  149. cleanfiles=$encfile
  150. encfile=$(target_path ${encfile})
  151. ffmpeg -i $src_file "$@" -f $out_fmt -y ${encfile} || return
  152. ffmpeg -bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -fflags +bitexact -f ${dec_fmt} -
  153. }
  154. FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
  155. DEC_OPTS="-threads $threads -idct simple $FLAGS"
  156. ENC_OPTS="-threads 1 -idct simple -dct fastint"
  157. enc_dec(){
  158. src_fmt=$1
  159. srcfile=$2
  160. enc_fmt=$3
  161. enc_opt=$4
  162. dec_fmt=$5
  163. dec_opt=$6
  164. ffprobe_opts=$9
  165. encfile="${outdir}/${test}.${enc_fmt}"
  166. decfile="${outdir}/${test}.out.${dec_fmt}"
  167. cleanfiles="$cleanfiles $decfile"
  168. test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
  169. tsrcfile=$(target_path $srcfile)
  170. tencfile=$(target_path $encfile)
  171. tdecfile=$(target_path $decfile)
  172. ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
  173. -f $enc_fmt -y $tencfile || return
  174. do_md5sum $encfile
  175. echo $(wc -c $encfile)
  176. ffmpeg $8 $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
  177. -f $dec_fmt -y $tdecfile || return
  178. do_md5sum $decfile
  179. tests/tiny_psnr${HOSTEXECSUF} $srcfile $decfile $cmp_unit $cmp_shift
  180. test -z $ffprobe_opts || \
  181. run ffprobe${PROGSUF}${EXECSUF} $ffprobe_opts -v 0 $tencfile || return
  182. }
  183. transcode(){
  184. src_fmt=$1
  185. srcfile=$2
  186. enc_fmt=$3
  187. enc_opt=$4
  188. final_decode=$5
  189. ffprobe_opts=$7
  190. encfile="${outdir}/${test}.${enc_fmt}"
  191. test "$6" = -keep || cleanfiles="$cleanfiles $encfile"
  192. tsrcfile=$(target_path $srcfile)
  193. tencfile=$(target_path $encfile)
  194. ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
  195. -f $enc_fmt -y $tencfile || return
  196. do_md5sum $encfile
  197. echo $(wc -c $encfile)
  198. ffmpeg $DEC_OPTS -i $tencfile $ENC_OPTS $FLAGS $final_decode \
  199. -f framecrc - || return
  200. test -z $ffprobe_opts || \
  201. run ffprobe${PROGSUF}${EXECSUF} $ffprobe_opts -v 0 $tencfile || return
  202. }
  203. stream_remux(){
  204. src_fmt=$1
  205. srcfile=$2
  206. enc_fmt=$3
  207. stream_maps=$4
  208. final_decode=$5
  209. ffprobe_opts=$7
  210. encfile="${outdir}/${test}.${enc_fmt}"
  211. test "$6" = -keep || cleanfiles="$cleanfiles $encfile"
  212. tsrcfile=$(target_path $srcfile)
  213. tencfile=$(target_path $encfile)
  214. ffmpeg -f $src_fmt -i $tsrcfile $stream_maps -codec copy $FLAGS \
  215. -f $enc_fmt -y $tencfile || return
  216. ffmpeg $DEC_OPTS -i $tencfile $ENC_OPTS $FLAGS $final_decode \
  217. -f framecrc - || return
  218. test -z $ffprobe_opts || \
  219. run ffprobe${PROGSUF}${EXECSUF} $ffprobe_opts -v 0 $tencfile || return
  220. }
  221. # FIXME: There is a certain duplication between the avconv-related helper
  222. # functions above and below that should be refactored.
  223. ffmpeg2="$target_exec ${target_path}/ffmpeg${PROGSUF}${EXECSUF}"
  224. raw_src="${target_path}/tests/vsynth1/%02d.pgm"
  225. pcm_src="${target_path}/tests/data/asynth1.sw"
  226. crcfile="tests/data/$test.lavf.crc"
  227. target_crcfile="${target_path}/$crcfile"
  228. [ "${V-0}" -gt 0 ] && echov=echov || echov=:
  229. echov(){
  230. echo "$@" >&3
  231. }
  232. AVCONV_OPTS="-nostdin -nostats -y -cpuflags $cpuflags"
  233. COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
  234. DEC_OPTS="$COMMON_OPTS -threads $threads"
  235. ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
  236. run_avconv(){
  237. $echov $ffmpeg2 $AVCONV_OPTS $*
  238. $ffmpeg2 $AVCONV_OPTS $*
  239. }
  240. do_avconv(){
  241. f="$1"
  242. shift
  243. set -- $* ${target_path}/$f
  244. run_avconv $*
  245. do_md5sum $f
  246. echo $(wc -c $f)
  247. }
  248. do_avconv_crc(){
  249. f="$1"
  250. shift
  251. run_avconv $* -f crc "$target_crcfile"
  252. echo "$f $(cat $crcfile)"
  253. }
  254. lavf_audio(){
  255. t="${test#lavf-}"
  256. outdir="tests/data/lavf"
  257. file=${outdir}/lavf.$t
  258. do_avconv $file $DEC_OPTS $1 -ar 44100 -f s16le -i $pcm_src "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 $2
  259. do_avconv_crc $file $DEC_OPTS $3 -i $target_path/$file
  260. }
  261. lavf_container(){
  262. t="${test#lavf-}"
  263. outdir="tests/data/lavf"
  264. file=${outdir}/lavf.$t
  265. do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le $1 -i $pcm_src "$ENC_OPTS -metadata title=lavftest" -b:a 64k -t 1 -qscale:v 10 $2
  266. test "$3" = "disable_crc" ||
  267. do_avconv_crc $file $DEC_OPTS -i $target_path/$file $3
  268. }
  269. lavf_container_attach() { lavf_container "" "$1 -attach ${raw_src%/*}/00.pgm -metadata:s:t mimetype=image/x-portable-greymap"; }
  270. lavf_container_timecode_nodrop() { lavf_container "" "$1 -timecode 02:56:14:13"; }
  271. lavf_container_timecode_drop() { lavf_container "" "$1 -timecode 02:56:14.13 -r 30000/1001"; }
  272. lavf_container_timecode()
  273. {
  274. lavf_container_timecode_nodrop "$@"
  275. lavf_container_timecode_drop "$@"
  276. lavf_container "" "$1"
  277. }
  278. lavf_container_fate()
  279. {
  280. t="${test#lavf-fate-}"
  281. outdir="tests/data/lavf-fate"
  282. file=${outdir}/lavf.$t
  283. input="${target_samples}/$1"
  284. do_avconv $file $DEC_OPTS $2 -i "$input" "$ENC_OPTS -metadata title=lavftest" -vcodec copy -acodec copy
  285. do_avconv_crc $file $DEC_OPTS -i $target_path/$file $3
  286. }
  287. lavf_image(){
  288. t="${test#lavf-}"
  289. outdir="tests/data/images/$t"
  290. mkdir -p "$outdir"
  291. file=${outdir}/%02d.$t
  292. run_avconv $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src $1 "$ENC_OPTS -metadata title=lavftest" -frames 13 -y -qscale 10 $target_path/$file
  293. do_md5sum ${outdir}/02.$t
  294. do_avconv_crc $file $DEC_OPTS $2 -i $target_path/$file $2
  295. echo $(wc -c ${outdir}/02.$t)
  296. }
  297. lavf_image2pipe(){
  298. t="${test#lavf-}"
  299. t="${t%pipe}"
  300. outdir="tests/data/lavf"
  301. file=${outdir}/${t}pipe.$t
  302. do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src -f image2pipe "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10
  303. do_avconv_crc $file $DEC_OPTS -f image2pipe -i $target_path/$file
  304. }
  305. lavf_video(){
  306. t="${test#lavf-}"
  307. outdir="tests/data/lavf"
  308. file=${outdir}/lavf.$t
  309. do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 $1 $2
  310. do_avconv_crc $file $DEC_OPTS -i $target_path/$file $1
  311. }
  312. refcmp_metadata(){
  313. refcmp=$1
  314. pixfmt=$2
  315. fuzz=${3:-0.001}
  316. ffmpeg $FLAGS $ENC_OPTS \
  317. -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref]${refcmp},metadata=print:file=-" \
  318. -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
  319. }
  320. pixfmt_conversion(){
  321. conversion="${test#pixfmt-}"
  322. outdir="tests/data/pixfmt"
  323. raw_dst="$outdir/$conversion.out.yuv"
  324. file=${outdir}/${conversion}.yuv
  325. run_avconv $DEC_OPTS -r 1 -f image2 -c:v pgmyuv -i $raw_src \
  326. $ENC_OPTS -f rawvideo -t 1 -s 352x288 -pix_fmt $conversion $target_path/$raw_dst
  327. do_avconv $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $conversion -i $target_path/$raw_dst \
  328. $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p
  329. }
  330. video_filter(){
  331. filters=$1
  332. shift
  333. label=${test#filter-}
  334. raw_src="${target_path}/tests/vsynth1/%02d.pgm"
  335. printf '%-20s' $label
  336. ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
  337. $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut md5:
  338. }
  339. pixfmts(){
  340. filter=${test#filter-pixfmts-}
  341. filter=${filter%_*}
  342. filter_args=$1
  343. prefilter_chain=$2
  344. nframes=${3:-1}
  345. showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts${EXECSUF}"
  346. scale_exclude_fmts=${outfile}_scale_exclude_fmts
  347. scale_in_fmts=${outfile}_scale_in_fmts
  348. scale_out_fmts=${outfile}_scale_out_fmts
  349. in_fmts=${outfile}_in_fmts
  350. # exclude pixel formats which are not supported as input
  351. $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
  352. $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
  353. comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts
  354. $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
  355. pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
  356. outertest=$test
  357. for pix_fmt in $pix_fmts; do
  358. test=$pix_fmt
  359. video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes
  360. done
  361. rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
  362. test=$outertest
  363. }
  364. gapless(){
  365. sample=$(target_path $1)
  366. extra_args=$2
  367. decfile1="${outdir}/${test}.out-1"
  368. decfile2="${outdir}/${test}.out-2"
  369. decfile3="${outdir}/${test}.out-3"
  370. cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
  371. # test packet data
  372. ffmpeg $extra_args -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile1)
  373. do_md5sum $decfile1
  374. # test decoded (and cut) data
  375. ffmpeg $extra_args -i "$sample" -bitexact -f wav md5:
  376. # the same as above again, with seeking to the start
  377. ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile2)
  378. do_md5sum $decfile2
  379. ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -f wav md5:
  380. # test packet data, with seeking to a specific position
  381. ffmpeg $extra_args -ss 5 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $(target_path $decfile3)
  382. do_md5sum $decfile3
  383. }
  384. gaplessenc(){
  385. sample=$(target_path $1)
  386. format=$2
  387. codec=$3
  388. file1="${outdir}/${test}.out-1"
  389. cleanfiles="$cleanfiles $file1"
  390. # test data after reencoding
  391. ffmpeg -i "$sample" -bitexact -map 0:a -c:a $codec -f $format -y "$(target_path "$file1")"
  392. probegaplessinfo "$(target_path "$file1")"
  393. }
  394. audio_match(){
  395. sample=$(target_path $1)
  396. trefile=$2
  397. extra_args=$3
  398. decfile="${outdir}/${test}.wav"
  399. cleanfiles="$cleanfiles $decfile"
  400. ffmpeg -i "$sample" -bitexact $extra_args -y $(target_path $decfile)
  401. tests/audiomatch${HOSTEXECSUF} $decfile $trefile
  402. }
  403. concat(){
  404. template=$1
  405. sample=$2
  406. mode=$3
  407. extra_args=$4
  408. concatfile="${outdir}/${test}.ffconcat"
  409. packetfile="${outdir}/${test}.ffprobe"
  410. cleanfiles="$concatfile $packetfile"
  411. awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile
  412. if [ "$mode" = "md5" ]; then
  413. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -v 0 -safe 0 $extra_args $(target_path $concatfile) | tr -d '\r' > $packetfile
  414. do_md5sum $packetfile
  415. else
  416. run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -v 0 -of compact=p=0:nk=1 -safe 0 $extra_args $(target_path $concatfile)
  417. fi
  418. }
  419. venc_data(){
  420. file=$1
  421. stream=$2
  422. frames=$3
  423. run tools/venc_data_dump${EXECSUF} ${file} ${stream} ${frames} ${threads} ${thread_type}
  424. }
  425. null(){
  426. :
  427. }
  428. # Disable globbing: command arguments may contain globbing characters and
  429. # must be kept verbatim
  430. set -f
  431. exec 3>&2
  432. eval $command >"$outfile" 2>$errfile
  433. err=$?
  434. if [ $err -gt 128 ]; then
  435. sig=$(kill -l $err 2>/dev/null)
  436. test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
  437. fi
  438. if test -e "$ref" || test $cmp = "oneline" || test $cmp = "null" || test $cmp = "grep" ; then
  439. case $cmp in
  440. diff) diff -u -b "$ref" "$outfile" >$cmpfile ;;
  441. rawdiff)diff -u "$ref" "$outfile" >$cmpfile ;;
  442. oneoff) oneoff "$ref" "$outfile" >$cmpfile ;;
  443. stddev) stddev "$ref" "$outfile" >$cmpfile ;;
  444. oneline)oneline "$ref" "$outfile" >$cmpfile ;;
  445. grep) grep "$ref" "$errfile" >$cmpfile ;;
  446. null) cat "$outfile" >$cmpfile ;;
  447. esac
  448. cmperr=$?
  449. test $err = 0 && err=$cmperr
  450. if [ "$report_type" = "ignore" ]; then
  451. test $err = 0 || echo "IGNORE\t${test}" && err=0 && unset sig
  452. else
  453. test $err = 0 || cat $cmpfile
  454. fi
  455. else
  456. echo "reference file '$ref' not found"
  457. err=1
  458. fi
  459. if [ $err -eq 0 ] && test $report_type = "standard" ; then
  460. unset cmpo erro
  461. else
  462. cmpo="$($base64 <$cmpfile)"
  463. erro="$($base64 <$errfile)"
  464. fi
  465. echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
  466. if test $err != 0 && test $gen != "no" ; then
  467. echo "GEN $ref"
  468. cp -f "$outfile" "$ref"
  469. err=$?
  470. fi
  471. if test $err = 0; then
  472. if test $keep = 0; then
  473. rm -f $outfile $errfile $cmpfile $cleanfiles
  474. fi
  475. elif test $gen = "no"; then
  476. echo "Test $test failed. Look at $errfile for details."
  477. test "${V:-0}" -gt 0 && cat $errfile
  478. else
  479. echo "Updating reference failed, possibly no output file was generated."
  480. fi
  481. exit $err