2 # Shell script to run test suite.
8 echo "Usage: tests/runtests [-v] [-v] [--valgrind] [test]"
9 echo " -v (or --verbose) prints each test as it is run"
10 echo " -vv (very verbose) traces test execution"
11 echo " --valgrind runs the test programs using the valgrind memory checker"
12 echo "The TEST_ENDIAN and TEST_BITS variables can be used to limit which"
13 echo "endianess (le, be) and bitness (32, 64) will be tested"
20 if [ -z "$VERBOSE" ]; then
37 [ -n "$TEST" ] && usage
44 # Creates a temporary file and exports the name of the file to
45 # the provided argument. Exits on error.
47 # Usage: create_tempfile TEMPFILE
53 echo "No argument passed to create_tempfile()"
57 if [ -x /bin
/tempfile
]
60 export $1="`tempfile`"
61 elif [ -x /bin
/mktemp
]
64 export $1="`mktemp /tmp/modtest.XXXXXX`"
66 echo "Don't know how to make a temporary file on this "
73 echo "Can't create temporary file."
77 export -f create_tempfile
79 if [ ! -e "tests/build" ]; then
80 echo Making build directory
for tests
83 if [ ! -e "tests/tmp" ]; then
84 echo Making temporary directory
for tests
88 : ${TEST_ENDIAN:=-be -le}
90 for e
in $TEST_ENDIAN; do
99 echo "Unknown endian: $e, valid values are \"be\" and \"le\"" >&2
106 : ${TEST_BITS:=32 64}
107 for b
in $TEST_BITS; do
112 echo "Unknown word size: $b, valid values are 32 and 64" >&2
118 for config
in --enable-zlib --disable-zlib; do
119 echo Building with
$config...
122 ..
/..
/configure
$config CFLAGS
="-DJUST_TESTING -g -Wall" >/dev
/null
123 make clean
>/dev
/null
124 # ismod.static doesn't build with -DJUST_TESTING and --enable-zlib
125 make insmod.static
>/dev
/null
2>&1 ||
touch insmod.static
129 echo Testing with
$config...
130 if grep -q CONFIG_USE_ZLIB
=1 tests
/build
/Makefile
; then
132 export CONFIG_HAVE_ZLIB
134 unset CONFIG_HAVE_ZLIB
137 # Create endianness links
138 case `file tests/build/modprobe` in
141 *) echo Unknown endian
! >&2; exit 1;;
143 ln -sfn 64-$ENDIAN tests
/data
/64
144 ln -sfn 32-$ENDIAN tests
/data
/32
146 # Make them run the valgrind wrappers if requested.
147 if [ -n "$VALGRIND" ]; then
148 PATH
=`pwd`/tests
/valgrind
:$PATH
150 PATH
=`pwd`/tests
/build
:$PATH
153 # By default, we want to look like a new kernel.
157 MODTEST_OVERRIDE_ROOT
=tests
/tmp
158 export MODTEST_OVERRIDE_ROOT
160 if [ -n "$TEST" ]; then DOING
=0; else DOING
=1; fi
162 for dir
in `find tests/test-* -type d | sort`
165 if [ -z "$VERBOSE" ]; then
166 echo -n Running tests
for $dir.
168 echo Running tests
for $dir.
171 for f
in $dir/[0-9]*.sh
; do
172 if [ $DOING -eq 0 ]; then
173 case "$f" in *$TEST*) DOING
=1;; *) continue;; esac
177 if sh
-e $EXTRA_ARGS $f; then
178 if [ -z "$VERBOSE" ]; then
181 echo Tests
$f succeeded.
184 echo Test
for $f failed.
188 if [ -z "$VERBOSE" ]; then echo; fi