]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Skip zlib tests if support is missing 2658/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 3 Jun 2025 15:24:30 +0000 (17:24 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 3 Jun 2025 15:27:48 +0000 (17:27 +0200)
If zlib is not supported, do not run tests to avoid false positives.

Also adjust tests to support latest gzip versions (1.10+) which store
less information for improved reproducibility. The gzip binary is
used as a fallback if zlib is not available.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
18 files changed:
libarchive/test/test_read_filter_gzip_recursive.c
libarchive/test/test_read_set_format.c
libarchive/test/test_write_filter_gzip.c
libarchive/test/test_write_filter_gzip_timestamp.c
unzip/test/test_C.c
unzip/test/test_L.c
unzip/test/test_basic.c
unzip/test/test_d.c
unzip/test/test_doubledash.c
unzip/test/test_glob.c
unzip/test/test_j.c
unzip/test/test_n.c
unzip/test/test_o.c
unzip/test/test_p.c
unzip/test/test_q.c
unzip/test/test_singlefile.c
unzip/test/test_t.c
unzip/test/test_x.c

index 0042a0511d5af50d48a85455c4b14d8417918326..51b614b6c023bf9ececec62f62e0edd1d505c980 100644 (file)
@@ -29,8 +29,8 @@ DEFINE_TEST(test_read_filter_gzip_recursive)
        const char *name = "test_read_filter_gzip_recursive.gz";
        struct archive *a;
 
-       if (!canGzip()) {
-               skipping("gzip not available");
+       if (archive_zlib_version() == NULL) {
+               skipping("zlib not available");
                return;
        }
 
index c760de0056d361682033fe5bed38c94e67a82de2..f951d9f7b72215754e83ebff26e459cda901fbdf 100644 (file)
@@ -138,7 +138,10 @@ DEFINE_TEST(test_read_append_filter)
     assertEqualInt(ARCHIVE_OK, archive_read_free(a));
     return;
   }
-  assertEqualIntA(a, ARCHIVE_OK, r);
+  if (r == ARCHIVE_WARN && canGzip())
+    assertEqualString(archive_error_string(a), "Using external gzip program");
+  else
+    assertEqualIntA(a, ARCHIVE_OK, r);
   assertEqualInt(ARCHIVE_OK,
       archive_read_open_memory(a, archive, sizeof(archive)));
   assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
index 8fbdbed09744c6a68709888f6ab824fa3f521925..a6681d7618b12d8d15c952a916a5723a31bb8568 100644 (file)
@@ -166,9 +166,15 @@ DEFINE_TEST(test_write_filter_gzip)
        assertEqualInt(rbuff[0], 0x1f);
        assertEqualInt(rbuff[1], 0x8b);
        assertEqualInt(rbuff[2], 0x08);
-       assertEqualInt(rbuff[3], 0x08);
-       assertEqualInt(rbuff[8], 2); /* RFC 1952 flag for compression level 9 */
-       assertEqualString((const char*)rbuff+10, "testorgfilename");
+       /* RFC 1952 flag for compression level 9 */
+       assertEqualInt(rbuff[8], 2);
+       /* External gzip program might not save filename */
+       if (!use_prog || rbuff[3] == 0x08) {
+               assertEqualInt(rbuff[3], 0x08);
+               assertEqualString((const char*)rbuff+10, "testorgfilename");
+       } else {
+               assertEqualInt(rbuff[3], 0x00);
+       }
 
        /* Curiously, this test fails; the test data above compresses
         * better at default compression than at level 9. */
index a148f818dceca16bce932c323e6445df8df007d5..d0496b025b646c20f86ddffdc79f31bd20df0567 100644 (file)
@@ -81,8 +81,11 @@ DEFINE_TEST(test_write_filter_gzip_timestamp)
        archive_entry_free(ae);
        assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
        assertEqualInt(ARCHIVE_OK, archive_write_free(a));
-       failure("Timestamp should be recorded");
-       assert(memcmp(buff + 4, "\x00\x00\x00\x00", 4) != 0);
+       /* External gzip program might not save timestamp */
+       if (!use_prog) {
+               failure("Timestamp should be recorded");
+               assert(memcmp(buff + 4, "\x00\x00\x00\x00", 4) != 0);
+       }
 
        /* Test2: set "gzip:!timestamp" option. */
        assert((a = archive_write_new()) != NULL);
index 66835c8406f37cadda4dc45c8a0328af99e35d15..d386bd61e85d0e17fcdbbf29475c2e484d162789 100644 (file)
@@ -9,6 +9,7 @@
 /* Test C arg - match case-insensitive */
 DEFINE_TEST(test_C)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -19,4 +20,7 @@ DEFINE_TEST(test_C)
        assertEmptyFile("test.err");
 
        assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index 5b004d5d5707f9fdf6ab2eedb62295f77fab760c..85b43f592542be6ca879d594964166547fa1ce94 100644 (file)
@@ -9,6 +9,7 @@
 /* Test L arg - make names lowercase */
 DEFINE_TEST(test_L)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -22,4 +23,7 @@ DEFINE_TEST(test_L)
        assertTextFileContents("contents b\n", "test_basic/b");
        assertTextFileContents("contents c\n", "test_basic/c");
        assertTextFileContents("contents CAPS\n", "test_basic/caps");
+#else
+       skipping("zlib not available");
+#endif
 }
index 1f37dcd416a39405be472519a4351109aae105de..3a884aa30e5d2a93f730fe1d6b403443a50fbf8c 100644 (file)
@@ -9,6 +9,7 @@
 /* This test just does a basic zip decompression */
 DEFINE_TEST(test_basic)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -22,4 +23,7 @@ DEFINE_TEST(test_basic)
        assertTextFileContents("contents b\n", "test_basic/b");
        assertTextFileContents("contents c\n", "test_basic/c");
        assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index ea67246207f2e67ba86193f39f41fa06720c70fb..cd7c3dfd97ad04911246c96d7663451074f84c10 100644 (file)
@@ -9,6 +9,7 @@
 /* Test d arg - extract to target dir - before zipfile argument */
 DEFINE_TEST(test_d_before_zipfile)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -22,11 +23,15 @@ DEFINE_TEST(test_d_before_zipfile)
        assertTextFileContents("contents b\n", "foobar/test_basic/b");
        assertTextFileContents("contents c\n", "foobar/test_basic/c");
        assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
 
 /* Test d arg - extract to target dir - after zipfile argument */
 DEFINE_TEST(test_d_after_zipfile)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -40,4 +45,7 @@ DEFINE_TEST(test_d_after_zipfile)
        assertTextFileContents("contents b\n", "foobar/test_basic/b");
        assertTextFileContents("contents c\n", "foobar/test_basic/c");
        assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index 4467213dbb8913c2f5c8953ad0feb6ca1dfada80..db0445ec3c24795c3e3213240330ca39486eccd9 100644 (file)
@@ -9,6 +9,7 @@
 /* Test double dash arg - swallow "--" and use next argument as file name  */
 DEFINE_TEST(test_doubledash)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -22,4 +23,7 @@ DEFINE_TEST(test_doubledash)
        assertTextFileContents("contents b\n", "test_basic/b");
        assertTextFileContents("contents c\n", "test_basic/c");
        assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index b53aa16fd85c0cb4f4a1173da3223e2dd09dd45d..589ff1c55ef33136b3be98f6ca61cd84a2a34771 100644 (file)
@@ -9,6 +9,7 @@
 /* Test that the glob works */
 DEFINE_TEST(test_glob)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -22,4 +23,7 @@ DEFINE_TEST(test_glob)
        assertTextFileContents("contents b\n", "test_basic/b");
        assertFileNotExists("test_basic/c");
        assertFileNotExists("test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index b87229f42e2520e3888d23dee36e657a9b34c09e..1fba8ca207ec5c379e6980f68b12d07939bbef47 100644 (file)
@@ -9,6 +9,7 @@
 /* Test j arg - don't make directories */
 DEFINE_TEST(test_j)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -22,4 +23,7 @@ DEFINE_TEST(test_j)
        assertTextFileContents("contents b\n", "b");
        assertTextFileContents("contents c\n", "c");
        assertTextFileContents("contents CAPS\n", "CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index bb75c5d7696dc09a3e3e826bbf48b52df062423f..a13623ce23dffa5929a9a79ce1c1eb39e55bf5b6 100644 (file)
@@ -9,6 +9,7 @@
 /* Test n arg - don't overwrite existing files */
 DEFINE_TEST(test_n)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -26,4 +27,7 @@ DEFINE_TEST(test_n)
        assertTextFileContents("orig b\n", "test_basic/b");
        assertTextFileContents("contents c\n", "test_basic/c");
        assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index 64f9467744406f66b3e7c4fead32756a475f718a..8c48348c41a47d14320e321854d214f1eef38e4f 100644 (file)
@@ -9,6 +9,7 @@
 /* Test o arg - overwrite existing files */
 DEFINE_TEST(test_o)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -25,4 +26,7 @@ DEFINE_TEST(test_o)
        assertTextFileContents("contents b\n", "test_basic/b");
        assertTextFileContents("contents c\n", "test_basic/c");
        assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index 8bfffbe5dc390c9799e5b0a74586eab27e9926e5..13a7765463ec2e0a7bee657941df61f09d74bc1d 100644 (file)
@@ -9,6 +9,7 @@
 /* Test p arg - Print to stdout */
 DEFINE_TEST(test_p)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -17,4 +18,7 @@ DEFINE_TEST(test_p)
        assertEqualInt(0, r);
        assertTextFileContents("contents a\ncontents b\ncontents c\ncontents CAPS\n", "test.out");
        assertEmptyFile("test.err");
+#else
+       skipping("zlib not available");
+#endif
 }
index 13222a48399229d27640fbfb2b7f4eb1c228fe97..0579e8028d76803d725473fd0050f873b53a346c 100644 (file)
@@ -9,6 +9,7 @@
 /* Test q arg - Quiet */
 DEFINE_TEST(test_q)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -22,4 +23,7 @@ DEFINE_TEST(test_q)
        assertTextFileContents("contents b\n", "test_basic/b");
        assertTextFileContents("contents c\n", "test_basic/c");
        assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
index a72811f046d96b730fe11955079b49cb7f8163ba..a5a35ecacc4d6c7d5a17fa3c64a4089dc03595b7 100644 (file)
@@ -9,6 +9,7 @@
 /* Ensure single-file zips work */
 DEFINE_TEST(test_singlefile)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_singlefile.zip";
        int r;
 
@@ -19,4 +20,7 @@ DEFINE_TEST(test_singlefile)
        assertEmptyFile("test.err");
 
        assertTextFileContents("hello\n", "file.txt");
+#else
+       skipping("zlib not available");
+#endif
 }
index 55a516fc636f5936335b2f017e3061c814ebdee3..7565830915c3ce83069fe6b1d1bcd1261d89cc07 100644 (file)
@@ -9,6 +9,7 @@
 /* Test t arg - Test zip contents */
 DEFINE_TEST(test_t)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -17,4 +18,7 @@ DEFINE_TEST(test_t)
        assertEqualInt(0, r);
        assertNonEmptyFile("test.out");
        assertEmptyFile("test.err");
+#else
+       skipping("zlib not available");
+#endif
 }
index 959beb1950dfafdb29bd615d761eee60a6b6335a..43a2085dc5b24b80c4defda592feafcd99b78351 100644 (file)
@@ -9,6 +9,7 @@
 /* Test x arg with single exclude path */
 DEFINE_TEST(test_x_single)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -22,11 +23,15 @@ DEFINE_TEST(test_x_single)
        assertTextFileContents("contents b\n", "test_basic/b");
        assertFileNotExists("test_basic/c");
        assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
 
 /* Test x arg with multiple exclude paths */
 DEFINE_TEST(test_x_multiple)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -40,11 +45,15 @@ DEFINE_TEST(test_x_multiple)
        assertFileNotExists("test_basic/b");
        assertFileNotExists("test_basic/c");
        assertTextFileContents("contents CAPS\n", "test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }
 
 /* Test x arg with multiple exclude paths and a d arg afterwards */
 DEFINE_TEST(test_x_multiple_with_d)
 {
+#ifdef HAVE_LIBZ
        const char *reffile = "test_basic.zip";
        int r;
 
@@ -58,4 +67,7 @@ DEFINE_TEST(test_x_multiple_with_d)
        assertFileNotExists("foobar/test_basic/b");
        assertFileNotExists("foobar/test_basic/c");
        assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS");
+#else
+       skipping("zlib not available");
+#endif
 }