run-all 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. unset LANG LANGUAGE
  3. unset LC_COLLATE
  4. unset LC_CTYPE
  5. unset LC_MONETARY
  6. unset LC_MESSAGES
  7. unset LC_NUMERIC
  8. unset LC_TIME
  9. unset LC_ALL
  10. test -x hush || {
  11. echo "No ./hush - creating a link to ../../busybox"
  12. ln -s ../../busybox hush
  13. }
  14. PATH="$PWD:$PATH" # for hush and recho/zecho/printenv
  15. export PATH
  16. THIS_SH="$PWD/hush"
  17. export THIS_SH
  18. do_test()
  19. {
  20. test -d "$1" || return 0
  21. # echo Running tests in directory "$1"
  22. (
  23. cd "$1" || { echo "cannot cd $1!"; exit 1; }
  24. for x in run-*; do
  25. test -f "$x" || continue
  26. case "$x" in
  27. "$0"|run-minimal|run-gprof) ;;
  28. *.orig|*~) ;;
  29. #*) echo $x ; sh $x ;;
  30. *)
  31. sh "$x" >"../$1-$x.fail" 2>&1 && \
  32. { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
  33. ;;
  34. esac
  35. done
  36. # Many bash run-XXX scripts just do this,
  37. # no point in duplication it all over the place
  38. for x in *.tests; do
  39. test -x "$x" || continue
  40. name="${x%%.tests}"
  41. test -f "$name.right" || continue
  42. # echo Running test: "$name.right"
  43. {
  44. "$THIS_SH" "./$x" >"$name.xx" 2>&1
  45. diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
  46. } && echo "$1/$x: ok" || echo "$1/$x: fail"
  47. done
  48. )
  49. }
  50. # Main part of this script
  51. # Usage: run-all [directories]
  52. if [ $# -lt 1 ]; then
  53. # All sub directories
  54. modules=`ls -d hush-*`
  55. for module in $modules; do
  56. do_test $module
  57. done
  58. else
  59. while [ $# -ge 1 ]; do
  60. if [ -d $1 ]; then
  61. do_test $1
  62. fi
  63. shift
  64. done
  65. fi