tests: exercise the fix for the decompression data-loss bug
authorJim Meyering <meyering@redhat.com>
Fri, 19 Feb 2010 19:50:09 +0000 (20:50 +0100)
committerJim Meyering <meyering@redhat.com>
Mon, 22 Feb 2010 13:42:54 +0000 (14:42 +0100)
* tests/null-suffix-clobber: New file.
* Makefile.am (TESTS): Add it.

Makefile.am
tests/null-suffix-clobber [new file with mode: 0755]

index 816e9f4efbe6aeab88ca7f5c1db94b0c92a0cbff..3b048b8eeeccd11fba2793120998ecfe71f5b723 100644 (file)
@@ -108,6 +108,7 @@ TESTS =                                             \
   tests/hufts                                  \
   tests/memcpy-abuse                           \
   tests/mixed                                  \
+  tests/null-suffix-clobber                    \
   tests/stdin                                  \
   tests/trailing-nul                           \
   tests/zdiff                                  \
diff --git a/tests/null-suffix-clobber b/tests/null-suffix-clobber
new file mode 100755 (executable)
index 0000000..e5b52a1
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Before gzip-1.5, gzip -d -S '' k.gz would delete F.gz and not create "F"
+
+# Copyright (C) 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
+  gzip --version
+fi
+
+: ${srcdir=.}
+. "$srcdir/tests/init.sh"
+
+printf anything | gzip > F.gz || framework_failure
+echo y > yes || framework_failure
+echo "gzip: invalid suffix ''" > expected-err || framework_failure
+
+fail=0
+
+gzip ---presume-input-tty -d -S '' F.gz < yes > out 2>err && fail=1
+
+compare out /dev/null || fail=1
+compare err expected-err || fail=1
+
+test -f F.gz || fail=1
+
+Exit $fail