diff options
author | kientzle <kientzle@FreeBSD.org> | 2009-03-07 03:30:35 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2009-03-07 03:30:35 +0000 |
commit | 1fb91ed696ad16495fbca8611a7832a70911c333 (patch) | |
tree | d5059a444cacb39328ab0d1b11ea50326a262f9e | |
parent | 6cf3aa0ad277135ba4eaae2d67de3d2f5375786f (diff) | |
download | FreeBSD-src-1fb91ed696ad16495fbca8611a7832a70911c333.zip FreeBSD-src-1fb91ed696ad16495fbca8611a7832a70911c333.tar.gz |
Merge r335,653,676 from libarchive.googlecode.com: Instead of
conditioning tests on HAVE_ZLIB, etc, just ask libarchive for the
service and handle the failure coming back from libarchive. This
gives us better test coverage of common client usage where clients
simply try to use libarchive services and handle the errors coming
back instead of trying to second-guess which libarchive services are
compiled in.
-rw-r--r-- | lib/libarchive/test/test.h | 11 | ||||
-rw-r--r-- | lib/libarchive/test/test_compat_bzip2.c | 11 | ||||
-rw-r--r-- | lib/libarchive/test/test_compat_gzip.c | 11 | ||||
-rw-r--r-- | lib/libarchive/test/test_compat_zip.c | 17 | ||||
-rw-r--r-- | lib/libarchive/test/test_fuzz.c | 42 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_cpio_bin_bz2.c | 16 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_cpio_bin_gz.c | 16 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_cpio_svr4_gzip.c | 16 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_gtar_gz.c | 16 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_iso_gz.c | 16 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_pax_bz2.c | 16 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_tbz.c | 16 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_tgz.c | 16 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_format_zip.c | 18 | ||||
-rw-r--r-- | lib/libarchive/test/test_write_compress_program.c | 41 |
15 files changed, 189 insertions, 90 deletions
diff --git a/lib/libarchive/test/test.h b/lib/libarchive/test/test.h index 19b2a67..fcac91a 100644 --- a/lib/libarchive/test/test.h +++ b/lib/libarchive/test/test.h @@ -189,3 +189,14 @@ int read_open_memory2(struct archive *, void *, size_t, size_t); test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a)) #define assertEqualStringA(a,v1,v2) \ test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a)) + +/* + * A compression is not supported + * Use this define after archive_read_next_header() is called + */ +#define UnsupportedCompress(r, a) \ + (r != ARCHIVE_OK && \ + (strcmp(archive_error_string(a), \ + "Unrecognized archive format") == 0 && \ + archive_compression(a) == ARCHIVE_COMPRESSION_NONE)) + diff --git a/lib/libarchive/test/test_compat_bzip2.c b/lib/libarchive/test/test_compat_bzip2.c index f9d4029..4b2cf05 100644 --- a/lib/libarchive/test/test_compat_bzip2.c +++ b/lib/libarchive/test/test_compat_bzip2.c @@ -55,6 +55,12 @@ compat_bzip2(const char *name) /* Read entries, match up names with list above. */ for (i = 0; i < 6; ++i) { r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping BZIP2 compression check: " + "This version of libarchive was compiled " + "without bzip2 support"); + goto finish; + } failure("Could not read file %d (%s) from %s", i, n[i], name); assertEqualIntA(a, ARCHIVE_OK, r); if (r != ARCHIVE_OK) { @@ -73,6 +79,7 @@ compat_bzip2(const char *name) assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else @@ -83,12 +90,8 @@ compat_bzip2(const char *name) DEFINE_TEST(test_compat_bzip2) { -#if HAVE_BZLIB_H compat_bzip2("test_compat_bzip2_1.tbz"); compat_bzip2("test_compat_bzip2_2.tbz"); -#else - skipping("Need bzlib"); -#endif } diff --git a/lib/libarchive/test/test_compat_gzip.c b/lib/libarchive/test/test_compat_gzip.c index 87dd23b..25cdc2b 100644 --- a/lib/libarchive/test/test_compat_gzip.c +++ b/lib/libarchive/test/test_compat_gzip.c @@ -55,6 +55,12 @@ verify(const char *name) /* Read entries, match up names with list above. */ for (i = 0; i < 6; ++i) { r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping GZIP compression check: " + "This version of libarchive was compiled " + "without gzip support"); + goto finish; + } failure("Could not read file %d (%s) from %s", i, n[i], name); assertEqualIntA(a, ARCHIVE_OK, r); if (r != ARCHIVE_OK) { @@ -73,6 +79,7 @@ verify(const char *name) assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else @@ -83,7 +90,6 @@ verify(const char *name) DEFINE_TEST(test_compat_gzip) { -#if HAVE_ZLIB_H /* This sample has been 'split', each piece compressed separately, * then concatenated. Gunzip will emit the concatenated result. */ /* Not supported in libarchive 2.6 and earlier */ @@ -91,9 +97,6 @@ DEFINE_TEST(test_compat_gzip) /* This sample has been compressed as a single stream, but then * some unrelated garbage text has been appended to the end. */ verify("test_compat_gzip_2.tgz"); -#else - skipping("Need zlib"); -#endif } diff --git a/lib/libarchive/test/test_compat_zip.c b/lib/libarchive/test/test_compat_zip.c index ac26d34..f60bc4f 100644 --- a/lib/libarchive/test/test_compat_zip.c +++ b/lib/libarchive/test/test_compat_zip.c @@ -32,6 +32,7 @@ test_compat_zip_1(void) char name[] = "test_compat_zip_1.zip"; struct archive_entry *ae; struct archive *a; + int r; assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); @@ -44,7 +45,16 @@ test_compat_zip_1(void) assertEqualString("META-INF/MANIFEST.MF", archive_entry_pathname(ae)); /* Read second entry. */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (r != ARCHIVE_OK) { + if (strcmp(archive_error_string(a), + "libarchive compiled without deflate support (no libz)") == 0) { + skipping("Skipping ZIP compression check: %s", + archive_error_string(a)); + goto finish; + } + } + assertEqualIntA(a, ARCHIVE_OK, r); assertEqualString("tmp.class", archive_entry_pathname(ae)); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); @@ -53,6 +63,7 @@ test_compat_zip_1(void) assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ZIP); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else @@ -63,11 +74,7 @@ test_compat_zip_1(void) DEFINE_TEST(test_compat_zip) { -#if HAVE_ZLIB_H test_compat_zip_1(); -#else - skipping("Need zlib"); -#endif } diff --git a/lib/libarchive/test/test_fuzz.c b/lib/libarchive/test/test_fuzz.c index 673d4b7..ab25c27 100644 --- a/lib/libarchive/test/test_fuzz.c +++ b/lib/libarchive/test/test_fuzz.c @@ -51,19 +51,13 @@ __FBSDID("$FreeBSD$"); static const char * files[] = { "test_fuzz_1.iso", -#if HAVE_BZLIB_H "test_compat_bzip2_1.tbz", -#endif "test_compat_gtar_1.tar", "test_compat_tar_hardlink_1.tar", -#if HAVE_ZLIB_H "test_compat_zip_1.zip", -#endif "test_read_format_gtar_sparse_1_17_posix10_modified.tar", "test_read_format_tar_empty_filename.tar", -#if HAVE_ZLIB_H "test_read_format_zip.zip", -#endif NULL }; @@ -72,9 +66,11 @@ DEFINE_TEST(test_fuzz) const char **filep; for (filep = files; *filep != NULL; ++filep) { + struct archive_entry *ae; + struct archive *a; char *rawimage, *image; size_t size; - int i; + int i, r; extract_reference_file(*filep); rawimage = slurpfile(&size, *filep); @@ -83,9 +79,37 @@ DEFINE_TEST(test_fuzz) assert(image != NULL); srand(time(NULL)); + assert((a = archive_read_new()) != NULL); + assert(0 == archive_read_support_compression_all(a)); + assert(0 == archive_read_support_format_all(a)); + assert(0 == archive_read_open_memory(a, rawimage, size)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping GZIP/BZIP2 compression check: " + "This version of libarchive was compiled " + "without gzip/bzip2 support"); + assert(0 == archive_read_close(a)); + assert(0 == archive_read_finish(a)); + continue; + } + assert(0 == r); + if (r == ARCHIVE_OK) { + char buff[20]; + + r = archive_read_data(a, buff, 19); + if (r < ARCHIVE_OK && strcmp(archive_error_string(a), + "libarchive compiled without deflate support (no libz)") == 0) { + skipping("Skipping ZIP compression check: %s", + archive_error_string(a)); + assert(0 == archive_read_close(a)); + assert(0 == archive_read_finish(a)); + continue; + } + } + assert(0 == archive_read_close(a)); + assert(0 == archive_read_finish(a)); + for (i = 0; i < 100; ++i) { - struct archive_entry *ae; - struct archive *a; int j, fd, numbytes; /* Fuzz < 1% of the bytes in the archive. */ diff --git a/lib/libarchive/test/test_read_format_cpio_bin_bz2.c b/lib/libarchive/test/test_read_format_cpio_bin_bz2.c index 0a857f0..426841b 100644 --- a/lib/libarchive/test/test_read_format_cpio_bin_bz2.c +++ b/lib/libarchive/test/test_read_format_cpio_bin_bz2.c @@ -34,27 +34,33 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_cpio_bin_bz2) { -#if HAVE_BZLIB_H struct archive_entry *ae; struct archive *a; + int r; + assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping BZ2 compression check: " + "This version of libarchive was compiled " + "without bz2 support"); + goto finish; + } + assertEqualIntA(a, ARCHIVE_OK, r); assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2); assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE); assert(0 == archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assert(0 == archive_read_finish(a)); #endif -#else - skipping("Need bzlib"); -#endif } diff --git a/lib/libarchive/test/test_read_format_cpio_bin_gz.c b/lib/libarchive/test/test_read_format_cpio_bin_gz.c index ce05f9d..77e322f 100644 --- a/lib/libarchive/test/test_read_format_cpio_bin_gz.c +++ b/lib/libarchive/test/test_read_format_cpio_bin_gz.c @@ -33,25 +33,31 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_cpio_bin_gz) { -#if HAVE_ZLIB_H struct archive_entry *ae; struct archive *a; + int r; + assert((a = archive_read_new()) != NULL); assert(0 == archive_read_support_compression_all(a)); assert(0 == archive_read_support_format_all(a)); assert(0 == archive_read_open_memory(a, archive, sizeof(archive))); - assert(0 == archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping GZIP compression check: " + "This version of libarchive was compiled " + "without gzip support"); + goto finish; + } + assert(0 == r); assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP); assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE); assert(0 == archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assert(0 == archive_read_finish(a)); #endif -#else - skipping("Need zlib"); -#endif } diff --git a/lib/libarchive/test/test_read_format_cpio_svr4_gzip.c b/lib/libarchive/test/test_read_format_cpio_svr4_gzip.c index 2787405..e517bb2 100644 --- a/lib/libarchive/test/test_read_format_cpio_svr4_gzip.c +++ b/lib/libarchive/test/test_read_format_cpio_svr4_gzip.c @@ -34,25 +34,31 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_cpio_svr4_gzip) { -#if HAVE_ZLIB_H struct archive_entry *ae; struct archive *a; + int r; + assert((a = archive_read_new()) != NULL); assert(0 == archive_read_support_compression_all(a)); assert(0 == archive_read_support_format_all(a)); assert(0 == archive_read_open_memory(a, archive, sizeof(archive))); - assert(0 == archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping GZIP compression check: " + "This version of libarchive was compiled " + "without gzip support"); + goto finish; + } + assert(0 == r); assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP); assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_SVR4_NOCRC); assert(0 == archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assert(0 == archive_read_finish(a)); #endif -#else - skipping("Need zlib"); -#endif } diff --git a/lib/libarchive/test/test_read_format_gtar_gz.c b/lib/libarchive/test/test_read_format_gtar_gz.c index afced28..6d3b66d 100644 --- a/lib/libarchive/test/test_read_format_gtar_gz.c +++ b/lib/libarchive/test/test_read_format_gtar_gz.c @@ -34,25 +34,31 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_gtar_gz) { -#if HAVE_ZLIB_H struct archive_entry *ae; struct archive *a; + int r; + assert((a = archive_read_new()) != NULL); assert(0 == archive_read_support_compression_all(a)); assert(0 == archive_read_support_format_all(a)); assert(0 == archive_read_open_memory(a, archive, sizeof(archive))); - assert(0 == archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping GZIP compression check: " + "This version of libarchive was compiled " + "without gzip support"); + goto finish; + } + assert(0 == r); assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP); assert(archive_format(a) == ARCHIVE_FORMAT_TAR_GNUTAR); assert(0 == archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assert(0 == archive_read_finish(a)); #endif -#else - skipping("Need zlib"); -#endif } diff --git a/lib/libarchive/test/test_read_format_iso_gz.c b/lib/libarchive/test/test_read_format_iso_gz.c index 9e61f87..6a9172f 100644 --- a/lib/libarchive/test/test_read_format_iso_gz.c +++ b/lib/libarchive/test/test_read_format_iso_gz.c @@ -53,9 +53,10 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_iso_gz) { -#if HAVE_ZLIB_H struct archive_entry *ae; struct archive *a; + int r; + assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); @@ -63,18 +64,23 @@ DEFINE_TEST(test_read_format_iso_gz) archive_read_support_format_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping GZIP compression check: " + "This version of libarchive was compiled " + "without gzip support"); + goto finish; + } + assertEqualIntA(a, ARCHIVE_OK, r); assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); #endif -#else - skipping("Need zlib"); -#endif } diff --git a/lib/libarchive/test/test_read_format_pax_bz2.c b/lib/libarchive/test/test_read_format_pax_bz2.c index 9490440..e0d0d2a 100644 --- a/lib/libarchive/test/test_read_format_pax_bz2.c +++ b/lib/libarchive/test/test_read_format_pax_bz2.c @@ -42,25 +42,31 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_pax_bz2) { -#if HAVE_BZLIB_H struct archive_entry *ae; struct archive *a; + int r; + assert((a = archive_read_new()) != NULL); assert(0 == archive_read_support_compression_all(a)); assert(0 == archive_read_support_format_all(a)); assert(0 == archive_read_open_memory(a, archive, sizeof(archive))); - assert(0 == archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping BZIP2 compression check: " + "This version of libarchive was compiled " + "without bzip2 support"); + goto finish; + } + assert(0 == r); assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2); assert(archive_format(a) == ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE); assert(0 == archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assert(0 == archive_read_finish(a)); #endif -#else - skipping("Need bzlib"); -#endif } diff --git a/lib/libarchive/test/test_read_format_tbz.c b/lib/libarchive/test/test_read_format_tbz.c index 3b44592..3d0e474 100644 --- a/lib/libarchive/test/test_read_format_tbz.c +++ b/lib/libarchive/test/test_read_format_tbz.c @@ -35,25 +35,31 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_tbz) { -#if HAVE_BZLIB_H struct archive_entry *ae; struct archive *a; + int r; + assert((a = archive_read_new()) != NULL); assert(0 == archive_read_support_compression_all(a)); assert(0 == archive_read_support_format_all(a)); assert(0 == archive_read_open_memory(a, archive, sizeof(archive))); - assert(0 == archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping BZIP2 compression check: " + "This version of libarchive was compiled " + "without bzip2 support"); + goto finish; + } + assert(0 == r); assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2); assert(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR); assert(0 == archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assert(0 == archive_read_finish(a)); #endif -#else - skipping("Need bzlib"); -#endif } diff --git a/lib/libarchive/test/test_read_format_tgz.c b/lib/libarchive/test/test_read_format_tgz.c index 67f8e8a..4b3d420 100644 --- a/lib/libarchive/test/test_read_format_tgz.c +++ b/lib/libarchive/test/test_read_format_tgz.c @@ -34,25 +34,31 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_tgz) { -#if HAVE_ZLIB_H struct archive_entry *ae; struct archive *a; + int r; + assert((a = archive_read_new()) != NULL); assert(0 == archive_read_support_compression_all(a)); assert(0 == archive_read_support_format_all(a)); assert(0 == archive_read_open_memory(a, archive, sizeof(archive))); - assert(0 == archive_read_next_header(a, &ae)); + r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("Skipping GZIP compression check: " + "This version of libarchive was compiled " + "without gzip support"); + goto finish; + } + assert(0 == r); assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP); assert(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR); assert(0 == archive_read_close(a)); +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assert(0 == archive_read_finish(a)); #endif -#else - skipping("Need zlib"); -#endif } diff --git a/lib/libarchive/test/test_read_format_zip.c b/lib/libarchive/test/test_read_format_zip.c index 77d6616..8c7059d 100644 --- a/lib/libarchive/test/test_read_format_zip.c +++ b/lib/libarchive/test/test_read_format_zip.c @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_read_format_zip) { -#if HAVE_ZLIB_H const char *refname = "test_read_format_zip.zip"; struct archive_entry *ae; struct archive *a; @@ -41,6 +40,7 @@ DEFINE_TEST(test_read_format_zip) const void *pv; size_t s; off_t o; + int r; extract_reference_file(refname); assert((a = archive_read_new()) != NULL); @@ -59,7 +59,16 @@ DEFINE_TEST(test_read_format_zip) assertEqualInt(1179604289, archive_entry_mtime(ae)); assertEqualInt(18, archive_entry_size(ae)); failure("archive_read_data() returns number of bytes read"); - assertEqualInt(18, archive_read_data(a, buff, 19)); + r = archive_read_data(a, buff, 19); + if (r < ARCHIVE_OK) { + if (strcmp(archive_error_string(a), + "libarchive compiled without deflate support (no libz)") == 0) { + skipping("Skipping ZIP compression check: %s", + archive_error_string(a)); + goto finish; + } + } + assertEqualInt(18, r); assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18)); assertA(0 == archive_read_next_header(a, &ae)); assertEqualString("file2", archive_entry_pathname(ae)); @@ -72,15 +81,12 @@ DEFINE_TEST(test_read_format_zip) assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE); assertA(archive_format(a) == ARCHIVE_FORMAT_ZIP); assert(0 == archive_read_close(a)); - +finish: #if ARCHIVE_VERSION_NUMBER < 2000000 archive_read_finish(a); #else assert(0 == archive_read_finish(a)); #endif -#else - skipping("Need zlib"); -#endif } diff --git a/lib/libarchive/test/test_write_compress_program.c b/lib/libarchive/test/test_write_compress_program.c index c4cf933..e00e398 100644 --- a/lib/libarchive/test/test_write_compress_program.c +++ b/lib/libarchive/test/test_write_compress_program.c @@ -92,29 +92,26 @@ DEFINE_TEST(test_write_compress_program) assertA(0 == archive_read_open_memory(a, buff, used)); r = archive_read_next_header(a, &ae); - if (r != ARCHIVE_OK) { - if (strcmp(archive_error_string(a), - "Unrecognized archive format") == 0) { - skipping("This version of libarchive was compiled " - "without gzip support"); - assert(0 == archive_read_finish(a)); - /* - * Try using an external "gunzip","gzip -d" program - */ - if ((extprog = external_gzip_program(1)) == NULL) { - skipping("There is no gzip uncompression " - "program in this platform"); - return; - } - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_none(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_program(a, extprog)); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used)); - r = archive_read_next_header(a, &ae); + if (UnsupportedCompress(r, a)) { + skipping("This version of libarchive was compiled " + "without gzip support"); + assert(0 == archive_read_finish(a)); + /* + * Try using an external "gunzip","gzip -d" program + */ + if ((extprog = external_gzip_program(1)) == NULL) { + skipping("There is no gzip uncompression " + "program in this platform"); + return; } + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_support_compression_none(a)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_support_compression_program(a, extprog)); + assertA(0 == archive_read_support_format_all(a)); + assertA(0 == archive_read_open_memory(a, buff, used)); + r = archive_read_next_header(a, &ae); } assertA(0 == r); |