3 # Are we running as root?
10 PATH
=:/bin
:/usr
/bin
:/sbin
13 rm -rf DIR
* # remove any old junk lying around
14 passed
=`expr 0` # count number of tests run correctly
15 failed
=`expr 0` # count number of tests that failed
16 skipped
=`expr 0` # count number of tests that were skipped
17 total
=`expr 0` # total number of tests tried
18 badones
= # list of tests that failed
19 export USENETWORK
# set to "yes" for test48+82 to use the network
21 # In the lists below, shell scripts should be listed without ".sh" suffix
23 # Programs that require setuid
24 setuids
="test11 test33 test43 test44 test46 test56 test60 test61 test65 \
25 test69 test73 test74 test78 test83 test85 test87 test88 test89 \
27 # Scripts that require to be run as root
28 rootscripts
="testisofs testvnd testrmib testrelpol"
30 alltests
="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
31 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
32 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
33 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
34 81 82 83 84 85 86 87 88 89 90 91 92 93 94 \
35 sh1 sh2 interp mfs isofs vnd rmib"
38 # If root, make sure the setuid tests have the correct permissions
39 # and make the dir bin-owned.
41 then /usr
/sbin
/chown bin .
42 /usr
/sbin
/chown root
${setuids}
48 # Are we given any args? If so, we might have to give
49 # or change our testlist
50 while getopts 'lt:T' opt
61 ?
) echo "Usage: run [-l] [-t testlist] [-T]" >&2
62 echo " -l: list tests, exit" >&2
63 echo " -t: execute given set of tests, default: all" >&2
64 echo " -T: produce TAP-format output" >&2
70 for i
in `echo $tests`; do
71 if [ -x .
/test$i -o -x .
/test${i}.sh
]; then
72 tests_no
=`expr $tests_no + 1`
76 if [ $tests_no -eq 0 ]
78 echo "No test binaries found. did you compile?"
82 # Print tests list whenever user asks for TAP mode. It is up
83 # to the caller to make sure it makes sense, i.e. he knows what it
86 then echo "1..$tests_no"
89 if [ "$tests" = "$alltests" ]
90 then # Print test welcome message
91 if [ ! "$tapmode" ]; then clear; fi
92 echo -n "${diagprefix}Running POSIX compliance test suite. "
93 echo "There are $tests_no tests in total."
97 # Provide an argument for test63
103 # setuid doesn't work with scripts, so we can only run those as root
104 if echo "$rootscripts" |
tr ' ' '\n' |
grep "^test${i}\$" >/dev
/null
108 # depending on where we are, scripts might have a .sh suffix or not
109 if [ -x test${i}.sh
]
110 then NAME
=.
/test${i}.sh
115 if [ $needroot -eq 1 ]
116 then $NAME $ARG ||
return 1
117 else su bin
-c "$NAME $ARG" ||
return 1
120 if [ $needroot -eq 1 ]
121 then echo "skipping test$i, not root." >&2 && return 0
122 else $NAME $ARG ||
return 1
128 # Run all the tests, keeping track of who failed.
129 for i
in `echo $tests`
131 if [ -x .
/test$i -o -x .
/test${i}.sh
]
133 total
=`expr $total + 1`
135 ARG
=`eval echo "\\${ARGS_$i}"`
140 runtest
$i $ARG >$out 2>&1
147 then if [ "$tapmode" ]
148 then echo "ok test $i"
150 passed
=`expr $passed + 1`
151 else if [ "$tapmode" ]
152 then echo "not ok test $i"
154 failed
=`expr $failed + 1`
155 badones
=`echo $badones " " $i`
159 then cat $out |
sed "s/^/$diagprefix/"
163 echo "${diagprefix}warning: skipping test$i"
164 skipped
=`expr $skipped + 1`
168 # Print results of the tests.
169 if [ "$tests" = "$alltests" ]
170 then echo "${diagprefix}"
171 if test $total = $passed
172 then echo "${diagprefix}All $passed tests completed without error ($skipped skipped)."
173 else echo "${diagprefix}Testing completed. Score: $passed passed, $failed failed, skipped $skipped"
174 echo "${diagprefix}The following tests failed: $badones"
178 # if any test failed return an error