]> git.gag.com Git - debian/gzip/commitdiff
gzip: add tests for today's bug fix
authorJim Meyering <meyering@redhat.com>
Sat, 10 Oct 2009 09:29:33 +0000 (11:29 +0200)
committerJim Meyering <meyering@redhat.com>
Sat, 10 Oct 2009 09:35:52 +0000 (11:35 +0200)
* tests/trailing-nul: New file.  Test for today's fix.
* Makefile.am (TESTS): Add new script.
* NEWS (Bug fixes): Mention it.

Makefile.am
NEWS
tests/trailing-nul [new file with mode: 0755]

index 206d5bf1ddfd7019e0ac67904b587eaae817f70c..3bca0eefe7cd5c64cacd759f32df28e386ff99f1 100644 (file)
@@ -100,9 +100,11 @@ check-local: $(FILES_TO_CHECK) $(bin_PROGRAMS) gzip.doc.gz
          test "`cat $$k | ./gzip -dc $$k - $$k`" = aaa && rm $$k
        @echo 'Test succeeded.'
 
-TESTS =                \
-  tests/zdiff  \
+TESTS =                                                \
+  tests/trailing-nul                           \
+  tests/zdiff                                  \
   tests/zgrep-f
+
 EXTRA_DIST += $(TESTS)
 
 install-exec-hook: remove-installed-links
diff --git a/NEWS b/NEWS
index 5071241e60886159008d54daf5f8b5e86ee6d0a5..5aeee71a121833284418b4c8c32f9a7a263c3318 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU gzip NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  gzip no longer fails when there is exactly one trailing NUL byte
+  gzip has always accepted trailing NUL bytes.  Note the plural.
+
   zdiff would exit with status 2 (indicating an error) rather than 1 to
   indicate differences when both inputs were compressed and different.
 
diff --git a/tests/trailing-nul b/tests/trailing-nul
new file mode 100755 (executable)
index 0000000..08b6c02
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+# gzip accepts trailing NUL bytes; don't fail if there is exactly one.
+# Before gzip-1.4, this would fail.
+
+# Copyright (C) 2009 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/tests/test-lib.sh
+
+(echo 0 | gzip; printf '\0') > 0.gz || framework_failure
+(echo 00 | gzip; printf '\0\0') > 00.gz || framework_failure
+(echo 1 | gzip; printf '\1') > 1.gz || framework_failure
+
+fail=0
+
+for i in 0 00 1; do
+  gzip -d $i.gz; ret=$?
+  test $ret -eq $i || fail=1
+  test $ret = 1 && continue
+  echo $i > exp || fail=1
+  compare $i exp || fail=1
+done
+
+Exit $fail