run-all 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. test -x ash || {
  3. echo "No ./ash?! Perhaps you want to run 'ln -s ../../busybox ash'"
  4. exit
  5. }
  6. test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
  7. test -x recho || gcc -O2 -o recho recho.c || exit $?
  8. test -x zecho || gcc -O2 -o zecho zecho.c || exit $?
  9. PATH="$PWD:$PATH" # for ash and recho/zecho/printenv
  10. export PATH
  11. THIS_SH="$PWD/ash"
  12. export THIS_SH
  13. do_test()
  14. {
  15. test -d "$1" || return 0
  16. echo do_test "$1"
  17. (
  18. cd "$1" || { echo "cannot cd $1!"; exit 1; }
  19. for x in run-*; do
  20. test -f "$x" || continue
  21. case "$x" in
  22. "$0"|run-minimal|run-gprof) ;;
  23. *.orig|*~) ;;
  24. #*) echo $x ; sh $x ;;
  25. *)
  26. sh "$x" >"../$1-$x.fail" 2>&1 && \
  27. { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
  28. ;;
  29. esac
  30. done
  31. # Many bash run-XXX scripts just do this,
  32. # no point in duplication it all over the place
  33. for x in *.tests; do
  34. test -x "$x" || continue
  35. name="${x%%.tests}"
  36. test -f "$name.right" || continue
  37. {
  38. "$THIS_SH" "./$x" >"$name.xx" 2>&1
  39. diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
  40. } && echo "$1/$x: ok" || echo "$1/$x: fail"
  41. done
  42. )
  43. }
  44. # main part of this script
  45. # Usage: run-all [directories]
  46. if [ $# -lt 1 ]; then
  47. # All sub directories
  48. modules=`ls -d ash-*`
  49. for module in $modules; do
  50. do_test $module
  51. done
  52. else
  53. while [ $# -ge 1 ]; do
  54. if [ -d $1 ]; then
  55. do_test $1
  56. fi
  57. shift
  58. done
  59. fi