2005-04-21 16:53:53 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-04-18 15:41:01 +02:00
|
|
|
# Are we running as root?
|
|
|
|
unset ROOT
|
|
|
|
if [ "`id -u`" = 0 ]
|
|
|
|
then ROOT=yes
|
|
|
|
fi
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
# Initialization
|
|
|
|
PATH=:/bin:/usr/bin
|
|
|
|
export PATH
|
|
|
|
|
|
|
|
rm -rf DIR* # remove any old junk lying around
|
|
|
|
passed=`expr 0` # count number of tests run correctly
|
|
|
|
failed=`expr 0` # count number of tests that failed
|
2009-12-09 20:01:38 +01:00
|
|
|
skipped=`expr 0` # count number of tests that were skipped
|
2005-04-21 16:53:53 +02:00
|
|
|
total=`expr 0` # total number of tests tried
|
|
|
|
badones= # list of tests that failed
|
|
|
|
|
2013-03-08 17:02:27 +01:00
|
|
|
# Tests which require setuid
|
2013-04-07 00:46:56 +02:00
|
|
|
setuids="test11 test33 test43 test44 test46 test56 test60 test61 test65 \
|
2012-11-08 13:45:06 +01:00
|
|
|
test69" # test73"
|
2013-03-08 17:02:27 +01:00
|
|
|
|
2013-04-18 15:41:01 +02:00
|
|
|
alltests=" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
|
2010-05-03 17:12:39 +02:00
|
|
|
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
|
2012-02-17 17:12:44 +01:00
|
|
|
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
|
2012-11-08 13:45:06 +01:00
|
|
|
61 62 63 64 65 66 67 68 69 70 71 72 \
|
2011-12-20 16:20:32 +01:00
|
|
|
sh1.sh sh2.sh interp.sh"
|
2010-05-03 17:12:39 +02:00
|
|
|
tests_no=`expr 0`
|
|
|
|
|
2013-03-08 17:02:27 +01:00
|
|
|
# If root, make sure the setuid tests have the correct permissions
|
2013-04-19 12:24:50 +02:00
|
|
|
# and make the dir bin-owned.
|
|
|
|
if [ "$ROOT" ]
|
|
|
|
then chown bin .
|
|
|
|
chown root ${setuids}
|
|
|
|
chmod 4755 ${setuids}
|
|
|
|
fi
|
2013-04-18 15:41:01 +02:00
|
|
|
|
|
|
|
tests=$alltests
|
|
|
|
|
|
|
|
# Are we given any args? If so, we might have to give
|
|
|
|
# or change our testlist
|
|
|
|
while getopts 'lt:' opt
|
|
|
|
do
|
|
|
|
case $opt in
|
|
|
|
l) echo "$alltests"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
t) tests="$OPTARG"
|
|
|
|
;;
|
|
|
|
?) echo "Usage: run [-l] [-t testlist]" >&2; exit 1
|
|
|
|
esac
|
|
|
|
done
|
2013-03-08 17:02:27 +01:00
|
|
|
|
2010-08-06 14:33:32 +02:00
|
|
|
# Count tests
|
2010-05-03 17:12:39 +02:00
|
|
|
for i in `echo $tests`; do
|
|
|
|
if [ -x ./test$i ]; then
|
|
|
|
tests_no=`expr $tests_no + 1`
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2013-04-20 09:26:18 +02:00
|
|
|
#
|
|
|
|
if [ $tests_no -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "No test binaries found. did you compile?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-04-18 15:41:01 +02:00
|
|
|
if [ "$tests" = "$alltests" ]
|
|
|
|
then # Print test welcome message
|
|
|
|
clear
|
|
|
|
echo -n "Running POSIX compliance test suite. "
|
|
|
|
echo "There are $tests_no tests in total."
|
|
|
|
echo " "
|
|
|
|
fi
|
2005-06-07 13:52:35 +02:00
|
|
|
|
2012-04-08 19:22:02 +02:00
|
|
|
# Provide an argument for test63
|
|
|
|
ARGS_63=`pwd`/mod
|
|
|
|
|
2005-06-07 13:52:35 +02:00
|
|
|
# Run all the tests, keeping track of who failed.
|
2010-05-03 17:12:39 +02:00
|
|
|
for i in `echo $tests`
|
2009-12-09 20:01:38 +01:00
|
|
|
do
|
2010-05-03 17:12:39 +02:00
|
|
|
if [ -x ./test$i ]
|
2009-12-09 20:01:38 +01:00
|
|
|
then
|
|
|
|
total=`expr $total + 1`
|
|
|
|
FAIL=0
|
2012-04-08 19:22:02 +02:00
|
|
|
unset ARG
|
2012-04-16 15:39:50 +02:00
|
|
|
testid="`echo $i | sed 's/\..*//'`"
|
|
|
|
ARG=`eval echo "\\${ARGS_$testid}"`
|
2013-04-18 15:41:01 +02:00
|
|
|
if [ "$ROOT" ]
|
2012-04-20 11:34:56 +02:00
|
|
|
then su - bin -c "cd `pwd`; ./test$i $ARG" || FAIL=1
|
2012-04-16 15:39:50 +02:00
|
|
|
else ./test$i $ARG || FAIL=1
|
2009-12-09 20:01:38 +01:00
|
|
|
fi
|
|
|
|
if [ $FAIL -eq 0 ]
|
|
|
|
then passed=`expr $passed + 1`
|
|
|
|
else failed=`expr $failed + 1`
|
|
|
|
badones=`echo $badones " " $i`
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
skipped=`expr $skipped + 1`
|
2005-04-21 16:53:53 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Print results of the tests.
|
2013-04-18 15:41:01 +02:00
|
|
|
if [ "$tests" = "$alltests" ]
|
|
|
|
then echo " "
|
|
|
|
if test $total = $passed
|
|
|
|
then echo All $passed tests completed without error \($skipped skipped\).
|
|
|
|
else echo Testing completed. Score: $passed passed, $failed failed, \
|
|
|
|
skipped $skipped
|
|
|
|
echo The following tests failed: $badones
|
|
|
|
fi
|
2005-04-21 16:53:53 +02:00
|
|
|
fi
|
|
|
|
|
2013-04-20 09:26:18 +02:00
|
|
|
# if any test failed return an error
|
|
|
|
if [ $failed -gt 0 ]
|
|
|
|
then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
# echo " "
|