tests: add 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.
This commit is contained in:
Jim Meyering
2018-03-25 21:17:18 -07:00
committed by Sergey Poznyakoff
parent 00f03498a9
commit e8c3f4860d
4 changed files with 124 additions and 2 deletions

1
tests/.gitignore vendored
View File

@@ -12,3 +12,4 @@ download
ttyemu
checkseekhole
ckmtime
/compress-*.at

View File

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

67
tests/compress.at.in Normal file
View File

@@ -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 @tool@-compressed tarballs
AT_SETUP([compress: @tool@])
AT_KEYWORDS([compression @tool@])
unset TAR_OPTIONS
AT_CHECK([
AT_GZIP_PREREQ([@tool@])
touch empty
# Create with --@tool@:
tar --@tool@ -cf - empty 2>err > k.tar.@suff@ || exit 1
test -s err && exit 1
tar tf k.tar.@suff@ 2>err > out || exit 1
test "$(cat out)" = empty || exit 1
test -s err && exit 1
# Ensure -ac works with an -f-specified .@suff@-suffixed name.
tar -acf k2.tar.@suff@ empty 2>err > out || exit 1
cmp k2.tar.@suff@ k.tar.@suff@ || exit 1
test -s err && exit 1
# Extraction: ensure the .@suff@ suffix is recognized.
rm -f empty || exit 1
tar xf k.tar.@suff@ 2>err > out || exit 1
test -s err && exit 1
test -f empty || exit 1
if test -n '@suff2@'; then
# Extraction: ensure the .@suff2@ suffix is also recognized.
mv k.tar.@suff@ k.@suff2@ || exit 1
rm -f empty
tar xf k.@suff2@ 2>err > out || exit 1
test -s err && exit 1
test -f empty || exit 1
else
:
fi
],
[0],
[],
[],
[],[])
AT_CLEANUP

View File

@@ -216,6 +216,15 @@ m4_include([opcomp04.at])
m4_include([opcomp05.at])
m4_include([opcomp06.at])
AT_BANNER([Compression])
m4_include([compress-gzip.at])
m4_include([compress-bzip2.at])
m4_include([compress-xz.at])
dnl: omit lzma, because it would fail due to magic number mismatch
m4_include([compress-lzip.at])
m4_include([compress-lzop.at])
m4_include([compress-zstd.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])