"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@xxxxxxxxxxxxxx> 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 0dcf985..f352b8e 100644 --- a/HACKING +++ b/HACKING @@ -7,10 +7,14 @@ substantial over time. Development is preferably done via git merges. * git trees don't contain pre-built config/Makefiles/etc. You'll need to run the following (in order): - aclocal + aclocal -I m4 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/valgrind/suppressions b/tests/valgrind/suppressions new file mode 100644 index 0000000..16289f8 --- /dev/null +++ b/tests/valgrind/suppressions @@ -0,0 +1,33 @@ +{ + Glibc goes boom from _start (Debian glibc 2.3.5-3) + Memcheck:Cond + obj:/lib/ld-2.3.5.so + obj:/lib/ld-2.3.5.so + obj:/lib/ld-2.3.5.so + obj:/lib/ld-2.3.5.so + obj:/lib/ld-2.3.5.so +} +{ + GCC strlen() builtin generates questionable reads + Memcheck:Addr4 + fun:output_symbols + fun:main +} +{ + GCC strlen() builtin generates questionable reads + Memcheck:Addr4 + fun:output_aliases + fun:main +} +{ + GCC strlen() builtin generates questionable reads + Memcheck:Addr4 + fun:output_symbols_bin + fun:main +} +{ + GCC strlen() builtin generates questionable reads + Memcheck:Addr4 + fun:output_aliases_bin + fun:main +} 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 diff --git a/tests/vg-suppressions b/tests/vg-suppressions deleted file mode 100644 index 16289f8..0000000 --- a/tests/vg-suppressions +++ /dev/null @@ -1,33 +0,0 @@ -{ - Glibc goes boom from _start (Debian glibc 2.3.5-3) - Memcheck:Cond - obj:/lib/ld-2.3.5.so - obj:/lib/ld-2.3.5.so - obj:/lib/ld-2.3.5.so - obj:/lib/ld-2.3.5.so - obj:/lib/ld-2.3.5.so -} -{ - GCC strlen() builtin generates questionable reads - Memcheck:Addr4 - fun:output_symbols - fun:main -} -{ - GCC strlen() builtin generates questionable reads - Memcheck:Addr4 - fun:output_aliases - fun:main -} -{ - GCC strlen() builtin generates questionable reads - Memcheck:Addr4 - fun:output_symbols_bin - fun:main -} -{ - GCC strlen() builtin generates questionable reads - Memcheck:Addr4 - fun:output_aliases_bin - fun:main -} -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html