run-all 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. tret=0
  43. cd "$1" || { echo "cannot cd $1!"; exit 1; }
  44. for x in run-*; do
  45. test -f "$x" || continue
  46. case "$x" in
  47. "$0"|run-minimal|run-gprof) ;;
  48. *.orig|*~) ;;
  49. #*) echo $x ; sh $x ;;
  50. *)
  51. echo -n "$1/$x:"
  52. sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
  53. { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; }
  54. ;;
  55. esac
  56. done
  57. # Many bash run-XXX scripts just do this,
  58. # no point in duplication it all over the place
  59. for x in *.tests; do
  60. test -x "$x" || continue
  61. name="${x%%.tests}"
  62. test -f "$name.right" || continue
  63. # echo Running test: "$x"
  64. echo -n "$1/$x:"
  65. (
  66. "$THIS_SH" "./$x" 2>&1 | \
  67. grep -va "^ash: using fallback suid method$" >"$name.xx"
  68. r=$?
  69. # filter C library differences
  70. sed -i \
  71. -e "/: invalid option /s:'::g" \
  72. "$name.xx"
  73. test $r -eq 77 && rm -f "$TOPDIR/$noslash-$x.fail" && exit 77
  74. diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
  75. && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
  76. )
  77. case $? in
  78. 0) echo " ok";;
  79. 77) echo " skip (feature disabled)";;
  80. *) echo " fail ($?)"; tret=1;;
  81. esac
  82. done
  83. exit $tret
  84. )
  85. }
  86. # Main part of this script
  87. # Usage: run-all [directories]
  88. ret=0
  89. if [ $# -lt 1 ]; then
  90. # All sub directories
  91. modules=`ls -d ash-*`
  92. # If you want to test ash against hush testsuite
  93. # (have to copy hush_test dir to current dir first):
  94. #modules=`ls -d ash-* hush_test/hush-*`
  95. for module in $modules; do
  96. do_test $module || ret=1
  97. done
  98. else
  99. while [ $# -ge 1 ]; do
  100. if [ -d $1 ]; then
  101. do_test $1 || ret=1
  102. fi
  103. shift
  104. done
  105. fi
  106. exit $ret