You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

565 lines
17KB

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