run-all 2.2 KB

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