summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/test/test_read_format_zip.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2009-03-07 03:30:35 +0000
committerkientzle <kientzle@FreeBSD.org>2009-03-07 03:30:35 +0000
commit1fb91ed696ad16495fbca8611a7832a70911c333 (patch)
treed5059a444cacb39328ab0d1b11ea50326a262f9e /lib/libarchive/test/test_read_format_zip.c
parent6cf3aa0ad277135ba4eaae2d67de3d2f5375786f (diff)
downloadFreeBSD-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.
Diffstat (limited to 'lib/libarchive/test/test_read_format_zip.c')
-rw-r--r--lib/libarchive/test/test_read_format_zip.c18
1 files changed, 12 insertions, 6 deletions
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
}
OpenPOWER on IntegriCloud