verify.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. rm -rf gen || exit 1
  3. mkdir -p gen || exit 1
  4. summary=""
  5. while [ "$#" -gt 0 ]
  6. do
  7. bin="$1"
  8. shift
  9. echo "# ${bin} #"
  10. mkdir -p "gen/$(dirname ${bin})" || exit 1
  11. "${bin}" test args > "gen/${bin}.stdout" 2> "gen/${bin}.stderr"
  12. retcode="$?"
  13. status=""
  14. for output in stdout stderr
  15. do
  16. gen="$(sha256sum "gen/${bin}.${output}" | cut -d " " -f 1)"
  17. # look for expected output file that is specific to binary type (either static or dynamic)
  18. expected_file="expected/${bin}.${output}"
  19. if [ ! -e $expected_file ]
  20. then
  21. # if unable to find above, the expected output file is the same to both static and dynamic binary
  22. name=$(echo $bin | cut -d "/" -f2-)
  23. expected_file="expected/${name}.${output}"
  24. fi
  25. expected="$(sha256sum "${expected_file}" | cut -d " " -f 1)"
  26. if [ "${gen}" != "${expected}" ]
  27. then
  28. echo "# ${bin}: ${output}: expected #"
  29. cat "${expected_file}"
  30. echo "# ${bin}: ${output}: generated #"
  31. cat "gen/${bin}.${output}"
  32. # FIXME: Make diff available on Redox
  33. if [ $(uname) != "Redox" ]
  34. then
  35. echo "# ${bin}: ${output}: diff #"
  36. diff --color -u "${expected_file}" "gen/${bin}.${output}"
  37. fi
  38. status="${bin} failed - retcode ${retcode}, ${output} mismatch"
  39. summary="${summary}${status}\n"
  40. fi
  41. done
  42. if [ -n "${status}" ]
  43. then
  44. echo "# ${status} #"
  45. fi
  46. done
  47. if [ -n "$summary" ]
  48. then
  49. echo -e "$summary"
  50. exit 1
  51. fi