depmod: export static device node information to modules.devname
[mit.git] / tests / runtests
blobe5c81843ed2d93d6d0b4e673f90cbb4594821d3b
1 #! /bin/bash
2 # Shell script to run test suite.
4 set -e
6 usage()
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"
14 exit
17 while [ $# != 0 ]; do
18 case "$1" in
19 -v)
20 if [ -z "$VERBOSE" ]; then
21 VERBOSE=1
22 else
23 EXTRA_ARGS=-x
26 -vv)
27 VERBOSE=1
28 EXTRA_ARGS=-x
30 --valgrind)
31 VALGRIND=1
33 -h|--help|-*)
34 usage
37 [ -n "$TEST" ] && usage
38 TEST="$1"
40 esac
41 shift
42 done
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
49 create_tempfile()
51 if test $# = 0
52 then
53 echo "No argument passed to create_tempfile()"
54 exit 1
57 if [ -x /bin/tempfile ]
58 then
59 # Debian
60 export $1="`tempfile`"
61 elif [ -x /bin/mktemp ]
62 then
63 # RedHat et. al.
64 export $1="`mktemp /tmp/modtest.XXXXXX`"
65 else
66 echo "Don't know how to make a temporary file on this "
67 echo "system, sorry."
68 exit 1
71 if [ $? -ne 0 ]
72 then
73 echo "Can't create temporary file."
74 exit 1
77 export -f create_tempfile
79 if [ ! -e "tests/build" ]; then
80 echo Making build directory for tests
81 mkdir tests/build
83 if [ ! -e "tests/tmp" ]; then
84 echo Making temporary directory for tests
85 mkdir tests/tmp
88 : ${TEST_ENDIAN:=-be -le}
89 _tmp=
90 for e in $TEST_ENDIAN; do
91 case $e in
92 -be | -le)
93 _tmp="$_tmp $e"
95 be | le)
96 _tmp="$_tmp -$e"
99 echo "Unknown endian: $e, valid values are \"be\" and \"le\"" >&2
100 exit 1
101 esac
102 done
103 TEST_ENDIAN="$_tmp"
105 : ${TEST_BITS:=32 64}
106 for b in $TEST_BITS; do
107 case $b in
108 32 | 64)
111 echo "Unknown word size: $b, valid values are 32 and 64" >&2
112 exit 1
113 esac
114 done
116 for config in --enable-zlib --disable-zlib; do
117 echo Building with $config...
119 cd tests/build
120 ../../configure $config CFLAGS="-DJUST_TESTING -g -Wall" >/dev/null
121 make clean >/dev/null
122 # ismod.static doesn't build with -DJUST_TESTING and --enable-zlib
123 make insmod.static >/dev/null 2>&1 || touch insmod.static
124 make all >/dev/null
125 cd ../..
127 echo Testing with $config...
128 if grep -q CONFIG_USE_ZLIB=1 tests/build/Makefile; then
129 CONFIG_HAVE_ZLIB=1
130 export CONFIG_HAVE_ZLIB
131 else
132 unset CONFIG_HAVE_ZLIB
135 # Create endianness links
136 case `file tests/build/modprobe` in
137 *MSB*) ENDIAN=be;;
138 *LSB*) ENDIAN=le;;
139 *) echo Unknown endian! >&2; exit 1;;
140 esac
141 ln -sfn 64-$ENDIAN tests/data/64
142 ln -sfn 32-$ENDIAN tests/data/32
144 # Make them run the valgrind wrappers if requested.
145 if [ -n "$VALGRIND" ]; then
146 PATH=`pwd`/tests/valgrind:$PATH
147 else
148 PATH=`pwd`/tests/build:$PATH
151 # By default, we want to look like a new kernel.
152 MODTEST_UNAME=2.6.27
153 export MODTEST_UNAME
155 MODTEST_OVERRIDE_ROOT=tests/tmp
156 export MODTEST_OVERRIDE_ROOT
158 if [ -n "$TEST" ]; then DOING=0; else DOING=1; fi
160 for dir in `find tests/test-* -type d | sort`
163 if [ -z "$VERBOSE" ]; then
164 echo -n Running tests for $dir.
165 else
166 echo Running tests for $dir.
168 shopt -s nullglob
169 for f in $dir/[0-9]*.sh; do
170 if [ $DOING -eq 0 ]; then
171 case "$f" in *$TEST*) DOING=1;; *) continue;; esac
174 rm -rf tests/tmp/*
175 if sh -e $EXTRA_ARGS $f; then
176 if [ -z "$VERBOSE" ]; then
177 echo -n .
178 else
179 echo Tests $f succeeded.
181 else
182 echo Test for $f failed.
183 exit 1
185 done
186 if [ -z "$VERBOSE" ]; then echo; fi
187 done
188 done
190 exit 0