3
0

runtest 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/bin/sh
  2. [ -n "$srcdir" ] || srcdir=$(pwd)
  3. [ -n "$bindir" ] || bindir=$(dirname $(pwd))
  4. PATH=$bindir:$PATH
  5. # Run old-style test.
  6. function run_applet_testcase
  7. {
  8. local applet=$1
  9. local testcase=$2
  10. local status=0
  11. local RES=
  12. local uc_applet=$(echo $applet | tr a-z A-Z)
  13. local testname=$(basename $testcase)
  14. if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then
  15. echo UNTESTED: $testname
  16. return 0
  17. fi
  18. if grep -q "^# FEATURE: " $testcase; then
  19. local feature=`sed -ne 's/^# FEATURE: //p' $testcase`
  20. if grep -q "^# ${feature} is not set$" $bindir/.config; then
  21. echo UNTESTED: $testname
  22. return 0
  23. fi
  24. fi
  25. rm -rf tmp
  26. mkdir -p tmp
  27. pushd tmp >/dev/null
  28. d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1
  29. if [ $? != 0 ] ; then
  30. echo FAIL: $testname
  31. if [ $verbose -gt 0 ]; then
  32. cat .logfile.txt
  33. #exit 1;
  34. fi;
  35. status=$?
  36. else
  37. echo PASS: $testname
  38. rm -f .logfile.txt
  39. status=$?
  40. fi
  41. popd >/dev/null
  42. rm -rf tmp
  43. return $status
  44. }
  45. run_applet_tests ()
  46. {
  47. local applet=$1
  48. local status=0
  49. for testcase in $srcdir/$applet/*; do
  50. if [ "$testcase" = "$srcdir/$applet/CVS" ]; then
  51. continue
  52. fi
  53. if run_applet_testcase $applet $testcase; then
  54. :
  55. else
  56. status=1
  57. fi
  58. done
  59. return $status
  60. }
  61. status=0
  62. verbose=0
  63. if [ x"$1" = x"-v" ]; then
  64. verbose=1
  65. export VERBOSE=$verbose
  66. shift
  67. fi
  68. if [ $# -ne 0 ]; then
  69. applets=$(cd $srcdir ; for i in $@; do ls ${i}* ; done)
  70. else
  71. applets=$(ls $srcdir)
  72. fi
  73. # Populate a directory with links to all busybox applets
  74. LINKSDIR="${bindir}/runtest-tempdir-links"
  75. rm -rf "$LINKSDIR" 2>/dev/null
  76. mkdir "$LINKSDIR"
  77. for i in $(sed 's@/[a-z0-9/\[]*/@@' $bindir/busybox.links)
  78. do
  79. ln -s $bindir/busybox "$LINKSDIR"/$i
  80. done
  81. # Set up option flags so tests can be selective.
  82. configfile=${bindir:-../../}/.config
  83. export OPTIONFLAGS=:$(echo $(sed -nr 's/^CONFIG_(.*)=.*/\1/p' $configfile) | sed 's/ /:/g')
  84. for applet in $applets; do
  85. if [ "$applet" = "links" ]; then continue; fi
  86. if [ "$applet" != "CVS" -a -d "$srcdir/$applet" ]; then
  87. if run_applet_tests $applet; then
  88. :
  89. else
  90. status=1
  91. fi
  92. fi
  93. # Is this a new-style test?
  94. applet=$(echo "$applet" | sed -n 's/\.tests$//p')
  95. if [ ${#applet} -ne 0 ]
  96. then
  97. if [ ! -h "$LINKSDIR/$applet" ]
  98. then
  99. echo "SKIPPED: $applet (not built)"
  100. continue
  101. fi
  102. PATH="$LINKSDIR":$srcdir:$bindir:$PATH \
  103. "${srcdir:-.}/$applet".tests
  104. if [ $? -ne 0 ]; then status=1; fi
  105. fi
  106. done
  107. rm -rf "$LINKSDIR"
  108. exit $status