fate-run.sh 15.8 KB
Newer Older
Måns Rullgård's avatar
Måns Rullgård committed
1 2
#! /bin/sh

3 4
export LC_ALL=C

Måns Rullgård's avatar
Måns Rullgård committed
5 6 7
base=$(dirname $0)
. "${base}/md5.sh"

8
base64=tests/base64${HOSTEXECSUF}
9

Måns Rullgård's avatar
Måns Rullgård committed
10
test="${1#fate-}"
11
target_samples=$2
Måns Rullgård's avatar
Måns Rullgård committed
12
target_exec=$3
13
target_path=$4
Måns Rullgård's avatar
Måns Rullgård committed
14
command=$5
15 16
cmp=${6:-diff}
ref=${7:-"${base}/ref/fate/${test}"}
17
fuzz=${8:-1}
18
threads=${9:-1}
19
thread_type=${10:-frame+slice}
20
cpuflags=${11:-all}
21
cmp_shift=${12:-0}
22
cmp_target=${13:-0}
23
size_tolerance=${14:-0}
24
cmp_unit=${15:-2}
25
gen=${16:-no}
26
hwaccel=${17:-none}
27
report_type=${18:-standard}
28
keep=${19:-0}
29

Måns Rullgård's avatar
Måns Rullgård committed
30 31
outdir="tests/data/fate"
outfile="${outdir}/${test}"
32
errfile="${outdir}/${test}.err"
33 34
cmpfile="${outdir}/${test}.diff"
repfile="${outdir}/${test}.rep"
Måns Rullgård's avatar
Måns Rullgård committed
35

36 37 38 39 40
target_path(){
    test ${1} = ${1#/} && p=${target_path}/
    echo ${p}${1}
}

41 42 43
# $1=value1, $2=value2, $3=threshold
# prints 0 if absolute difference between value1 and value2 is <= threshold
compare(){
44
    awk "BEGIN { v = $1 - $2; printf ((v < 0 ? -v : v) > $3) }"
45 46
}

47
do_tiny_psnr(){
48
    psnr=$(tests/tiny_psnr${HOSTEXECSUF} "$1" "$2" $cmp_unit $cmp_shift 0) || return 1
49
    val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
50 51
    size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
    size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
52
    val_cmp=$(compare $val $cmp_target $fuzz)
53 54
    size_cmp=$(compare $size1 $size2 $size_tolerance)
    if [ "$val_cmp" != 0 ] || [ "$size_cmp" != 0 ]; then
55
        echo "$psnr"
56 57 58 59 60 61
        if [ "$val_cmp" != 0 ]; then
            echo "$3: |$val - $cmp_target| >= $fuzz"
        fi
        if [ "$size_cmp" != 0 ]; then
            echo "size: |$size1 - $size2| >= $size_tolerance"
        fi
62 63 64 65
        return 1
    fi
}

66
oneoff(){
67
    do_tiny_psnr "$1" "$2" MAXDIFF
68 69 70
}

stddev(){
71
    do_tiny_psnr "$1" "$2" stddev
72 73
}

74
oneline(){
75
    printf '%s\n' "$1" | diff -u -b - "$2"
76 77
}

78
run(){
79
    test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
80 81 82
    $target_exec $target_path/"$@"
}

83 84 85 86 87
runecho(){
    test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
    $target_exec $target_path/"$@" >&3
}

88
probefmt(){
89
    run ffprobe${PROGSUF}${EXECSUF} -show_entries format=format_name -print_format default=nw=1:nk=1 -v 0 "$@"
Thilo Borgmann's avatar
Thilo Borgmann committed
90 91
}

Richard Shaffer's avatar
Richard Shaffer committed
92
probetags(){
93
    run ffprobe${PROGSUF}${EXECSUF} -show_entries format_tags -v 0 "$@"
Richard Shaffer's avatar
Richard Shaffer committed
94 95
}

96 97 98 99 100
runlocal(){
    test "${V:-0}" -gt 0 && echo ${base}/"$@" ${base} >&3
    ${base}/"$@" ${base}
}

Thilo Borgmann's avatar
Thilo Borgmann committed
101
probeframes(){
102
    run ffprobe${PROGSUF}${EXECSUF} -show_frames -v 0 "$@"
103 104
}

105
probechapters(){
106
    run ffprobe${PROGSUF}${EXECSUF} -show_chapters -v 0 "$@"
107 108
}

109 110 111
probegaplessinfo(){
    filename="$1"
    shift
112
    run ffprobe${PROGSUF}${EXECSUF} -bitexact -select_streams a -show_entries format=start_time,duration:stream=index,start_pts,duration_ts -v 0 "$filename" "$@"
113 114 115
    pktfile1="${outdir}/${test}.pkts"
    framefile1="${outdir}/${test}.frames"
    cleanfiles="$cleanfiles $pktfile1 $framefile1"
116
    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"
117 118
    head -n 8 "$pktfile1"
    tail -n 9 "$pktfile1"
119
    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"
120 121 122 123
    head -n 8 "$framefile1"
    tail -n 9 "$framefile1"
}

124
ffmpeg(){
125
    dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
126
    ffmpeg_args="-nostdin -nostats -cpuflags $cpuflags"
127
    for arg in $@; do
128
        [ x${arg} = x-i ] && ffmpeg_args="${ffmpeg_args} ${dec_opts}"
129
        ffmpeg_args="${ffmpeg_args} ${arg}"
130
    done
131
    run ffmpeg${PROGSUF}${EXECSUF} ${ffmpeg_args}
132 133 134
}

framecrc(){
135
    ffmpeg "$@" -bitexact -f framecrc -
136 137
}

138
ffmetadata(){
139
    ffmpeg "$@" -bitexact -f ffmetadata -
140 141
}

142
framemd5(){
143
    ffmpeg "$@" -bitexact -f framemd5 -
144 145 146
}

crc(){
147
    ffmpeg "$@" -f crc -
148 149
}

150
md5pipe(){
151
    ffmpeg "$@" md5:
152 153
}

154 155 156 157 158 159 160
md5(){
    encfile="${outdir}/${test}.out"
    cleanfiles="$cleanfiles $encfile"
    ffmpeg "$@" $encfile
    do_md5sum $encfile | awk '{print $1}'
}

161
pcm(){
162
    ffmpeg "$@" -vn -f s16le -
163 164
}

165 166 167
fmtstdout(){
    fmt=$1
    shift 1
168
    ffmpeg -bitexact "$@" -f $fmt -
169 170
}

171 172
enc_dec_pcm(){
    out_fmt=$1
173 174 175 176
    dec_fmt=$2
    pcm_fmt=$3
    src_file=$(target_path $4)
    shift 4
177 178
    encfile="${outdir}/${test}.${out_fmt}"
    cleanfiles=$encfile
179
    encfile=$(target_path ${encfile})
180
    ffmpeg -i $src_file "$@" -f $out_fmt -y ${encfile} || return
181
    ffmpeg -bitexact -i ${encfile} -c:a pcm_${pcm_fmt} -fflags +bitexact -f ${dec_fmt} -
182 183
}

184
FLAGS="-flags +bitexact -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
DEC_OPTS="-threads $threads -idct simple $FLAGS"
ENC_OPTS="-threads 1        -idct simple -dct fastint"

enc_dec(){
    src_fmt=$1
    srcfile=$2
    enc_fmt=$3
    enc_opt=$4
    dec_fmt=$5
    dec_opt=$6
    encfile="${outdir}/${test}.${enc_fmt}"
    decfile="${outdir}/${test}.out.${dec_fmt}"
    cleanfiles="$cleanfiles $decfile"
    test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
    tsrcfile=$(target_path $srcfile)
    tencfile=$(target_path $encfile)
    tdecfile=$(target_path $decfile)
202
    ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
203 204 205
        -f $enc_fmt -y $tencfile || return
    do_md5sum $encfile
    echo $(wc -c $encfile)
206
    ffmpeg $8 $DEC_OPTS -i $tencfile $ENC_OPTS $dec_opt $FLAGS \
207 208
        -f $dec_fmt -y $tdecfile || return
    do_md5sum $decfile
209
    tests/tiny_psnr${HOSTEXECSUF} $srcfile $decfile $cmp_unit $cmp_shift
210 211
}

212 213 214 215 216
transcode(){
    src_fmt=$1
    srcfile=$2
    enc_fmt=$3
    enc_opt=$4
217
    final_decode=$5
218 219 220 221 222 223 224 225
    encfile="${outdir}/${test}.${enc_fmt}"
    test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
    tsrcfile=$(target_path $srcfile)
    tencfile=$(target_path $encfile)
    ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $ENC_OPTS $enc_opt $FLAGS \
        -f $enc_fmt -y $tencfile || return
    do_md5sum $encfile
    echo $(wc -c $encfile)
226
    ffmpeg $DEC_OPTS -i $encfile $ENC_OPTS $FLAGS $final_decode \
227
        -f framecrc - || return
228 229
}

230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
stream_remux(){
    src_fmt=$1
    srcfile=$2
    enc_fmt=$3
    stream_maps=$4
    final_decode=$5
    encfile="${outdir}/${test}.${enc_fmt}"
    test "$7" = -keep || cleanfiles="$cleanfiles $encfile"
    tsrcfile=$(target_path $srcfile)
    tencfile=$(target_path $encfile)
    ffmpeg -f $src_fmt -i $tsrcfile $stream_maps -codec copy $FLAGS \
        -f $enc_fmt -y $tencfile || return
    ffmpeg $DEC_OPTS -i $encfile $ENC_OPTS $FLAGS $final_decode \
        -f framecrc - || return
}

246 247
# FIXME: There is a certain duplication between the avconv-related helper
# functions above and below that should be refactored.
248
ffmpeg2="$target_exec ${target_path}/ffmpeg${PROGSUF}${EXECSUF}"
249
raw_src="${target_path}/tests/vsynth1/%02d.pgm"
250
pcm_src="${target_path}/tests/data/asynth1.sw"
251 252 253
crcfile="tests/data/$test.lavf.crc"
target_crcfile="${target_path}/$crcfile"

James Almer's avatar
James Almer committed
254 255
[ "${V-0}" -gt 0 ] && echov=echov || echov=:

256 257 258 259
echov(){
    echo "$@" >&3
}

260 261 262 263
AVCONV_OPTS="-nostdin -nostats -y -cpuflags $cpuflags"
COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact -fflags +bitexact"
DEC_OPTS="$COMMON_OPTS -threads $threads"
ENC_OPTS="$COMMON_OPTS -threads 1 -dct fastint"
264 265

run_avconv(){
James Almer's avatar
James Almer committed
266 267
    $echov $ffmpeg2 $AVCONV_OPTS $*
    $ffmpeg2 $AVCONV_OPTS $*
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
}

do_avconv(){
    f="$1"
    shift
    set -- $* ${target_path}/$f
    run_avconv $*
    do_md5sum $f
    echo $(wc -c $f)
}

do_avconv_crc(){
    f="$1"
    shift
    run_avconv $* -f crc "$target_crcfile"
    echo "$f $(cat $crcfile)"
}

286 287 288 289
lavf_audio(){
    t="${test#lavf-}"
    outdir="tests/data/lavf"
    file=${outdir}/lavf.$t
James Almer's avatar
James Almer committed
290
    do_avconv $file $DEC_OPTS $1 -ar 44100 -f s16le -i $pcm_src "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 $2
291 292 293
    do_avconv_crc $file $DEC_OPTS $3 -i $target_path/$file
}

294 295 296 297
lavf_container(){
    t="${test#lavf-}"
    outdir="tests/data/lavf"
    file=${outdir}/lavf.$t
James Almer's avatar
James Almer committed
298
    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
299
    test "$3" = "disable_crc" ||
300 301 302
        do_avconv_crc $file $DEC_OPTS -i $target_path/$file $3
}

James Almer's avatar
James Almer committed
303 304 305 306 307 308 309 310 311 312 313
lavf_container_attach() {          lavf_container "" "$1 -attach ${raw_src%/*}/00.pgm -metadata:s:t mimetype=image/x-portable-greymap"; }
lavf_container_timecode_nodrop() { lavf_container "" "$1 -timecode 02:56:14:13"; }
lavf_container_timecode_drop()   { lavf_container "" "$1 -timecode 02:56:14.13 -r 30000/1001"; }

lavf_container_timecode()
{
    lavf_container_timecode_nodrop "$@"
    lavf_container_timecode_drop "$@"
    lavf_container "" "$1"
}

314 315 316 317 318 319 320 321 322 323
lavf_container_fate()
{
    t="${test#lavf-fate-}"
    outdir="tests/data/lavf-fate"
    file=${outdir}/lavf.$t
    input="${target_samples}/$1"
    do_avconv $file $DEC_OPTS $2 -i "$input" "$ENC_OPTS -metadata title=lavftest" -vcodec copy -acodec copy
    do_avconv_crc $file $DEC_OPTS -i $target_path/$file $3
}

324 325 326 327 328
lavf_image(){
    t="${test#lavf-}"
    outdir="tests/data/images/$t"
    mkdir -p "$outdir"
    file=${outdir}/%02d.$t
329
    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
330
    do_md5sum ${outdir}/02.$t
331
    do_avconv_crc $file $DEC_OPTS $2 -i $target_path/$file $2
332 333 334
    echo $(wc -c ${outdir}/02.$t)
}

335 336 337 338 339
lavf_image2pipe(){
    t="${test#lavf-}"
    t="${t%pipe}"
    outdir="tests/data/lavf"
    file=${outdir}/${t}pipe.$t
James Almer's avatar
James Almer committed
340
    do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src -f image2pipe "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10
341 342 343
    do_avconv_crc $file $DEC_OPTS -f image2pipe -i $target_path/$file
}

344
lavf_video(){
345
    t="${test#lavf-}"
346 347
    outdir="tests/data/lavf"
    file=${outdir}/lavf.$t
James Almer's avatar
James Almer committed
348
    do_avconv $file $DEC_OPTS -f image2 -c:v pgmyuv -i $raw_src "$ENC_OPTS -metadata title=lavftest" -t 1 -qscale 10 $1 $2
349
    do_avconv_crc $file $DEC_OPTS -i $target_path/$file $1
350 351
}

352 353 354 355 356 357 358 359 360
refcmp_metadata(){
    refcmp=$1
    pixfmt=$2
    fuzz=${3:-0.001}
    ffmpeg $FLAGS $ENC_OPTS \
        -lavfi "testsrc2=size=300x200:rate=1:duration=5,format=${pixfmt},split[ref][tmp];[tmp]avgblur=4[enc];[enc][ref]${refcmp},metadata=print:file=-" \
        -f null /dev/null | awk -v ref=${ref} -v fuzz=${fuzz} -f ${base}/refcmp-metadata.awk -
}

361 362 363 364 365 366 367 368 369 370 371
pixfmt_conversion(){
    conversion="${test#pixfmt-}"
    outdir="tests/data/pixfmt"
    raw_dst="$outdir/$conversion.out.yuv"
    file=${outdir}/${conversion}.yuv
    run_avconv $DEC_OPTS -r 1 -f image2 -c:v pgmyuv -i $raw_src \
               $ENC_OPTS -f rawvideo -t 1 -s 352x288 -pix_fmt $conversion $target_path/$raw_dst
    do_avconv $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $conversion -i $target_path/$raw_dst \
              $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p
}

372 373 374 375 376 377
video_filter(){
    filters=$1
    shift
    label=${test#filter-}
    raw_src="${target_path}/tests/vsynth1/%02d.pgm"
    printf '%-20s' $label
378
    ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src \
379
        $FLAGS $ENC_OPTS -vf "$filters" -vcodec rawvideo -frames:v 5 $* -f nut md5:
380 381
}

382 383
pixfmts(){
    filter=${test#filter-pixfmts-}
384
    filter=${filter%_*}
385
    filter_args=$1
386
    prefilter_chain=$2
387
    nframes=${3:-1}
388

389
    showfiltfmts="$target_exec $target_path/libavfilter/tests/filtfmts${EXECSUF}"
390 391 392 393
    scale_exclude_fmts=${outfile}_scale_exclude_fmts
    scale_in_fmts=${outfile}_scale_in_fmts
    scale_out_fmts=${outfile}_scale_out_fmts
    in_fmts=${outfile}_in_fmts
394 395

    # exclude pixel formats which are not supported as input
396 397 398 399 400 401
    $showfiltfmts scale | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_in_fmts
    $showfiltfmts scale | awk -F '[ \r]' '/^OUTPUT/{ fmt=substr($3, 5); print fmt }' | sort >$scale_out_fmts
    comm -12 $scale_in_fmts $scale_out_fmts >$scale_exclude_fmts

    $showfiltfmts $filter | awk -F '[ \r]' '/^INPUT/{ fmt=substr($3, 5); print fmt }' | sort >$in_fmts
    pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
402

403
    outertest=$test
404 405
    for pix_fmt in $pix_fmts; do
        test=$pix_fmt
406
        video_filter "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt -frames:v $nframes
407 408
    done

409
    rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
410
    test=$outertest
411 412
}

wm4's avatar
wm4 committed
413 414 415 416 417 418
gapless(){
    sample=$(target_path $1)
    extra_args=$2

    decfile1="${outdir}/${test}.out-1"
    decfile2="${outdir}/${test}.out-2"
419 420
    decfile3="${outdir}/${test}.out-3"
    cleanfiles="$cleanfiles $decfile1 $decfile2 $decfile3"
wm4's avatar
wm4 committed
421 422

    # test packet data
423
    ffmpeg $extra_args -i "$sample" -bitexact -c:a copy -f framecrc -y $decfile1
wm4's avatar
wm4 committed
424 425
    do_md5sum $decfile1
    # test decoded (and cut) data
426
    ffmpeg $extra_args -i "$sample" -bitexact -f wav md5:
427
    # the same as above again, with seeking to the start
428
    ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $decfile2
wm4's avatar
wm4 committed
429
    do_md5sum $decfile2
430
    ffmpeg $extra_args -ss 0 -seek_timestamp 1 -i "$sample" -bitexact -f wav md5:
431
    # test packet data, with seeking to a specific position
432
    ffmpeg $extra_args -ss 5 -seek_timestamp 1 -i "$sample" -bitexact -c:a copy -f framecrc -y $decfile3
433
    do_md5sum $decfile3
wm4's avatar
wm4 committed
434 435
}

436 437 438 439 440 441 442 443 444
gaplessenc(){
    sample=$(target_path $1)
    format=$2
    codec=$3

    file1="${outdir}/${test}.out-1"
    cleanfiles="$cleanfiles $file1"

    # test data after reencoding
445
    ffmpeg -i "$sample" -bitexact -map 0:a -c:a $codec -f $format -y "$file1"
446 447 448
    probegaplessinfo "$file1"
}

449 450 451 452 453 454 455 456
audio_match(){
    sample=$(target_path $1)
    trefile=$(target_path $2)
    extra_args=$3

    decfile="${outdir}/${test}.wav"
    cleanfiles="$cleanfiles $decfile"

457
    ffmpeg -i "$sample" -bitexact $extra_args -y $decfile
458
    tests/audiomatch${HOSTEXECSUF} $decfile $trefile
459 460
}

461 462
concat(){
    template=$1
463
    sample=$2
464 465 466 467 468 469 470 471 472 473
    mode=$3
    extra_args=$4

    concatfile="${outdir}/${test}.ffconcat"
    packetfile="${outdir}/${test}.ffprobe"
    cleanfiles="$concatfile $packetfile"

    awk "{gsub(/%SRCFILE%/, \"$sample\"); print}" $template > $concatfile

    if [ "$mode" = "md5" ]; then
474
        run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -v 0 -fflags keepside -safe 0 $extra_args $concatfile | tr -d '\r' > $packetfile
Timothy Gu's avatar
Timothy Gu committed
475
        do_md5sum $packetfile
476
    else
477
        run ffprobe${PROGSUF}${EXECSUF} -bitexact -show_streams -show_packets -v 0 -of compact=p=0:nk=1 -fflags keepside -safe 0 $extra_args $concatfile
478
    fi
479
}
James Almer's avatar
James Almer committed
480

481 482
null(){
    :
483 484
}

485 486 487 488
# Disable globbing: command arguments may contain globbing characters and
# must be kept verbatim
set -f

489
exec 3>&2
490
eval $command >"$outfile" 2>$errfile
491
err=$?
492

493 494
if [ $err -gt 128 ]; then
    sig=$(kill -l $err 2>/dev/null)
495
    test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
496 497
fi

James Almer's avatar
James Almer committed
498
if test -e "$ref" || test $cmp = "oneline" || test $cmp = "null" || test $cmp = "grep" ; then
499
    case $cmp in
500
        diff)   diff -u -b "$ref" "$outfile"            >$cmpfile ;;
501
        rawdiff)diff -u    "$ref" "$outfile"            >$cmpfile ;;
502 503
        oneoff) oneoff     "$ref" "$outfile"            >$cmpfile ;;
        stddev) stddev     "$ref" "$outfile"            >$cmpfile ;;
504
        oneline)oneline    "$ref" "$outfile"            >$cmpfile ;;
505
        grep)   grep       "$ref" "$errfile"            >$cmpfile ;;
506
        null)   cat               "$outfile"            >$cmpfile ;;
507 508 509
    esac
    cmperr=$?
    test $err = 0 && err=$cmperr
510
    if [ "$report_type" = "ignore" ]; then
511
        test $err = 0 || echo "IGNORE\t${test}" && err=0 && unset sig
512 513 514
    else
        test $err = 0 || cat $cmpfile
    fi
515
else
516
    echo "reference file '$ref' not found"
517
    err=1
518 519
fi

520
if [ $err -eq 0 ] && test $report_type = "standard" ; then
521 522 523 524 525 526
    unset cmpo erro
else
    cmpo="$($base64 <$cmpfile)"
    erro="$($base64 <$errfile)"
fi
echo "${test}:${sig:-$err}:$cmpo:$erro" >$repfile
527

528 529 530 531 532 533
if test $err != 0 && test $gen != "no" ; then
    echo "GEN     $ref"
    cp -f "$outfile" "$ref"
    err=$?
fi

534
if test $err = 0; then
535 536 537
    if test $keep = 0; then
        rm -f $outfile $errfile $cmpfile $cleanfiles
    fi
538
elif test $gen = "no"; then
539
    echo "Test $test failed. Look at $errfile for details."
540
    test "${V:-0}" -gt 0 && cat $errfile
541 542
else
    echo "Updating reference failed, possibly no output file was generated."
543
fi
544
exit $err