3
0

run-all 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 hush; then
  12. if test ! -x ../../busybox; then
  13. echo "Can't run tests. Put hush binary into this directory (`pwd`)"
  14. exit 1
  15. fi
  16. echo "No ./hush - creating a link to ../../busybox"
  17. ln -s ../../busybox hush
  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. PATH="`pwd`:$PATH" # for hush
  28. export PATH
  29. THIS_SH="`pwd`/hush"
  30. export THIS_SH
  31. do_test()
  32. {
  33. test -d "$1" || return 0
  34. d=${d%/}
  35. # echo Running tests in directory "$1"
  36. # $1 but with / replaced by # so that it can be used as filename part
  37. noslash=`echo "$1" | sed 's:/:#:g'`
  38. (
  39. tret=0
  40. cd "$1" || { echo "cannot cd $1!"; exit 1; }
  41. for x in run-*; do
  42. test -f "$x" || continue
  43. case "$x" in
  44. "$0"|run-minimal|run-gprof) ;;
  45. *.orig|*~) ;;
  46. #*) echo $x ; sh $x ;;
  47. *)
  48. echo -n "$1/$x:"
  49. sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
  50. { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; }
  51. ;;
  52. esac
  53. done
  54. # Many bash run-XXX scripts just do this,
  55. # no point in duplication it all over the place
  56. for x in *.tests; do
  57. test -x "$x" || continue
  58. name="${x%%.tests}"
  59. test -f "$name.right" || continue
  60. # echo Running test: "$x"
  61. echo -n "$1/$x:"
  62. (
  63. "$THIS_SH" "./$x" 2>&1 | \
  64. grep -va "^hush: using fallback suid method$" >"$name.xx"
  65. r=$?
  66. # filter C library differences
  67. sed -i \
  68. -e "/: invalid option /s:'::g" \
  69. "$name.xx"
  70. test $r -eq 77 && rm -f "$TOPDIR/$noslash-$x.fail" && exit 77
  71. diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
  72. && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
  73. )
  74. case $? in
  75. 0) echo " ok";;
  76. 77) echo " skip (feature disabled)";;
  77. *) echo " fail ($?)"; tret=1;;
  78. esac
  79. done
  80. exit $tret
  81. )
  82. }
  83. # Main part of this script
  84. # Usage: run-all [directories]
  85. ret=0
  86. if [ $# -lt 1 ]; then
  87. # All sub directories
  88. modules=`ls -d hush-*`
  89. # If you want to test hush against ash testsuite
  90. # (have to copy ash_test dir to current dir first):
  91. #modules=`ls -d hush-* ash_test/ash-*`
  92. for module in $modules; do
  93. do_test $module || ret=1
  94. done
  95. else
  96. while [ $# -ge 1 ]; do
  97. if [ -d $1 ]; then
  98. do_test $1 || ret=1
  99. fi
  100. shift
  101. done
  102. fi
  103. exit $ret