3
0

run-all 2.1 KB

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