]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix test failure without zlib.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 13 Oct 2014 08:03:59 +0000 (17:03 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 13 Oct 2014 08:03:59 +0000 (17:03 +0900)
libarchive/test/test_read_format_zip_traditional_encryption_data.c
libarchive/test/test_read_format_zip_winzip_aes.c
libarchive/test/test_read_format_zip_winzip_aes_large.c

index 531dcaaacef1c824b564750a4b26747d01941ba2..a88050cfc2778eae9ec71ddde8b368b22ef1a1f5 100644 (file)
 #include "test.h"
 __FBSDID("$FreeBSD$");
 
+#ifdef HAVE_LIBZ
+static const int libz_enabled = 1;
+#else
+static const int libz_enabled = 0;
+#endif
+
 DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
 {
        /* This file is password protected (Traditional PKWARE Enctypted).
@@ -124,7 +130,15 @@ DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
        assertEqualInt(1, archive_entry_is_data_encrypted(ae));
        assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
        assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
-       assertEqualInt(495, archive_read_data(a, buff, sizeof(buff)));
+       if (libz_enabled) {
+               assertEqualInt(495, archive_read_data(a, buff, sizeof(buff)));
+       } else {
+               assertEqualInt(ARCHIVE_FAILED,
+                   archive_read_data(a, buff, sizeof(buff)));
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method (deflation)");
+               assert(archive_errno(a) != 0);
+       }
        
        /* Verify encrypted file "foo.txt" */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -134,7 +148,15 @@ DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
        assertEqualInt(1, archive_entry_is_data_encrypted(ae));
        assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
        assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
-       assertEqualInt(495, archive_read_data(a, buff, sizeof(buff)));
+       if (libz_enabled) {
+               assertEqualInt(495, archive_read_data(a, buff, sizeof(buff)));
+       } else {
+               assertEqualInt(ARCHIVE_FAILED,
+                   archive_read_data(a, buff, sizeof(buff)));
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method (deflation)");
+               assert(archive_errno(a) != 0);
+       }
        
        assertEqualInt(2, archive_file_count(a));
 
index 3f856131028a89a080b6b127a4158aa1dfae6a61..6ffbc1dd0cb502f00984fcb1814cd1807e617cd8 100644 (file)
 #include "test.h"
 __FBSDID("$FreeBSD$");
 
+#ifdef HAVE_LIBZ
+static const int libz_enabled = 1;
+#else
+static const int libz_enabled = 0;
+#endif
+
 static void
-test_winzip_aes(const char *refname)
+test_winzip_aes(const char *refname, int need_libz)
 {
        struct archive_entry *ae;
        struct archive *a;
@@ -110,7 +116,14 @@ test_winzip_aes(const char *refname)
        assertEqualInt(1, archive_entry_is_data_encrypted(ae));
        assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
        assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
-       assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       if (!need_libz || libz_enabled) {
+               assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       } else {
+               assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, 19));
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method (deflation)");
+               assert(archive_errno(a) != 0);
+       }
        
        assertEqualInt(1, archive_file_count(a));
 
@@ -129,17 +142,17 @@ test_winzip_aes(const char *refname)
 DEFINE_TEST(test_read_format_zip_winzip_aes128)
 {
        /* WinZip AES-128 encryption. */
-       test_winzip_aes("test_read_format_zip_winzip_aes128.zip");
+       test_winzip_aes("test_read_format_zip_winzip_aes128.zip", 1);
 }
 
 DEFINE_TEST(test_read_format_zip_winzip_aes256)
 {
        /* WinZip AES-256 encryption. */
-       test_winzip_aes("test_read_format_zip_winzip_aes256.zip");
+       test_winzip_aes("test_read_format_zip_winzip_aes256.zip", 1);
 }
 
 DEFINE_TEST(test_read_format_zip_winzip_aes256_stored)
 {
        /* WinZip AES-256 encryption with stored data. */
-       test_winzip_aes("test_read_format_zip_winzip_aes256_stored.zip");
+       test_winzip_aes("test_read_format_zip_winzip_aes256_stored.zip", 0);
 }
index 4027fc0eaf98f825c4e805eefeef4f0bee506668..aeaca7df9cc36a724b735b472c41ca02abcf154c 100644 (file)
 #include "test.h"
 __FBSDID("$FreeBSD$");
 
+#ifdef HAVE_LIBZ
+static const int libz_enabled = 1;
+#else
+static const int libz_enabled = 0;
+#endif
+
 DEFINE_TEST(test_read_format_zip_winzip_aes256_large)
 {
        const char *refname = "test_read_format_zip_winzip_aes256_large.zip";
@@ -137,7 +143,15 @@ DEFINE_TEST(test_read_format_zip_winzip_aes256_large)
        assertEqualInt(1, archive_entry_is_data_encrypted(ae));
        assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
        assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
-       assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       if (libz_enabled) {
+               assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       } else {
+               assertEqualInt(ARCHIVE_FAILED,
+                       archive_read_data(a, buff, sizeof(buff)));
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method (deflation)");
+               assert(archive_errno(a) != 0);
+       }
 
        /* Verify encrypted file "NEWS" */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -147,7 +161,15 @@ DEFINE_TEST(test_read_format_zip_winzip_aes256_large)
        assertEqualInt(1, archive_entry_is_data_encrypted(ae));
        assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
        assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
-       assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       if (libz_enabled) {
+               assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       } else {
+               assertEqualInt(ARCHIVE_FAILED,
+                       archive_read_data(a, buff, sizeof(buff)));
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method (deflation)");
+               assert(archive_errno(a) != 0);
+       }
 
        /* Verify encrypted file "README" */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -157,7 +179,15 @@ DEFINE_TEST(test_read_format_zip_winzip_aes256_large)
        assertEqualInt(1, archive_entry_is_data_encrypted(ae));
        assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
        assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
-       assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       if (libz_enabled) {
+               assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       } else {
+               assertEqualInt(ARCHIVE_FAILED,
+                       archive_read_data(a, buff, sizeof(buff)));
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method (deflation)");
+               assert(archive_errno(a) != 0);
+       }
 
        /* Verify encrypted file "config.h" */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -167,7 +197,15 @@ DEFINE_TEST(test_read_format_zip_winzip_aes256_large)
        assertEqualInt(1, archive_entry_is_data_encrypted(ae));
        assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
        assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
-       assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       if (libz_enabled) {
+               assertEqualInt(512, archive_read_data(a, buff, sizeof(buff)));
+       } else {
+               assertEqualInt(ARCHIVE_FAILED,
+                       archive_read_data(a, buff, sizeof(buff)));
+               assertEqualString(archive_error_string(a),
+                   "Unsupported ZIP compression method (deflation)");
+               assert(archive_errno(a) != 0);
+       }
        
        assertEqualInt(4, archive_file_count(a));