docs: don't forget to pass -I m4 to aclocal
[mit.git] / tests / runtests
blobcbc02f2e05122a9c3cc36fc8c3a027573d3a47c8
1 #! /bin/bash
2 # Shell script to run test suite.
4 set -e
6 if [ x"$1" = x"-v" ]; then VERBOSE=1; shift; fi
7 if [ x"$1" = x"-v" -o x"$1" = x"-vv" ]; then VERBOSE=1; EXTRA_ARGS=-x; shift; fi
9 # Run by "make check" from build directory
10 if [ -n "$srcdir" ]; then cd "$srcdir"; fi
12 # Creates a temporary file and exports the name of the file to
13 # the provided argument. Exits on error.
15 # Usage: create_tempfile TEMPFILE
17 create_tempfile()
19 if test $# = 0
20 then
21 echo "No argument passed to create_tempfile()"
22 exit 1
25 if [ -x /bin/tempfile ]
26 then
27 # Debian
28 export $1="`tempfile`"
29 elif [ -x /bin/mktemp ]
30 then
31 # RedHat et. al.
32 export $1="`mktemp /tmp/modtest.XXXXXX`"
33 else
34 echo "Don't know how to make a temporary file on this "
35 echo "system, sorry."
36 exit 1
39 if [ $? -ne 0 ]
40 then
41 echo "Can't create temporary file."
42 exit 1
45 export -f create_tempfile
47 if [ ! -e "tests/build" ]; then
48 echo Making build directory for tests
49 mkdir tests/build
51 if [ ! -e "tests/tmp" ]; then
52 echo Making temporary directory for tests
53 mkdir tests/tmp
56 for config in --enable-zlib --disable-zlib; do
57 echo Building with $config...
59 cd tests/build
60 ../../configure $config CFLAGS="-DJUST_TESTING -g -Wall" >/dev/null
61 make clean >/dev/null
62 # ismod.static doesn't build with -DJUST_TESTING and --enable-zlib
63 make insmod.static >/dev/null 2>&1 || touch insmod.static
64 make all >/dev/null
65 cd ../..
67 echo Testing with $config...
68 if grep -q CONFIG_USE_ZLIB=1 tests/build/Makefile; then
69 CONFIG_HAVE_ZLIB=1
70 export CONFIG_HAVE_ZLIB
71 else
72 unset CONFIG_HAVE_ZLIB
75 # Create endianness links
76 case `file tests/build/modprobe` in
77 *MSB*) ENDIAN=be;;
78 *LSB*) ENDIAN=le;;
79 *) echo Unknown endian! >&2; exit 1;;
80 esac
81 ln -sfn 64-$ENDIAN tests/data/64
82 ln -sfn 32-$ENDIAN tests/data/32
84 PATH=`pwd`/tests/build:$PATH
86 # By default, we want to look like a new kernel.
87 MODTEST_UNAME=2.6.27
88 export MODTEST_UNAME
90 MODTEST_OVERRIDE_ROOT=tests/tmp
91 export MODTEST_OVERRIDE_ROOT
93 if [ $# -eq 1 ]; then DOING=0; else DOING=1; fi
95 for dir in `find tests/* -type d | sort`
97 # data, build and tmp dirs don't contain tests.
98 case "$dir" in
99 tests/data*) continue;;
100 tests/build*) continue;;
101 tests/tmp*) continue;;
102 esac
104 if [ -z "$VERBOSE" ]; then
105 echo -n Running tests for $dir.
106 else
107 echo Running tests for $dir.
109 shopt -s nullglob
110 for f in $dir/[0-9]*; do
111 # Ignore backups dir.
112 case "$f" in *~) continue;; esac
114 if [ $DOING -eq 0 ]; then
115 case "$f" in *$1*) DOING=1;; *) continue;; esac
118 rm -rf tests/tmp/*
119 if sh -e $EXTRA_ARGS $f; then
120 if [ -z "$VERBOSE" ]; then
121 echo -n .
122 else
123 echo Tests $f succeeded.
125 else
126 echo Test for $f failed.
127 exit 1
129 done
130 if [ -z "$VERBOSE" ]; then echo; fi
131 done
132 done
134 exit 0