[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] tests: test for problems with long matches
From: |
Paul Eggert |
Subject: |
[PATCH 1/5] tests: test for problems with long matches |
Date: |
Thu, 01 Mar 2012 12:48:03 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120209 Thunderbird/10.0.1 |
The new test is expensive, so add a category of expensive tests,
which are normally not run, and put the new test in this new
category. The idea of having expensive tests is taken from coreutils.
* HACKING: Mention RUN_EXPENSIVE_TESTS and similar env vars.
* Makefile.am (check-expensive): New rule.
* tests/Makefile.am (TESTS): Add big-match.
* tests/init.cfg (expensive_): New function, from coreutils.
* tests/big-match: New file.
---
HACKING | 6 ++++++
Makefile.am | 5 +++++
tests/Makefile.am | 1 +
tests/big-match | 32 ++++++++++++++++++++++++++++++++
tests/init.cfg | 17 +++++++++++++++++
5 files changed, 61 insertions(+), 0 deletions(-)
create mode 100644 tests/big-match
diff --git a/HACKING b/HACKING
index 6a9d588..be39905 100644
--- a/HACKING
+++ b/HACKING
@@ -415,6 +415,12 @@ as possible. Note to run tests/new-test in isolation you
can do:
(cd tests && make check TESTS=new-test VERBOSE=yes)
+Variables that are significant for tests with their default values are:
+
+ VERBOSE=yes
+ RUN_EXPENSIVE_TESTS=no
+ SHELL=/bin/sh
+
There are many tests in the tests/ directories. Use one of the
init.sh-using scripts as a template.
diff --git a/Makefile.am b/Makefile.am
index 93fb852..786bf5e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,6 +29,11 @@ EXTRA_DIST = \
TODO \
cfg.mk
+# Shortcut target to make it easier to run expensive tests.
+.PHONY: check-expensive
+check-expensive:
+ $(MAKE) check RUN_EXPENSIVE_TESTS=yes
+
# Run syntax-check rules before creating a distribution tarball.
.PHONY: run-syntax-check
run-syntax-check:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 571bd1b..0a22ba6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -38,6 +38,7 @@ TESTS = \
backref \
backref-multibyte-slow \
backref-word \
+ big-match \
bogus-wctob \
bre \
case-fold-backref \
diff --git a/tests/big-match b/tests/big-match
new file mode 100644
index 0000000..1a3aeed
--- /dev/null
+++ b/tests/big-match
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Check that grep doesn't mishandle long matching lines.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+expensive_
+
+# Create a one-line file containing slightly more than 2 GiB.
+echo x | dd bs=1M seek=2048 >2G-plus-2 || framework_failure_
+
+skip_diagnostic=
+
+# These two patterns catch different kinds of
+# failures due to internal integer overflows.
+for pattern in '^.*' '^.*x\(\)\1'; do
+ diagnostic=$(LC_ALL=C grep -a "$pattern" 2G-plus-2 2>&1 >/dev/null)
+ status=$?
+
+ case $status,$diagnostic in
+ 0,*) ;;
+ 2,*': line too long for re_search')
+ skip_diagnostic='regular expression library cannot handle the test' ;;
+ 2,*': memory exhausted')
+ skip_diagnostic='not enough main memory to run the test' ;;
+ *) fail=1 ;;
+ esac
+done
+
+case $fail,$skip_diagnostic in
+0,?*) skip_ "$skip_diagnostic" ;;
+esac
+
+Exit $fail
diff --git a/tests/init.cfg b/tests/init.cfg
index 772e119..408400c 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -77,3 +77,20 @@ require_compiled_in_MB_support()
printf 'é' | LC_ALL=en_US.UTF-8 grep '[[:lower:]]' \
|| skip_ this test requires MBS support
}
+
+expensive_()
+{
+ if test "$RUN_EXPENSIVE_TESTS" != yes; then
+ skip_ 'expensive: disabled by default
+This test is relatively expensive, so it is disabled by default.
+To run it anyway, rerun make check with the RUN_EXPENSIVE_TESTS
+environment variable set to yes. E.g.,
+
+ env RUN_EXPENSIVE_TESTS=yes make check
+
+or use the shortcut target of the toplevel Makefile,
+
+ make check-expensive
+'
+ fi
+}
--
1.7.6.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH 1/5] tests: test for problems with long matches,
Paul Eggert <=