run-all 1.8 KB

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