bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] [PATCH] tests: add coverage for new --zstd and all other compr


From: Jim Meyering
Subject: [Bug-tar] [PATCH] tests: add coverage for new --zstd and all other compression tools
Date: Sun, 25 Mar 2018 21:17:18 -0700

Hi Sergey,

Here is a patch to add tests for --zstd as well as coverage for
the other types of compression that tar supports.

>From 212c575a1beb5a8193d02f982d2e8fcc2ff45fa1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 20 Mar 2018 13:12:10 -0700
Subject: [PATCH] tests: add test coverage for new --zstd and all other
 compression tools

* tests/compress.at.in: New file: template from which each
per-compression-tool test is derived.
* tests/Makefile.am (TESTSUITE_AT): Add it.
(EXTRA_DIST): Add compress.at.in.
(compress-*.at): New rules to generate a file/tests for each compression tool.
* tests/testsuite.at (Compression): Add each of these generated
files in a new section.
* tests/.gitignore: Ignore the new generated files.
---
 tests/.gitignore     |  1 +
 tests/Makefile.am    | 48 ++++++++++++++++++++++++++++++-
 tests/compress.at.in | 67 ++++++++++++++++++++++++++++++++++++++++++++
 tests/testsuite.at   | 10 ++++++-
 4 files changed, 124 insertions(+), 2 deletions(-)
 create mode 100644 tests/compress.at.in

diff --git a/tests/.gitignore b/tests/.gitignore
index 9c0103d..802adb1 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -12,3 +12,4 @@ download
 ttyemu
 checkseekhole
 ckmtime
+/compress-*.at
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2d7939d..fb46325 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,9 +17,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

-EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 star/README star/quicktest.sh
+EXTRA_DIST = $(TESTSUITE_AT) \
+  testsuite package.m4 star/README star/quicktest.sh \
+  compress.at.in
+
 DISTCLEANFILES       = atconfig $(check_SCRIPTS)
 MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
+CLEANFILES =

 ## ------------ ##
 ## package.m4.  ##
@@ -66,6 +70,12 @@ TESTSUITE_AT = \
  chtype.at\
  comprec.at\
  comperr.at\
+ compress-zstd.at\
+ compress-xz.at\
+ compress-bzip2.at\
+ compress-gzip.at\
+ compress-lzip.at\
+ compress-lzop.at\
  delete01.at\
  delete02.at\
  delete03.at\
@@ -264,6 +274,42 @@ TESTSUITE_AT = \
  selacl01.at\
  capabs_raw01.at

+CLEANFILES += compress-zstd.at
+compress-zstd.at: compress.at.in
+       $(AM_V_GEN)rm -rf $@ address@hidden
+       $(AM_V_at)sed 's/@tool@/zstd/g;s/@suff@/zst/g;s/@suff2@/tzst/g;' \
+         $(srcdir)/compress.at.in > address@hidden && chmod a-w address@hidden 
&& mv address@hidden $@
+
+CLEANFILES += compress-gzip.at
+compress-gzip.at: compress.at.in
+       $(AM_V_GEN)rm -rf $@ address@hidden
+       $(AM_V_at)sed 's/@tool@/gzip/g;s/@suff@/gz/g;s/@suff2@/tgz/g;' \
+         $(srcdir)/compress.at.in > address@hidden && chmod a-w address@hidden 
&& mv address@hidden $@
+
+CLEANFILES += compress-xz.at
+compress-xz.at: compress.at.in
+       $(AM_V_GEN)rm -rf $@ address@hidden
+       $(AM_V_at)sed 's/@tool@/xz/g;s/@suff@/xz/g;s/@suff2@/txz/g;' \
+         $(srcdir)/compress.at.in > address@hidden && chmod a-w address@hidden 
&& mv address@hidden $@
+
+CLEANFILES += compress-bzip2.at
+compress-bzip2.at: compress.at.in
+       $(AM_V_GEN)rm -rf $@ address@hidden
+       $(AM_V_at)sed 's/@tool@/bzip2/g;s/@suff@/bz2/g;s/@suff2@/tbz2/g;' \
+         $(srcdir)/compress.at.in > address@hidden && chmod a-w address@hidden 
&& mv address@hidden $@
+
+CLEANFILES += compress-lzip.at
+compress-lzip.at: compress.at.in
+       $(AM_V_GEN)rm -rf $@ address@hidden
+       $(AM_V_at)sed 's/@tool@/lzip/g;s/@suff@/lz/g;s/@suff2@//g;' \
+         $(srcdir)/compress.at.in > address@hidden && chmod a-w address@hidden 
&& mv address@hidden $@
+
+CLEANFILES += compress-lzop.at
+compress-lzop.at: compress.at.in
+       $(AM_V_GEN)rm -rf $@ address@hidden
+       $(AM_V_at)sed 's/@tool@/lzop/g;s/@suff@/lzo/g;s/@suff2@//g;' \
+         $(srcdir)/compress.at.in > address@hidden && chmod a-w address@hidden 
&& mv address@hidden $@
+
 distclean-local:
        -rm -rf download

diff --git a/tests/compress.at.in b/tests/compress.at.in
new file mode 100644
index 0000000..e9cc76a
--- /dev/null
+++ b/tests/compress.at.in
@@ -0,0 +1,67 @@
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
+
+# Test suite for GNU tar.
+# Copyright 2018 Free Software Foundation, Inc.
+
+# This file is part of GNU tar.
+
+# GNU tar 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.
+
+# GNU tar 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/>.
+
+# tar can create/decompress @address@hidden tarballs
+
+AT_SETUP([compress: @address@hidden)
+AT_KEYWORDS([compression @address@hidden)
+
+unset TAR_OPTIONS
+
+AT_CHECK([
+AT_GZIP_PREREQ(address@hidden@])
+
+touch empty
+# Create with address@hidden@:
+tar address@hidden@ -cf - empty 2>err > address@hidden@ || exit 1
+test -s err && exit 1
+tar tf address@hidden@ 2>err > out || exit 1
+test "$(cat out)" = empty || exit 1
+test -s err && exit 1
+
+# Ensure -ac works with an -f-specified address@hidden@-suffixed name.
+tar -acf address@hidden@ empty 2>err > out || exit 1
+cmp address@hidden@ address@hidden@ || exit 1
+test -s err && exit 1
+
+# Extraction: ensure the address@hidden@ suffix is recognized.
+rm -f empty || exit 1
+tar xf address@hidden@ 2>err > out || exit 1
+test -s err && exit 1
+test -f empty || exit 1
+
+if test -n '@suff2@'; then
+  # Extraction: ensure the address@hidden@ suffix is also recognized.
+  mv address@hidden@ address@hidden@ || exit 1
+  rm -f empty
+  tar xf address@hidden@ 2>err > out || exit 1
+  test -s err && exit 1
+  test -f empty || exit 1
+else
+  :
+fi
+
+],
+[0],
+[],
+[],
+[],[])
+
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 0f2600f..6095f93 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -216,6 +216,15 @@ m4_include([opcomp04.at])
 m4_include([opcomp05.at])
 m4_include([opcomp06.at])

+AT_BANNER([Compression])
+m4_include([compress-zstd.at])
+m4_include([compress-xz.at])
+m4_include([compress-bzip2.at])
+m4_include([compress-gzip.at])
+dnl: omit lzma, because it would fail due to magic number mismatch
+m4_include([compress-lzip.at])
+m4_include([compress-lzop.at])
+
 AT_BANNER([Positional options])
 m4_include([positional01.at])
 m4_include([positional02.at])
@@ -490,4 +499,3 @@ m4_include([star/ustar-big-2g.at])
 m4_include([star/ustar-big-8g.at])

 m4_include([star/pax-big-10g.at])
-
--
2.17.0.rc1.35.g90bbd502d



reply via email to

[Prev in Thread] Current Thread [Next in Thread]