minix/test/run
Ben Gras d3e3c78051 testmfs, testisofs: MFS format, ISO functionality
testmfs: catch MFS format changes

This test tests mkfs.mfs will generate the same FS image given the same
input files. mkproto creates a proto file (normalizing directory entry
order). The assumption is that a change in the output flags a tacit
change in FS format, and that a FS format change will cause the image
to change.

        . Changes to mkfs.mfs that innocently change the format can
          change the sha1 output in the script along with it.
        . The assumption is that corresponding versions of mkfs.mfs and
          MFS will always work together; otherwise a lot breaks (ramdisk etc.)
        . Therefore, as long as a generated FS image stays the same with the
          same input now, incompatible MFS changes will still be flagged,
          even if they work together with the current mkfs.mfs.

testisofs: test ISO filesystem

        . to test isofs: prepare an ISO FS image using writeisofs, copy it
          to a RAM device, mount it using the iso9660fs server, compare the
          SHA1 contents of the files on the ISO with the inputs.
        . use su to run certain commands in the script as root

run script: run shell script tests

	. they are installed without .sh so should be
	  searched for as such
	. add diagnostic when tests are skipped

Change-Id: I30daff58e1e43903dacf3c99996a4a0e7d819b6b
2013-11-21 10:17:43 +00:00

172 lines
3.8 KiB
Bash
Executable File

#!/bin/sh
# Are we running as root?
unset ROOT
if [ "`id -u`" = 0 ]
then ROOT=yes
fi
# 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
skipped=`expr 0` # count number of tests that were skipped
total=`expr 0` # total number of tests tried
badones= # list of tests that failed
# Tests which require setuid
setuids="test11 test33 test43 test44 test46 test56 test60 test61 test65 \
test69" # test73"
alltests=" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
61 62 63 64 65 66 67 68 69 70 71 72 75 \
sh1 sh2 interp mfs isofs"
tests_no=`expr 0`
# test mmap only if enabled in sysenv
filemap=1 # the default is on
if sysenv filemap >/dev/null
then filemap=`sysenv filemap`
fi
if [ "$filemap" -ne 0 ]
then alltests="$alltests 74"
fi
# If root, make sure the setuid tests have the correct permissions
# and make the dir bin-owned.
if [ "$ROOT" ]
then chown bin .
chown root ${setuids}
chmod 4755 ${setuids}
fi
tests=$alltests
# Are we given any args? If so, we might have to give
# or change our testlist
while getopts 'lt:T' opt
do
case $opt in
l) echo "$alltests"
exit 0
;;
t) tests="$OPTARG"
;;
T) tapmode=yes
diagprefix="# "
;;
?) echo "Usage: run [-l] [-t testlist] [-T]" >&2
echo " -l: list tests, exit" >&2
echo " -t: execute given set of tests, default: all" >&2
echo " -T: produce TAP-format output" >&2
exit 1
esac
done
# Count tests
for i in `echo $tests`; do
if [ -x ./test$i ]; then
tests_no=`expr $tests_no + 1`
fi
done
if [ $tests_no -eq 0 ]
then
echo "No test binaries found. did you compile?"
exit 1
fi
# Print tests list whenever user asks for TAP mode. It is up
# to the caller to make sure it makes sense, i.e. he knows what it
# represents.
if [ "$tapmode" ]
then echo "1..$tests_no"
fi
if [ "$tests" = "$alltests" ]
then # Print test welcome message
if [ ! "$tapmode" ]; then clear; fi
echo -n "${diagprefix}Running POSIX compliance test suite. "
echo "There are $tests_no tests in total."
echo "${diagprefix}"
fi
# Provide an argument for test63
ARGS_63=`pwd`/mod
runtest() {
i=$1
ARG=$2
if [ "$ROOT" ]
then su - bin -c "cd `pwd`; ./test$i $ARG" || return 1
else ./test$i $ARG || return 1
fi
return 0
}
# Run all the tests, keeping track of who failed.
for i in `echo $tests`
do
if [ -x ./test$i ]
then
total=`expr $total + 1`
FAIL=0
unset ARG
testid="`echo $i | sed 's/\..*//'`"
ARG=`eval echo "\\${ARGS_$testid}"`
if [ "$tapmode" ]
then out=out.$$
rm -f $out
runtest $i $ARG >$out 2>&1
else runtest $i $ARG
fi
FAIL=$?
if [ $FAIL -eq 0 ]
then if [ "$tapmode" ]
then echo "ok test $i"
fi
passed=`expr $passed + 1`
else if [ "$tapmode" ]
then echo "not ok test $i"
fi
failed=`expr $failed + 1`
badones=`echo $badones " " $i`
fi
if [ "$tapmode" ]
then cat $out | sed "s/^/$diagprefix/"
rm -f $out
fi
else
echo "${diagprefix}warning: skipping test$i"
skipped=`expr $skipped + 1`
fi
done
# Print results of the tests.
if [ "$tests" = "$alltests" ]
then echo "${diagprefix}"
if test $total = $passed
then echo "${diagprefix}All $passed tests completed without error ($skipped skipped)."
else echo "${diagprefix}Testing completed. Score: $passed passed, $failed failed, skipped $skipped"
echo "${diagprefix}The following tests failed: $badones"
fi
fi
# if any test failed return an error
if [ $failed -gt 0 ]
then
exit 1
fi
# echo " "