aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-05-11 09:22:58 +0100
committerJon Masters <jcm@jonmasters.org>2009-05-19 04:52:06 -0400
commit869fc9c1573ae321ae1cb2923ee0b98a1d4021dc (patch)
treec158b10859b029e682b433edfc75c2873479c195
parent2d23075ca0f6560901ddda3645ba49d4c330a867 (diff)
downloadmodule-init-tools-869fc9c1573ae321ae1cb2923ee0b98a1d4021dc.tar.gz
testsuite: add --valgrind
"valgrindme.sh" has been hanging around for a while without doing anything. The original idea seems to have been to run under valgrind automatically. But it is very slow, which discourages one from running the testsuite. Implement it as an option instead. In particular, this was useful while writing the binary index code. Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk> Signed-off-by: Jon Masters <jcm@jonmasters.org>
-rw-r--r--.gitignore3
-rw-r--r--HACKING4
-rwxr-xr-xtests/runtests62
l---------tests/valgrind/depmod1
l---------tests/valgrind/insmod1
l---------tests/valgrind/lsmod1
l---------tests/valgrind/modindex1
l---------tests/valgrind/modinfo1
l---------tests/valgrind/modprobe1
l---------tests/valgrind/rmmod1
-rw-r--r--tests/valgrind/suppressions (renamed from tests/vg-suppressions)0
-rwxr-xr-xtests/valgrind/valgrindme.sh14
-rwxr-xr-xtests/valgrindme.sh14
13 files changed, 72 insertions, 32 deletions
diff --git a/.gitignore b/.gitignore
index b71ac35..5d57b2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,9 @@ modindex
modprobe
rmmod
+# But don't ignore the symlinks with the same names in this directory
+!tests/valgrind/*
+
# Generated documentation
*.8
*.5
diff --git a/HACKING b/HACKING
index 933c99c..f352b8e 100644
--- a/HACKING
+++ b/HACKING
@@ -11,6 +11,10 @@ substantial over time. Development is preferably done via git merges.
automake --add-missing --copy
autoconf
+* Regression tests can be run as follows (try --help for more details):
+
+ tests/runtests
+
* Documentation is in SGML source in doc/ so don't edit *.8, *.5 directly.
Prior to a new release:
diff --git a/tests/runtests b/tests/runtests
index cbc02f2..0c7d7f3 100755
--- a/tests/runtests
+++ b/tests/runtests
@@ -3,11 +3,41 @@
set -e
-if [ x"$1" = x"-v" ]; then VERBOSE=1; shift; fi
-if [ x"$1" = x"-v" -o x"$1" = x"-vv" ]; then VERBOSE=1; EXTRA_ARGS=-x; shift; fi
+usage()
+{
+ echo "Usage: tests/runtests [-v] [-v] [--valgrind] [test]"
+ echo " -v (or --verbose) prints each test as it is run"
+ echo " -vv (very verbose) traces test execution"
+ echo " --valgrind runs the test programs using the valgrind memory checker"
+ exit
+}
-# Run by "make check" from build directory
-if [ -n "$srcdir" ]; then cd "$srcdir"; fi
+while [ $# != 0 ]; do
+ case "$1" in
+ -v)
+ if [ -z "$VERBOSE" ]; then
+ VERBOSE=1
+ else
+ EXTRA_ARGS=-x
+ fi
+ ;;
+ -vv)
+ VERBOSE=1
+ EXTRA_ARGS=-x
+ ;;
+ --valgrind)
+ VALGRIND=1
+ ;;
+ -h|--help|-*)
+ usage
+ ;;
+ *)
+ [ -n "$TEST" ] && usage
+ TEST="$1"
+ ;;
+ esac
+ shift
+done
# Creates a temporary file and exports the name of the file to
# the provided argument. Exits on error.
@@ -81,7 +111,12 @@ for config in --enable-zlib --disable-zlib; do
ln -sfn 64-$ENDIAN tests/data/64
ln -sfn 32-$ENDIAN tests/data/32
- PATH=`pwd`/tests/build:$PATH
+ # Make them run the valgrind wrappers if requested.
+ if [ -n "$VALGRIND" ]; then
+ PATH=`pwd`/tests/valgrind:$PATH
+ else
+ PATH=`pwd`/tests/build:$PATH
+ fi
# By default, we want to look like a new kernel.
MODTEST_UNAME=2.6.27
@@ -90,16 +125,10 @@ for config in --enable-zlib --disable-zlib; do
MODTEST_OVERRIDE_ROOT=tests/tmp
export MODTEST_OVERRIDE_ROOT
- if [ $# -eq 1 ]; then DOING=0; else DOING=1; fi
+ if [ -n "$TEST" ]; then DOING=0; else DOING=1; fi
- for dir in `find tests/* -type d | sort`
+ for dir in `find tests/test-* -type d | sort`
do
- # data, build and tmp dirs don't contain tests.
- case "$dir" in
- tests/data*) continue;;
- tests/build*) continue;;
- tests/tmp*) continue;;
- esac
if [ -z "$VERBOSE" ]; then
echo -n Running tests for $dir.
@@ -107,12 +136,9 @@ for config in --enable-zlib --disable-zlib; do
echo Running tests for $dir.
fi
shopt -s nullglob
- for f in $dir/[0-9]*; do
- # Ignore backups dir.
- case "$f" in *~) continue;; esac
-
+ for f in $dir/[0-9]*.sh; do
if [ $DOING -eq 0 ]; then
- case "$f" in *$1*) DOING=1;; *) continue;; esac
+ case "$f" in *$TEST*) DOING=1;; *) continue;; esac
fi
rm -rf tests/tmp/*
diff --git a/tests/valgrind/depmod b/tests/valgrind/depmod
new file mode 120000
index 0000000..af8962e
--- /dev/null
+++ b/tests/valgrind/depmod
@@ -0,0 +1 @@
+valgrindme.sh \ No newline at end of file
diff --git a/tests/valgrind/insmod b/tests/valgrind/insmod
new file mode 120000
index 0000000..af8962e
--- /dev/null
+++ b/tests/valgrind/insmod
@@ -0,0 +1 @@
+valgrindme.sh \ No newline at end of file
diff --git a/tests/valgrind/lsmod b/tests/valgrind/lsmod
new file mode 120000
index 0000000..af8962e
--- /dev/null
+++ b/tests/valgrind/lsmod
@@ -0,0 +1 @@
+valgrindme.sh \ No newline at end of file
diff --git a/tests/valgrind/modindex b/tests/valgrind/modindex
new file mode 120000
index 0000000..af8962e
--- /dev/null
+++ b/tests/valgrind/modindex
@@ -0,0 +1 @@
+valgrindme.sh \ No newline at end of file
diff --git a/tests/valgrind/modinfo b/tests/valgrind/modinfo
new file mode 120000
index 0000000..af8962e
--- /dev/null
+++ b/tests/valgrind/modinfo
@@ -0,0 +1 @@
+valgrindme.sh \ No newline at end of file
diff --git a/tests/valgrind/modprobe b/tests/valgrind/modprobe
new file mode 120000
index 0000000..af8962e
--- /dev/null
+++ b/tests/valgrind/modprobe
@@ -0,0 +1 @@
+valgrindme.sh \ No newline at end of file
diff --git a/tests/valgrind/rmmod b/tests/valgrind/rmmod
new file mode 120000
index 0000000..af8962e
--- /dev/null
+++ b/tests/valgrind/rmmod
@@ -0,0 +1 @@
+valgrindme.sh \ No newline at end of file
diff --git a/tests/vg-suppressions b/tests/valgrind/suppressions
index 16289f8..16289f8 100644
--- a/tests/vg-suppressions
+++ b/tests/valgrind/suppressions
diff --git a/tests/valgrind/valgrindme.sh b/tests/valgrind/valgrindme.sh
new file mode 100755
index 0000000..0ab8a86
--- /dev/null
+++ b/tests/valgrind/valgrindme.sh
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+# Make sure it finds the real one this time.
+PATH=`pwd`/tests/build:$PATH
+valgrind -q --num-callers=8 --suppressions=tests/valgrind/suppressions --log-fd=3 `basename $0` "$@" 3>tests/tmp/valgrind
+ret=$?
+
+if [ -s tests/tmp/valgrind ]; then
+ echo VALGRIND FAILED for $0 "$@" > /proc/$PPID/fd/1
+ cat tests/tmp/valgrind > /proc/$PPID/fd/1
+ kill $PPID
+ exit 1
+fi
+exit $ret
diff --git a/tests/valgrindme.sh b/tests/valgrindme.sh
deleted file mode 100755
index 6ebc14a..0000000
--- a/tests/valgrindme.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#! /bin/sh
-
-# Make sure it finds real one this time.
-PATH=`pwd`:$PATH
-valgrind -q --num-callers=8 --suppressions=tests/vg-suppressions --log-fd=3 `basename $0` "$@" 3>/tmp/valgrind
-ret=$?
-
-if [ -s /tmp/valgrind ]; then
- echo VALGRIND FAILED for $0 "$@" > /proc/$PPID/fd/1
- cat /tmp/valgrind > /proc/$PPID/fd/1
- kill $PPID
- exit 1
-fi
-exit $ret