run-all 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. echo -n "$1/$x:"
  46. sh "$x" >"../$1-$x.fail" 2>&1 && \
  47. { { echo " ok"; rm "../$1-$x.fail"; } || echo " fail"; }
  48. ;;
  49. esac
  50. done
  51. # Many bash run-XXX scripts just do this,
  52. # no point in duplication it all over the place
  53. for x in *.tests; do
  54. test -x "$x" || continue
  55. name="${x%%.tests}"
  56. test -f "$name.right" || continue
  57. # echo Running test: "$x"
  58. echo -n "$1/$x:"
  59. (
  60. "$THIS_SH" "./$x" >"$name.xx" 2>&1
  61. # filter C library differences
  62. sed -i \
  63. -e "/: invalid option /s:'::g" \
  64. "$name.xx"
  65. test $? -eq 77 && rm -f "../$1-$x.fail" && exit 77
  66. diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
  67. )
  68. case $? in
  69. 0) echo " ok";;
  70. 77) echo " skip (feature disabled)";;
  71. *) echo " fail"; tret=1;;
  72. esac
  73. done
  74. exit ${tret}
  75. )
  76. }
  77. # Main part of this script
  78. # Usage: run-all [directories]
  79. ret=0
  80. if [ $# -lt 1 ]; then
  81. # All sub directories
  82. modules=`ls -d hush-*`
  83. for module in $modules; do
  84. do_test $module || ret=1
  85. done
  86. else
  87. while [ $# -ge 1 ]; do
  88. if [ -d $1 ]; then
  89. do_test $1 || ret=1
  90. fi
  91. shift
  92. done
  93. fi
  94. exit ${ret}