]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Handle missing zlib in test_read_format_zip_7z_deflate 1668/head
authorMichał Górny <mgorny@gentoo.org>
Sat, 12 Feb 2022 10:12:27 +0000 (11:12 +0100)
committerMichał Górny <mgorny@gentoo.org>
Sat, 12 Feb 2022 10:12:27 +0000 (11:12 +0100)
libarchive/test/test_read_format_zip.c

index bc498fa431f0e4b7286f939d204cb5554c49868d..642a5e222ebe01b0de780c1ffa78d6c6dee4c417 100644 (file)
@@ -1128,6 +1128,7 @@ DEFINE_TEST(test_read_format_zip_7z_deflate)
        const char *refname = "test_read_format_zip_7z_deflate.zip";
        struct archive_entry *ae;
        struct archive *a;
+       int r;
 
        assert((a = archive_read_new()) != NULL);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
@@ -1137,15 +1138,33 @@ DEFINE_TEST(test_read_format_zip_7z_deflate)
        assertEqualIntA(a, ARCHIVE_OK,
                archive_read_open_filename(a, refname, 10240));
        //read first symlink
-       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       r = archive_read_next_header(a, &ae);
+       if (archive_zlib_version() == NULL) {
+               assertEqualInt(ARCHIVE_FAILED, r);
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method during decompression "
+                   "of link entry (8: deflation)");
+               assert(archive_errno(a) != 0);
+       } else {
+               assertEqualIntA(a, ARCHIVE_OK, r);
+               assertEqualString("libxkbcommon-x11.so.0.0.0",
+                       archive_entry_symlink(ae));
+       }
        assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
-       assertEqualString("libxkbcommon-x11.so.0.0.0",
-               archive_entry_symlink(ae));
        //read second symlink
-       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       r = archive_read_next_header(a, &ae);
+       if (archive_zlib_version() == NULL) {
+               assertEqualInt(ARCHIVE_FAILED, r);
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method during decompression "
+                   "of link entry (8: deflation)");
+               assert(archive_errno(a) != 0);
+       } else {
+               assertEqualIntA(a, ARCHIVE_OK, r);
+               assertEqualString("libxkbcommon-x11.so.0.0.0",
+                       archive_entry_symlink(ae));
+       }
        assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
-       assertEqualString("libxkbcommon-x11.so.0.0.0",
-               archive_entry_symlink(ae));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
 }