tests: move the hufts-segv test to its own file
authorJim Meyering <meyering@redhat.com>
Mon, 1 Feb 2010 14:02:34 +0000 (15:02 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 3 Feb 2010 05:23:57 +0000 (06:23 +0100)
* tests/hufts: New test.
* Makefile.am (TESTS): Add tests/
(check-local): Remove the hufts-segv test from this rule.

Makefile.am
tests/hufts [new file with mode: 0755]

index 181899aa6f624b44f9cd52d3337ef3c35a58d936..b4e75fc4054abf25a5f33d1fc413faca01de7c31 100644 (file)
@@ -97,12 +97,11 @@ check-local: $(FILES_TO_CHECK) $(bin_PROGRAMS) gzip.doc.gz
        for file in $(FILES_TO_CHECK); do \
          ./gzip -cv -- "$$file" | ./gzip -d | cmp - "$$file" || exit 1; \
        done
-       ./gzip -dc $(srcdir)/tests/hufts-segv.gz > /dev/null 2>&1; \
-         test $$? = 1
        @echo 'Test succeeded.'
 
 TESTS =                                                \
   tests/helin-segv                             \
+  tests/hufts                                  \
   tests/memcpy-abuse                           \
   tests/stdin                                  \
   tests/trailing-nul                           \
diff --git a/tests/hufts b/tests/hufts
new file mode 100755 (executable)
index 0000000..73e74de
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+# Exercise a bug whereby an invalid input could make gzip -d misbehave.
+
+# Copyright (C) 2009-2010 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# limit so don't run it by default.
+
+if test "$VERBOSE" = yes; then
+  set -x
+  zgrep --version
+fi
+
+: ${srcdir=.}
+. "$srcdir/tests/init.sh"
+
+printf '\n...: invalid compressed data--format violated\n' > exp \
+  || framework_failure
+
+fail=0
+gzip -dc "$abs_srcdir/tests/hufts-segv.gz" > out 2> err
+test $? = 1 || fail=1
+
+compare /dev/null out || fail=1
+
+sed 's/.*hufts-segv.gz: /...: /' err > k; mv k err || fail=1
+compare exp err || fail=1
+
+Exit $fail