run-all 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. r=$?
  62. # filter C library differences
  63. sed -i \
  64. -e "/: invalid option /s:'::g" \
  65. "$name.xx"
  66. test $r -eq 77 && rm -f "../$1-$x.fail" && exit 77
  67. diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
  68. )
  69. case $? in
  70. 0) echo " ok";;
  71. 77) echo " skip (feature disabled)";;
  72. *) echo " fail"; tret=1;;
  73. esac
  74. done
  75. exit ${tret}
  76. )
  77. }
  78. # Main part of this script
  79. # Usage: run-all [directories]
  80. ret=0
  81. if [ $# -lt 1 ]; then
  82. # All sub directories
  83. modules=`ls -d hush-*`
  84. for module in $modules; do
  85. do_test $module || ret=1
  86. done
  87. else
  88. while [ $# -ge 1 ]; do
  89. if [ -d $1 ]; then
  90. do_test $1 || ret=1
  91. fi
  92. shift
  93. done
  94. fi
  95. exit ${ret}