run-all 2.3 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. TOPDIR=`pwd`
  11. if test ! -x ash; then
  12. if test ! -x ../../busybox; then
  13. echo "Can't run tests. Put ash binary into this directory (`pwd`)"
  14. exit 1
  15. fi
  16. echo "No ./ash - creating a link to ../../busybox"
  17. ln -s ../../busybox ash
  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. test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
  28. test -x recho || gcc -O2 -o recho recho.c || exit $?
  29. test -x zecho || gcc -O2 -o zecho zecho.c || exit $?
  30. PATH="`pwd`:$PATH" # for ash and recho/zecho/printenv
  31. export PATH
  32. THIS_SH="`pwd`/ash"
  33. export THIS_SH
  34. do_test()
  35. {
  36. test -d "$1" || return 0
  37. d=${d%/}
  38. # echo Running tests in directory "$1"
  39. # $1 but with / replaced by # so that it can be used as filename part
  40. noslash=`echo "$1" | sed 's:/:#:g'`
  41. (
  42. cd "$1" || { echo "cannot cd $1!"; exit 1; }
  43. for x in run-*; do
  44. test -f "$x" || continue
  45. case "$x" in
  46. "$0"|run-minimal|run-gprof) ;;
  47. *.orig|*~) ;;
  48. #*) echo $x ; sh $x ;;
  49. *)
  50. echo -n "$1/$x:"
  51. sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
  52. { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; }
  53. ;;
  54. esac
  55. done
  56. # Many bash run-XXX scripts just do this,
  57. # no point in duplication it all over the place
  58. for x in *.tests; do
  59. test -x "$x" || continue
  60. name="${x%%.tests}"
  61. test -f "$name.right" || continue
  62. # echo Running test: "$x"
  63. echo -n "$1/$x:"
  64. {
  65. "$THIS_SH" "./$x" 2>&1 | \
  66. grep -va "^ash: using fallback suid method$" >"$name.xx"
  67. diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
  68. && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
  69. } && echo " ok" || echo " fail"
  70. done
  71. )
  72. }
  73. # Main part of this script
  74. # Usage: run-all [directories]
  75. ret=0
  76. if [ $# -lt 1 ]; then
  77. # All sub directories
  78. modules=`ls -d ash-*`
  79. # If you want to test ash against hush testsuite
  80. # (have to copy hush_test dir to current dir first):
  81. #modules=`ls -d ash-* hush_test/hush-*`
  82. for module in $modules; do
  83. do_test $module || ret=1
  84. done
  85. else
  86. while [ $# -ge 1 ]; do
  87. if [ -d $1 ]; then
  88. do_test $1 || ret=1
  89. fi
  90. shift
  91. done
  92. fi
  93. exit ${ret}