runtest 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/sh
  2. [ -n "$srcdir" ] || srcdir=$(pwd)
  3. [ -n "$bindir" ] || bindir=$(dirname $(pwd))
  4. PATH=$bindir:$PATH
  5. run_applet_testcase ()
  6. {
  7. local applet=$1
  8. local testcase=$2
  9. local status=0
  10. local RES=
  11. local uc_applet=$(echo $applet | tr a-z A-Z)
  12. local testname=$(basename $testcase)
  13. if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then
  14. echo UNTESTED: $testname
  15. return 0
  16. fi
  17. if grep -q "^# FEATURE: " $testcase; then
  18. local feature=`sed -ne 's/^# FEATURE: //p' $testcase`
  19. if grep -q "^# ${feature} is not set$" $bindir/.config; then
  20. echo UNTESTED: $testname
  21. return 0
  22. fi
  23. fi
  24. rm -rf tmp
  25. mkdir -p tmp
  26. pushd tmp >/dev/null
  27. d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1
  28. if [ $? != 0 ] ; then
  29. echo FAIL: $testname
  30. if [ "$verbose" = 1 ]; then
  31. cat .logfile.txt
  32. #exit 1;
  33. fi;
  34. status=$?
  35. else
  36. echo PASS: $testname
  37. rm -f .logfile.txt
  38. status=$?
  39. fi
  40. popd >/dev/null
  41. rm -rf tmp
  42. return $status
  43. }
  44. run_applet_tests ()
  45. {
  46. local applet=$1
  47. local status=0
  48. for testcase in $srcdir/$applet/*; do
  49. if [ "$testcase" = "$srcdir/$applet/CVS" ]; then
  50. continue
  51. fi
  52. if run_applet_testcase $applet $testcase; then
  53. :
  54. else
  55. status=1
  56. fi
  57. done
  58. return $status
  59. }
  60. status=0
  61. if [ x"$1" = x"-v" ]; then
  62. verbose=1
  63. shift
  64. fi
  65. if [ $# -ne 0 ]; then
  66. applets="$@"
  67. else
  68. applets=$(ls $srcdir)
  69. fi
  70. for applet in $applets; do
  71. if [ "$applet" != CVS -a -d "$srcdir/$applet" ]; then
  72. if run_applet_tests $applet; then
  73. :
  74. else
  75. status=1
  76. fi
  77. fi
  78. done
  79. exit $status