modprobe: remove flock() because it never worked anyway
[mit.git] / tests / runtests
blobb0b6dce9e6f9f909b73eea809d3d94047c56b3e7
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 # Creates a temporary file and exports the name of the file to
10 # the provided argument. Exits on error.
12 # Usage: create_tempfile TEMPFILE
14 create_tempfile()
16 if test $# = 0
17 then
18 echo "No argument passed to create_tempfile()"
19 exit 1
22 if [ -x /bin/tempfile ]
23 then
24 # Debian
25 export $1="`tempfile`"
26 elif [ -x /bin/mktemp ]
27 then
28 # RedHat et. al.
29 export $1="`mktemp /tmp/modtest.XXXXXX`"
30 else
31 echo "Don't know how to make a temporary file on this "
32 echo "system, sorry."
33 exit 1
36 if [ $? -ne 0 ]
37 then
38 echo "Can't create temporary file."
39 exit 1
42 export -f create_tempfile
44 for config in --enable-zlib --disable-zlib; do
45 echo Building with $config...
46 ./configure $config CFLAGS="-DJUST_TESTING -g -Wall" >/dev/null
47 make clean >/dev/null
48 # ismod.static doesn't build with -DJUST_TESTING and --enable-zlib
49 make insmod.static >/dev/null 2>&1 || touch insmod.static
50 make all >/dev/null
52 echo Testing with $config...
53 if grep -q CONFIG_USE_ZLIB=1 Makefile; then
54 CONFIG_HAVE_ZLIB=1
55 export CONFIG_HAVE_ZLIB
56 else
57 unset CONFIG_HAVE_ZLIB
60 # Create endianness links
61 case `file modprobe` in
62 *MSB*) ENDIAN=be;;
63 *LSB*) ENDIAN=le;;
64 *) echo Unknown endian! >&2; exit 1;;
65 esac
66 ln -sfn 64-$ENDIAN tests/data/64
67 ln -sfn 32-$ENDIAN tests/data/32
69 # Make them run the valgrind wrappers, if available.
70 if type valgrind 2>/dev/null; then
71 PATH=`pwd`/tests:$PATH
72 else
73 PATH=`pwd`:$PATH
76 # By default, we want to look like a new kernel.
77 MODTEST_UNAME=2.6.27
78 export MODTEST_UNAME
80 MODTEST_OVERRIDE_ROOT=tests/tmp
81 export MODTEST_OVERRIDE_ROOT
83 if [ $# -eq 1 ]; then DOING=0; else DOING=1; fi
85 if [ ! -e "tests/tmp" ]; then
86 echo Making temporary directory for tests
87 mkdir tests/tmp
88 fi
91 for dir in `find tests/* -type d | sort`
93 # data and tmp dirs don't contain tests.
94 case "$dir" in tests/data*) continue;; tests/tmp*) continue;; esac
96 if [ -z "$VERBOSE" ]; then
97 echo -n Running tests for $dir.
98 else
99 echo Running tests for $dir.
101 shopt -s nullglob
102 for f in $dir/[0-9]*; do
103 # Ignore backups dir.
104 case "$f" in *~) continue;; esac
106 if [ $DOING -eq 0 ]; then
107 case "$f" in *$1*) DOING=1;; *) continue;; esac
110 rm -rf tests/tmp/*
111 if sh -e $EXTRA_ARGS $f; then
112 if [ -z "$VERBOSE" ]; then
113 echo -n .
114 else
115 echo Tests $f succeeded.
117 else
118 echo Test for $f failed.
119 # Dangerous to leave these lying around
120 make distclean >/dev/null
121 exit 1
123 done
124 if [ -z "$VERBOSE" ]; then echo; fi
125 done
126 done
128 exit 0