[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/4] tests: enable glibc's malloc-perturbing option
From: |
Jim Meyering |
Subject: |
[PATCH 1/4] tests: enable glibc's malloc-perturbing option |
Date: |
Sun, 09 May 2010 22:47:48 +0200 |
FYI, here are a few test-related patches I've just pushed:
>From 97f23c4c6b98977518a3c7dd33a94021790fa495 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 6 May 2010 07:34:08 +0200
Subject: [PATCH 1/4] tests: enable glibc's malloc-perturbing option
* tests/Makefile.am (MALLOC_PERTURB_): Define, in case it's not already
set in your environment.
(TESTS_ENVIRONMENT): Propagate MALLOC_PERTURB_ setting to test scripts.
---
tests/Makefile.am | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 16d6cbb..a8db6c9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -85,6 +85,10 @@ CLEANFILES = \
116909.out 123362.out 161700.out 171379.out 179698.out \
204255.first 204255.second
+# Default to a nonzero value. Environment overrides.
+# http://udrepper.livejournal.com/11429.html
+MALLOC_PERTURB_ = 1
+
TESTS_ENVIRONMENT = \
tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \
TMPDIR=$$tmp__; export TMPDIR; \
@@ -121,6 +125,7 @@ TESTS_ENVIRONMENT = \
CC='$(CC)' \
GREP_TEST_NAME=`echo $$tst|sed 's,^\./,,;s,/,-,g'` \
MAKE=$(MAKE) \
+ MALLOC_PERTURB_=$(MALLOC_PERTURB_); export MALLOC_PERTURB_ \
PACKAGE_BUGREPORT='$(PACKAGE_BUGREPORT)' \
PACKAGE_VERSION=$(PACKAGE_VERSION) \
PERL='$(PERL)' \
--
1.7.1.189.g07419
>From 2a83a3ee2d690bb73ecbc48d48d45c51da9ac4f5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 9 May 2010 21:42:53 +0200
Subject: [PATCH 2/4] tests: update help-version
* tests/help-version: Update from coreutils.
---
tests/help-version | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/tests/help-version b/tests/help-version
index 9d7d11d..10f93ad 100755
--- a/tests/help-version
+++ b/tests/help-version
@@ -23,8 +23,7 @@
test "x$SHELL" = x && SHELL=/bin/sh
export SHELL
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
expected_failure_status_chroot=125
expected_failure_status_env=125
@@ -184,6 +183,16 @@ shred_setup () { args=$tmp_in; }
touch_setup () { args=$tmp_in2; }
truncate_setup () { args="--reference=$tmp_in $tmp_in2"; }
+mkid_setup () { printf 'f(){}\ntypedef int t;\n' > f.c; args=. ; }
+lid_setup () { args=; }
+fid_setup () { args=f.c; }
+fnid_setup () { args=; }
+xtokid_setup () { args=; }
+aid_setup () { args=f; }
+eid_setup () { args=--version; }
+gid_setup () { args=f; }
+defid_setup () { args=t; }
+
basename_setup () { args=$tmp_in; }
dirname_setup () { args=$tmp_in; }
expr_setup () { args=foo; }
--
1.7.1.189.g07419
>From e67d5a1437e0d9473d2ba2dfe823b87c9ea2630e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 9 May 2010 21:52:55 +0200
Subject: [PATCH 3/4] tests: normalize init.sh-sourcing code
* tests/backref-multibyte-slow: Use one-line idiom.
* tests/backref-word: Likewise.
* tests/case-fold-backref: Likewise.
* tests/case-fold-backslash-w: Likewise.
* tests/case-fold-char-class: Likewise.
* tests/case-fold-char-range: Likewise.
* tests/case-fold-char-type: Likewise.
* tests/char-class-multibyte: Likewise.
* tests/dfaexec-multibyte: Likewise.
* tests/empty: Likewise.
* tests/euc-mb: Likewise.
* tests/fedora: Likewise.
* tests/fgrep-infloop: Likewise.
* tests/fmbtest: Likewise.
* tests/foad1: Likewise.
* tests/ignore-mmap: Likewise.
* tests/include-exclude: Likewise.
* tests/max-count-vs-context: Likewise.
* tests/pcre-z: Likewise.
* tests/prefix-of-multibyte: Likewise.
* tests/reversed-range-endpoints: Likewise.
* tests/sjis-mb: Likewise.
* tests/spencer1-locale: Likewise.
* tests/word-delim-multibyte: Likewise.
* tests/word-multi-file: Likewise.
---
tests/backref-multibyte-slow | 3 +--
tests/backref-word | 3 +--
tests/case-fold-backref | 3 +--
tests/case-fold-backslash-w | 3 +--
tests/case-fold-char-class | 3 +--
tests/case-fold-char-range | 3 +--
tests/case-fold-char-type | 3 +--
tests/char-class-multibyte | 3 +--
tests/dfaexec-multibyte | 3 +--
tests/empty | 3 +--
tests/euc-mb | 3 +--
tests/fedora | 3 +--
tests/fgrep-infloop | 3 +--
tests/fmbtest | 3 +--
tests/foad1 | 3 +--
tests/ignore-mmap | 3 +--
tests/include-exclude | 3 +--
tests/max-count-vs-context | 3 +--
tests/pcre-z | 3 +--
tests/prefix-of-multibyte | 3 +--
tests/reversed-range-endpoints | 3 +--
tests/sjis-mb | 3 +--
tests/spencer1-locale | 3 +--
tests/word-delim-multibyte | 3 +--
tests/word-multi-file | 3 +--
25 files changed, 25 insertions(+), 50 deletions(-)
diff --git a/tests/backref-multibyte-slow b/tests/backref-multibyte-slow
index 06ae1bd..eb32b43 100644
--- a/tests/backref-multibyte-slow
+++ b/tests/backref-multibyte-slow
@@ -1,7 +1,6 @@
#!/bin/sh
# This was approximately quadratic up to grep-2.6.3
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_en_utf8_locale_
require_timeout_
diff --git a/tests/backref-word b/tests/backref-word
index 1c98b7c..adf6a10 100644
--- a/tests/backref-word
+++ b/tests/backref-word
@@ -1,7 +1,6 @@
#!/bin/sh
# This would fail for grep-2.6
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
printf 'foo foo bar\n' > exp1 || framework_failure_
fail=0
diff --git a/tests/case-fold-backref b/tests/case-fold-backref
index c8b14a3..ef9e9bc 100644
--- a/tests/case-fold-backref
+++ b/tests/case-fold-backref
@@ -1,7 +1,6 @@
#!/bin/sh
# This would fail for grep-2.5.3
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
printf 'foo foo\nFoo foo\nFOO foo\n' > exp1 || framework_failure_
fail=0
diff --git a/tests/case-fold-backslash-w b/tests/case-fold-backslash-w
index 6ae7046..57ff0f5 100755
--- a/tests/case-fold-backslash-w
+++ b/tests/case-fold-backslash-w
@@ -1,8 +1,7 @@
#!/bin/sh
# test that \W works on case-insensitive matches. It used to become \w.
# Derived from https://savannah.gnu.org/bugs/?28162
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
if echo foo bar | LANG=C.ASCII grep '^foo\W'; then
echo foo bar | LANG=C.ASCII grep -i '^foo\W' || fail_ ASCII insensitive
diff --git a/tests/case-fold-char-class b/tests/case-fold-char-class
index 3722f7e..018d2d2 100644
--- a/tests/case-fold-char-class
+++ b/tests/case-fold-char-class
@@ -1,7 +1,6 @@
#!/bin/sh
# This would fail for grep-2.5.3
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
printf 'Y\n' > exp1 || framework_failure_
fail=0
diff --git a/tests/case-fold-char-range b/tests/case-fold-char-range
index 799ea9c..d036492 100644
--- a/tests/case-fold-char-range
+++ b/tests/case-fold-char-range
@@ -1,7 +1,6 @@
#!/bin/sh
# This would fail for grep-2.5.3
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
printf 'A\nZ\n' > exp1 || framework_failure_
fail=0
diff --git a/tests/case-fold-char-type b/tests/case-fold-char-type
index ca0b3c3..7ae7d4b 100644
--- a/tests/case-fold-char-type
+++ b/tests/case-fold-char-type
@@ -1,7 +1,6 @@
#!/bin/sh
# This would fail for grep-2.5.3
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
printf 'Y\n' > exp1 || framework_failure_
fail=0
diff --git a/tests/char-class-multibyte b/tests/char-class-multibyte
index 95220ee..07d9620 100644
--- a/tests/char-class-multibyte
+++ b/tests/char-class-multibyte
@@ -1,7 +1,6 @@
#!/bin/sh
# This would segfault for grep-2.6
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_en_utf8_locale_
diff --git a/tests/dfaexec-multibyte b/tests/dfaexec-multibyte
index 2f3e5d4..eea6315 100644
--- a/tests/dfaexec-multibyte
+++ b/tests/dfaexec-multibyte
@@ -1,7 +1,6 @@
#!/bin/sh
# This would fail for grep-2.5.3
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
printf 'aa\nab\nba\nbb\n' > exp1 || framework_failure_
printf '1 2 3\n' > exp2 || framework_failure_
diff --git a/tests/empty b/tests/empty
index 2cc17fd..977e43a 100755
--- a/tests/empty
+++ b/tests/empty
@@ -8,8 +8,7 @@
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_timeout_
diff --git a/tests/euc-mb b/tests/euc-mb
index 11350da..aebf759 100644
--- a/tests/euc-mb
+++ b/tests/euc-mb
@@ -2,8 +2,7 @@
# test that matches starting in the middle of a multibyte char aren't rejected
# too greedily.
# Derived from https://savannah.gnu.org/bugs/?23814
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
# Add "." to PATH for the use of get-mb-cur-max.
path_prepend_ .
diff --git a/tests/fedora b/tests/fedora
index a029999..e85cd60 100644
--- a/tests/fedora
+++ b/tests/fedora
@@ -1,7 +1,6 @@
#!/bin/bash
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
# GREP Regression test suite for Fedora bugs and fixes
# (c) 2008 Lubomir Rintel
diff --git a/tests/fgrep-infloop b/tests/fgrep-infloop
index 7491918..908b788 100644
--- a/tests/fgrep-infloop
+++ b/tests/fgrep-infloop
@@ -1,7 +1,6 @@
#!/bin/sh
# This would infloop for grep-2.6.1
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_en_utf8_locale_
require_timeout_
diff --git a/tests/fmbtest b/tests/fmbtest
index be0b886..c3037c8 100755
--- a/tests/fmbtest
+++ b/tests/fmbtest
@@ -5,8 +5,7 @@
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
# If cs_CZ.UTF-8 locale doesn't work, skip this test silently
LC_ALL=cs_CZ.UTF-8 locale -k LC_CTYPE 2>/dev/null | grep -q charmap.*UTF-8 \
diff --git a/tests/foad1 b/tests/foad1
index 9492fad..c294e5e 100755
--- a/tests/foad1
+++ b/tests/foad1
@@ -9,8 +9,7 @@
#
# This set of tests was started by Julian Foad.
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
failures=0
diff --git a/tests/ignore-mmap b/tests/ignore-mmap
index 9fdbf0c..a757216 100644
--- a/tests/ignore-mmap
+++ b/tests/ignore-mmap
@@ -1,7 +1,6 @@
#!/bin/sh
# Ensure that --mmap is ignored
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
echo a > in || framework_failure_
fail=0
diff --git a/tests/include-exclude b/tests/include-exclude
index 0745ce5..0192b78 100644
--- a/tests/include-exclude
+++ b/tests/include-exclude
@@ -1,7 +1,6 @@
#!/bin/sh
# Use of any --include or --exclude* option would segfault in 2.6 and 2.6.1
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
mkdir -p x/dir || framework_failure_
echo a > x/a || framework_failure_
diff --git a/tests/max-count-vs-context b/tests/max-count-vs-context
index 7713bbb..ec20728 100755
--- a/tests/max-count-vs-context
+++ b/tests/max-count-vs-context
@@ -1,7 +1,6 @@
#!/bin/sh
# Show how -m1 works with -A N when a 2nd match is < N lines after the first
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
cat <<EOF > in || framework_failure_
needle
diff --git a/tests/pcre-z b/tests/pcre-z
index f59c1fa..d1d5dd7 100755
--- a/tests/pcre-z
+++ b/tests/pcre-z
@@ -1,7 +1,6 @@
#!/bin/sh
# Test Perl regex with NUL-separated input
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
echo a | grep -P a >/dev/null 2>err || skip_ 'PCRE not available.'
compare err /dev/null || fail_ 'PCRE available, but stderr not empty.'
diff --git a/tests/prefix-of-multibyte b/tests/prefix-of-multibyte
index c077b81..05045b0 100644
--- a/tests/prefix-of-multibyte
+++ b/tests/prefix-of-multibyte
@@ -1,7 +1,6 @@
#!/bin/sh
# This would mistakenly print a line prior to grep-2.6.2.
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_en_utf8_locale_
diff --git a/tests/reversed-range-endpoints b/tests/reversed-range-endpoints
index e80c07a..eb84594 100644
--- a/tests/reversed-range-endpoints
+++ b/tests/reversed-range-endpoints
@@ -1,7 +1,6 @@
#!/bin/sh
# Ensure that an invalid range like [b-a] evokes exit status of 2.
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
fail=0
diff --git a/tests/sjis-mb b/tests/sjis-mb
index 02b95ce..5f7eaf7 100644
--- a/tests/sjis-mb
+++ b/tests/sjis-mb
@@ -3,8 +3,7 @@
# in this encoding, an ASCII character is both a valid single-byte
# character, and a suffix of a valid double-byte character
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
# Add "." to PATH for the use of get-mb-cur-max.
path_prepend_ .
diff --git a/tests/spencer1-locale b/tests/spencer1-locale
index 3efe7d4..a2c3556 100755
--- a/tests/spencer1-locale
+++ b/tests/spencer1-locale
@@ -8,8 +8,7 @@
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
fail=0
diff --git a/tests/word-delim-multibyte b/tests/word-delim-multibyte
index 20276c1..5add9c8 100644
--- a/tests/word-delim-multibyte
+++ b/tests/word-delim-multibyte
@@ -1,8 +1,7 @@
#!/bin/sh
# exercise \< and \> with multibyte data.
# Derived from http://savannah.gnu.org/bugs/?29537
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_en_utf8_locale_
diff --git a/tests/word-multi-file b/tests/word-multi-file
index 22bcdef..6614ab6 100644
--- a/tests/word-multi-file
+++ b/tests/word-multi-file
@@ -1,8 +1,7 @@
#!/bin/sh
# exercise the -w option on multiple files
# Derived from http://bugzilla.redhat.com/570500
-: ${srcdir=.}
-. "$srcdir/init.sh"; path_prepend_ ../src
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
mkdir a || framework_failure_
( cd a \
--
1.7.1.189.g07419
>From 1da431e6830663150af375ba452a77d9ec29706c Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 9 May 2010 22:45:30 +0200
Subject: [PATCH 4/4] tests: update init.sh
* tests/init.sh: Update from gnulib.
---
tests/init.sh | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/tests/init.sh b/tests/init.sh
index ee9c542..1c0b4b4 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -21,11 +21,16 @@
# The typical skeleton of a test looks like this:
#
# #!/bin/sh
-# : ${srcdir=.}
-# . "$srcdir/init.sh"; path_prepend_ .
+# . "${srcdir=.}/init.sh"; path_prepend_ .
# Execute some commands.
# Note that these commands are executed in a subdirectory, therefore you
# need to prepend "../" to relative filenames in the build directory.
+# Note that the "path_prepend_ ." is useful only if the body of your
+# test invokes programs residing in the initial directory.
+# For example, if the programs you want to test are in src/, and this test
+# script is named tests/test-1, then you would use "path_prepend_ ../src",
+# or perhaps export PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH"
+# to all tests via automake's TESTS_ENVIRONMENT.
# Set the exit code 0 for success, 77 for skipped, or 1 or other for failure.
# Use the skip_ and fail_ functions to print a diagnostic and then exit
# with the corresponding exit code.
@@ -89,6 +94,13 @@ fi
test -n "$EXEEXT" && shopt -s expand_aliases
+# Enable glibc's malloc-perturbing option.
+# This is cheap and useful for exposing code that depends on the fact that
+# malloc-related functions often return memory that is mostly zeroed.
+# If you have the time and cycles, use valgrind to do an even better job.
+${MALLOC_PERTURB_=87}
+export MALLOC_PERTURB_
+
# We use a trap below for cleanup. This requires us to go through
# hoops to get the right exit status transported through the handler.
# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
@@ -225,10 +237,12 @@ setup_()
|| fail_ "failed to create temporary directory in $initial_cwd_"
cd "$test_dir_"
- # This pair of trap statements ensures that the temporary directory,
- # $test_dir_, is removed upon exit as well as upon catchable signal.
+ # These trap statements ensure that the temporary directory, $test_dir_,
+ # is removed upon exit as well as upon receipt of any of the listed signals.
trap remove_tmp_ 0
- trap 'Exit $?' 1 2 13 15
+ for sig_ in 1 2 3 13 15; do
+ eval "trap 'Exit $(expr $sig_ + 128)' $sig_"
+ done
}
# Create a temporary directory, much like mktemp -d does.
--
1.7.1.189.g07419
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH 1/4] tests: enable glibc's malloc-perturbing option,
Jim Meyering <=