run-all 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. if test ! -x hush; then
  11. if test ! -x ../../busybox; then
  12. echo "Can't run tests. Put hush binary into this directory (`pwd`)"
  13. exit 1
  14. fi
  15. echo "No ./hush - creating a link to ../../busybox"
  16. ln -s ../../busybox hush
  17. fi
  18. if test ! -f .config; then
  19. if test ! -f ../../.config; then
  20. echo "Missing .config file"
  21. exit 1
  22. fi
  23. cp ../../.config . || exit 1
  24. fi
  25. eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
  26. PATH="`pwd`:$PATH" # for hush and recho/zecho/printenv
  27. export PATH
  28. THIS_SH="`pwd`/hush"
  29. export THIS_SH
  30. do_test()
  31. {
  32. test -d "$1" || return 0
  33. d=${d%/}
  34. # echo Running tests in directory "$1"
  35. (
  36. tret=0
  37. cd "$1" || { echo "cannot cd $1!"; exit 1; }
  38. for x in run-*; do
  39. test -f "$x" || continue
  40. case "$x" in
  41. "$0"|run-minimal|run-gprof) ;;
  42. *.orig|*~) ;;
  43. #*) echo $x ; sh $x ;;
  44. *)
  45. sh "$x" >"../$1-$x.fail" 2>&1 && \
  46. { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
  47. ;;
  48. esac
  49. done
  50. # Many bash run-XXX scripts just do this,
  51. # no point in duplication it all over the place
  52. for x in *.tests; do
  53. test -x "$x" || continue
  54. name="${x%%.tests}"
  55. test -f "$name.right" || continue
  56. # echo Running test: "$x"
  57. (
  58. "$THIS_SH" "./$x" >"$name.xx" 2>&1
  59. # filter C library differences
  60. sed -i \
  61. -e "/: invalid option /s:'::g" \
  62. "$name.xx"
  63. test $? -eq 77 && rm -f "../$1-$x.fail" && exit 77
  64. diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
  65. )
  66. case $? in
  67. 0) echo "$1/$x: ok";;
  68. 77) echo "$1/$x: skip (feature disabled)";;
  69. *) echo "$1/$x: fail"; tret=1;;
  70. esac
  71. done
  72. exit ${tret}
  73. )
  74. }
  75. # Main part of this script
  76. # Usage: run-all [directories]
  77. ret=0
  78. if [ $# -lt 1 ]; then
  79. # All sub directories
  80. modules=`ls -d hush-*`
  81. for module in $modules; do
  82. do_test $module || ret=1
  83. done
  84. else
  85. while [ $# -ge 1 ]; do
  86. if [ -d $1 ]; then
  87. do_test $1 || ret=1
  88. fi
  89. shift
  90. done
  91. fi
  92. exit ${ret}