run-all 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. echo -n "$1/$x: "
  30. sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
  31. { echo "ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo "fail";
  32. ;;
  33. esac
  34. done
  35. # Many bash run-XXX scripts just do this,
  36. # no point in duplication it all over the place
  37. for x in *.tests; do
  38. test -x "$x" || continue
  39. name="${x%%.tests}"
  40. test -f "$name.right" || continue
  41. echo -n "$1/$x: "
  42. {
  43. "$THIS_SH" "./$x" >"$name.xx" 2>&1
  44. diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
  45. && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
  46. } && echo "ok" || echo "fail"
  47. done
  48. )
  49. }
  50. # main part of this script
  51. # Usage: run-all [directories]
  52. if [ $# -lt 1 ]; then
  53. # All sub directories
  54. modules=`ls -d ash-*`
  55. # If you want to test ash against hush and msh testsuites
  56. # (have to copy hush_test and msh_test dirs to current dir first):
  57. #modules=`ls -d ash-* hush_test/hush-* msh_test/msh-*`
  58. for module in $modules; do
  59. do_test $module
  60. done
  61. else
  62. while [ $# -ge 1 ]; do
  63. if [ -d $1 ]; then
  64. do_test $1
  65. fi
  66. shift
  67. done
  68. fi