Fix test failure without zlib.

This commit is contained in:
Michihiro NAKAJIMA committed 2014-10-13 17:03:59 +09:00
1 parent 481b432ec1
commit d095d6a488
3 files changed
+84 -11

No files matched your search

@@ -26,6 +26,12 @@
#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));
@@ -26,8 +26,14 @@
#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);
}
@@ -26,6 +26,12 @@
#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));