uclibcng-testrunner.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. #-
  3. # Copyright (c) 2015
  4. # Thorsten "mirabilos" Glaser <tg@mirbsd.org>
  5. #
  6. # Provided that these terms and disclaimer and all copyright notices
  7. # are retained or reproduced in an accompanying document, permission
  8. # is granted to deal in this work without restriction, including un-
  9. # limited rights to use, publicly perform, distribute, sell, modify,
  10. # merge, give away, or sublicence.
  11. #
  12. # This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
  13. # the utmost extent permitted by applicable law, neither express nor
  14. # implied; without malicious intent or gross negligence. In no event
  15. # may a licensor, author or contributor be held liable for indirect,
  16. # direct, other damage, loss, or other issues arising in any way out
  17. # of dealing in the work, even if advised of the possibility of such
  18. # damage or existence of a defect, except proven that it results out
  19. # of said person's immediate fault when using the work as intended.
  20. #-
  21. # Testsuite runner
  22. die() {
  23. echo >&2 E: "$*"
  24. exit 1
  25. }
  26. test -s uclibcng-testrunner.in || die uclibcng-testrunner.in not found
  27. nfail=0
  28. npass=0
  29. while read expected_ret tst_src_name binary_name subdir cmd; do
  30. printf '.... %s\r' "$binary_name"
  31. (cd $subdir && eval "$cmd" >$binary_name.out 2>&1) </dev/null
  32. ret=$?
  33. test $ret = "$expected_ret" || {
  34. echo "FAIL $binary_name got $ret expected $expected_ret"
  35. nfail=`expr $nfail + 1`
  36. sed 's/^/ /' <$subdir/$binary_name.out
  37. continue
  38. }
  39. for x in $binary_name.out $test_src_name.out -; do
  40. if test x"$x" = x"-"; then
  41. echo "PASS $binary_name"
  42. npass=`expr $npass + 1`
  43. break
  44. fi
  45. test -e "$subdir/$x.good" || continue
  46. if d=`diff -u "$subdir/$binary_name.out" "$subdir/$x.good"`; then
  47. echo "PASS $binary_name"
  48. npass=`expr $npass + 1`
  49. else
  50. echo "FAIL $binary_name expected output differs"
  51. nfail=`expr $nfail + 1`
  52. echo "$d" | sed 's/^/ /'
  53. fi
  54. break
  55. done
  56. done <uclibcng-testrunner.in
  57. echo Total failed: $nfail
  58. echo Total passed: $npass
  59. test $nfail = 0