fate-run.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #! /bin/sh
  2. export LC_ALL=C
  3. base=$(dirname $0)
  4. . "${base}/md5.sh"
  5. base64=tests/base64
  6. test="${1#fate-}"
  7. 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
  14. threads=${9:-1}
  15. thread_type=${10:-3}
  16. outdir="tests/data/fate"
  17. outfile="${outdir}/${test}"
  18. errfile="${outdir}/${test}.err"
  19. cmpfile="${outdir}/${test}.diff"
  20. repfile="${outdir}/${test}.rep"
  21. do_tiny_psnr(){
  22. psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0)
  23. val=$(expr "$psnr" : ".*$3: *\([0-9.]*\)")
  24. size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)')
  25. size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)')
  26. res=$(echo "if ($val $4 $5) 1" | bc)
  27. if [ "$res" != 1 ] || [ $size1 != $size2 ]; then
  28. echo "$psnr"
  29. return 1
  30. fi
  31. }
  32. oneoff(){
  33. do_tiny_psnr "$1" "$2" MAXDIFF '<=' ${fuzz:-1}
  34. }
  35. stddev(){
  36. do_tiny_psnr "$1" "$2" stddev '<=' ${fuzz:-1}
  37. }
  38. run(){
  39. test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
  40. $target_exec $target_path/"$@"
  41. }
  42. ffmpeg(){
  43. run ffmpeg -v 0 -threads $threads -thread_type $thread_type "$@"
  44. }
  45. framecrc(){
  46. ffmpeg "$@" -f framecrc -
  47. }
  48. framemd5(){
  49. ffmpeg "$@" -f framemd5 -
  50. }
  51. crc(){
  52. ffmpeg "$@" -f crc -
  53. }
  54. md5(){
  55. ffmpeg "$@" md5:
  56. }
  57. pcm(){
  58. ffmpeg "$@" -vn -f s16le -
  59. }
  60. regtest(){
  61. t="${test#$2-}"
  62. ref=${base}/ref/$2/$t
  63. ${base}/${1}-regression.sh $t $2 $3 "$target_exec" "$target_path" "$threads" "$thread_type"
  64. }
  65. codectest(){
  66. regtest codec $1 tests/$1
  67. }
  68. lavftest(){
  69. regtest lavf lavf tests/vsynth1
  70. }
  71. lavfitest(){
  72. cleanfiles="tests/data/lavfi/${test#lavfi-}.nut"
  73. regtest lavfi lavfi tests/vsynth1
  74. }
  75. seektest(){
  76. t="${test#seek-}"
  77. ref=${base}/ref/seek/$t
  78. case $t in
  79. image_*) file="tests/data/images/${t#image_}/%02d.${t#image_}" ;;
  80. *) file=$(echo $t | tr _ '?')
  81. for d in acodec vsynth2 lavf; do
  82. test -f tests/data/$d/$file && break
  83. done
  84. file=$(echo tests/data/$d/$file)
  85. ;;
  86. esac
  87. $target_exec $target_path/libavformat/seek-test $target_path/$file
  88. }
  89. mkdir -p "$outdir"
  90. exec 3>&2
  91. $command > "$outfile" 2>$errfile
  92. err=$?
  93. if [ $err -gt 128 ]; then
  94. sig=$(kill -l $err 2>/dev/null)
  95. test "${sig}" = "${sig%[!A-Za-z]*}" || unset sig
  96. fi
  97. if test -e "$ref"; then
  98. case $cmp in
  99. diff) diff -u -w "$ref" "$outfile" >$cmpfile ;;
  100. oneoff) oneoff "$ref" "$outfile" "$fuzz" >$cmpfile ;;
  101. stddev) stddev "$ref" "$outfile" "$fuzz" >$cmpfile ;;
  102. null) cat "$outfile" >$cmpfile ;;
  103. esac
  104. cmperr=$?
  105. test $err = 0 && err=$cmperr
  106. test $err = 0 || cat $cmpfile
  107. else
  108. echo "reference file '$ref' not found"
  109. err=1
  110. fi
  111. echo "${test}:${sig:-$err}:$($base64 <$cmpfile):$($base64 <$errfile)" >$repfile
  112. test $err = 0 && rm -f $outfile $errfile $cmpfile $cleanfiles
  113. exit $err