aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libarchive/libarchive/test
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libarchive/libarchive/test')
-rw-r--r--contrib/libarchive/libarchive/test/test_archive_read_next_header_empty.c26
-rw-r--r--contrib/libarchive/libarchive/test/test_archive_read_support.c47
-rw-r--r--contrib/libarchive/libarchive/test/test_archive_string_conversion.c79
-rw-r--r--contrib/libarchive/libarchive/test/test_entry.c89
-rw-r--r--contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_mtree.c74
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu22
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_raw.c5
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip.c32
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_7z_lzma.zip.uu45
-rw-r--r--contrib/libarchive/libarchive/test/test_read_set_format.c25
-rw-r--r--contrib/libarchive/libarchive/test/test_write_disk_secure.c34
-rw-r--r--contrib/libarchive/libarchive/test/test_write_format_cpio.c20
-rw-r--r--contrib/libarchive/libarchive/test/test_write_format_warc.c28
14 files changed, 476 insertions, 52 deletions
diff --git a/contrib/libarchive/libarchive/test/test_archive_read_next_header_empty.c b/contrib/libarchive/libarchive/test/test_archive_read_next_header_empty.c
index f650bccce89b..f43cbd934288 100644
--- a/contrib/libarchive/libarchive/test/test_archive_read_next_header_empty.c
+++ b/contrib/libarchive/libarchive/test/test_archive_read_next_header_empty.c
@@ -44,14 +44,9 @@ test_empty_file1(void)
}
static void
-test_empty_file2(void)
+test_empty_file2_check(struct archive* a)
{
- struct archive* a = archive_read_new();
struct archive_entry* e;
-
- /* Try opening an empty file with raw and empty handlers. */
- assertEqualInt(ARCHIVE_OK, archive_read_support_format_raw(a));
- assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
assertEqualInt(0, archive_errno(a));
assertEqualString(NULL, archive_error_string(a));
@@ -67,6 +62,25 @@ test_empty_file2(void)
}
static void
+test_empty_file2(void)
+{
+ struct archive* a = archive_read_new();
+
+ /* Try opening an empty file with raw and empty handlers. */
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_raw(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
+ test_empty_file2_check(a);
+
+ a = archive_read_new();
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_by_code(a, ARCHIVE_FORMAT_EMPTY));
+ test_empty_file2_check(a);
+
+ a = archive_read_new();
+ assertEqualInt(ARCHIVE_OK, archive_read_set_format(a, ARCHIVE_FORMAT_EMPTY));
+ test_empty_file2_check(a);
+}
+
+static void
test_empty_tarfile(void)
{
struct archive* a = archive_read_new();
diff --git a/contrib/libarchive/libarchive/test/test_archive_read_support.c b/contrib/libarchive/libarchive/test/test_archive_read_support.c
index 1619b0729e94..6d213c409bf2 100644
--- a/contrib/libarchive/libarchive/test/test_archive_read_support.c
+++ b/contrib/libarchive/libarchive/test/test_archive_read_support.c
@@ -35,6 +35,17 @@ typedef struct archive *constructor(void);
typedef int enabler(struct archive *);
typedef int destructor(struct archive *);
+static int format_code = 0;
+static int format_code_enabler(struct archive *a)
+{
+ return archive_read_support_format_by_code(a, format_code);
+}
+
+static int format_code_setter(struct archive *a)
+{
+ return archive_read_set_format(a, format_code);
+}
+
static void
test_success(constructor new_, enabler enable_, destructor free_)
{
@@ -85,6 +96,42 @@ DEFINE_TEST(test_archive_read_support)
test_filter_or_format(archive_read_support_format_xar);
test_filter_or_format(archive_read_support_format_zip);
+ int format_codes[] = {
+ ARCHIVE_FORMAT_CPIO,
+ ARCHIVE_FORMAT_CPIO_POSIX,
+ ARCHIVE_FORMAT_CPIO_BIN_LE,
+ ARCHIVE_FORMAT_CPIO_BIN_BE,
+ ARCHIVE_FORMAT_CPIO_SVR4_NOCRC,
+ ARCHIVE_FORMAT_CPIO_SVR4_CRC,
+ ARCHIVE_FORMAT_CPIO_AFIO_LARGE,
+ ARCHIVE_FORMAT_TAR,
+ ARCHIVE_FORMAT_TAR_USTAR,
+ ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE,
+ ARCHIVE_FORMAT_TAR_PAX_RESTRICTED,
+ ARCHIVE_FORMAT_TAR_GNUTAR,
+ ARCHIVE_FORMAT_ISO9660,
+ ARCHIVE_FORMAT_ISO9660_ROCKRIDGE,
+ ARCHIVE_FORMAT_ZIP,
+ ARCHIVE_FORMAT_EMPTY,
+ ARCHIVE_FORMAT_AR,
+ ARCHIVE_FORMAT_AR_GNU,
+ ARCHIVE_FORMAT_AR_BSD,
+ ARCHIVE_FORMAT_MTREE,
+ ARCHIVE_FORMAT_RAW,
+ ARCHIVE_FORMAT_XAR,
+ ARCHIVE_FORMAT_LHA,
+ ARCHIVE_FORMAT_CAB,
+ ARCHIVE_FORMAT_RAR,
+ ARCHIVE_FORMAT_7ZIP,
+ ARCHIVE_FORMAT_WARC,
+ ARCHIVE_FORMAT_RAR_V5,
+ };
+ for (unsigned i = 0; i < sizeof(format_codes) / sizeof(int); i++) {
+ format_code = format_codes[i];
+ test_filter_or_format(format_code_enabler);
+ test_filter_or_format(format_code_setter);
+ }
+
test_filter_or_format(archive_read_support_filter_all);
test_filter_or_format(archive_read_support_filter_bzip2);
test_filter_or_format(archive_read_support_filter_compress);
diff --git a/contrib/libarchive/libarchive/test/test_archive_string_conversion.c b/contrib/libarchive/libarchive/test/test_archive_string_conversion.c
index e86f97c8a492..fb5359b6f349 100644
--- a/contrib/libarchive/libarchive/test/test_archive_string_conversion.c
+++ b/contrib/libarchive/libarchive/test/test_archive_string_conversion.c
@@ -445,7 +445,7 @@ test_archive_string_normalization_nfc(const char *testdata)
assertEqualInt(0,
archive_mstring_copy_wcs(&mstr, wc_nfc));
assertEqualInt(0, archive_mstring_get_mbs_l(
- &mstr, &mp, &mplen, t_sconv8));
+ a, &mstr, &mp, &mplen, t_sconv8));
failure("WCS NFC(%s) should be UTF-8 NFC:%d"
,nfc, line);
assertEqualUTF8String(utf8_nfc, mp);
@@ -695,7 +695,7 @@ test_archive_string_normalization_mac_nfd(const char *testdata)
assertEqualInt(0, archive_mstring_copy_wcs(
&mstr, wc_nfd));
assertEqualInt(0, archive_mstring_get_mbs_l(
- &mstr, &mp, &mplen, t_sconv8));
+ a, &mstr, &mp, &mplen, t_sconv8));
failure("WCS NFD(%s) should be UTF-8 NFD:%d"
,nfd, line);
assertEqualUTF8String(utf8_nfd, mp);
@@ -777,6 +777,80 @@ test_archive_string_canonicalization(void)
}
+static void
+check_string(struct archive *a, struct archive_mstring *mstr, struct archive_string_conv *sc,
+ const char *exp, const wchar_t *wexp)
+{
+ /* Do all the tests on a copy so that we can have a clear initial state every time */
+ struct archive_mstring mstr2;
+ const char *p = NULL;
+ const wchar_t *wp = NULL;
+ size_t len = 0;
+
+ memset(&mstr2, 0, sizeof(mstr2));
+
+ archive_mstring_copy(&mstr2, mstr);
+ assertEqualInt(0, archive_mstring_get_mbs(a, &mstr2, &p));
+ assertEqualString(exp, p);
+ p = NULL;
+
+ archive_mstring_copy(&mstr2, mstr);
+ assertEqualInt(0, archive_mstring_get_utf8(a, &mstr2, &p));
+ assertEqualString(exp, p);
+ p = NULL;
+
+ archive_mstring_copy(&mstr2, mstr);
+ assertEqualInt(0, archive_mstring_get_wcs(a, &mstr2, &wp));
+ assertEqualWString(wexp, wp);
+ wp = NULL;
+
+ archive_mstring_copy(&mstr2, mstr);
+ assertEqualInt(0, archive_mstring_get_mbs_l(a, &mstr2, &p, &len, sc));
+ assertEqualString(exp, p);
+ assertEqualInt(len, strlen(exp));
+ p = NULL;
+ len = 0;
+
+ archive_mstring_clean(&mstr2);
+}
+
+/*
+ * Make sure no matter what the input encoding is, the string can be
+ * converted too all the output encodings.
+ */
+static void
+test_archive_string_set_get(void)
+{
+ struct archive *a;
+ struct archive_mstring mstr;
+ struct archive_string_conv *sc;
+
+ setlocale(LC_ALL, "en_US.UTF-8");
+
+ assert((a = archive_read_new()) != NULL);
+ memset(&mstr, 0, sizeof(mstr));
+
+ assertA(NULL != (sc =
+ archive_string_conversion_to_charset(a, "UTF-8", 1)));
+ failure("Charset name should be UTF-8");
+ assertEqualString("UTF-8",
+ archive_string_conversion_charset_name(sc));
+
+ assertEqualInt(0, archive_mstring_copy_mbs(&mstr, "AAA"));
+ check_string(a, &mstr, sc, "AAA", L"AAA");
+ assertEqualInt(4, archive_mstring_copy_utf8(&mstr, "BBBB"));
+ check_string(a, &mstr, sc, "BBBB", L"BBBB");
+ assertEqualInt(0, archive_mstring_copy_wcs(&mstr, L"CCC12"));
+ check_string(a, &mstr, sc, "CCC12", L"CCC12");
+ assertEqualInt(0, archive_mstring_copy_mbs_len_l(&mstr, "DDDD-l", 6, sc));
+ check_string(a, &mstr, sc, "DDDD-l", L"DDDD-l");
+ assertEqualInt(0, archive_mstring_update_utf8(a, &mstr, "EEEEE---H"));
+ check_string(a, &mstr, sc, "EEEEE---H", L"EEEEE---H");
+
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+}
+
DEFINE_TEST(test_archive_string_conversion)
{
static const char reffile[] = "test_archive_string_conversion.txt.Z";
@@ -807,4 +881,5 @@ DEFINE_TEST(test_archive_string_conversion)
test_archive_string_normalization_nfc(testdata);
test_archive_string_normalization_mac_nfd(testdata);
test_archive_string_canonicalization();
+ test_archive_string_set_get();
}
diff --git a/contrib/libarchive/libarchive/test/test_entry.c b/contrib/libarchive/libarchive/test/test_entry.c
index 3fb17d3645a1..a5777b148711 100644
--- a/contrib/libarchive/libarchive/test/test_entry.c
+++ b/contrib/libarchive/libarchive/test/test_entry.c
@@ -177,31 +177,60 @@ DEFINE_TEST(test_entry)
/* gname */
archive_entry_set_gname(e, "group");
assertEqualString(archive_entry_gname(e), "group");
+ assertEqualString(archive_entry_gname_utf8(e), "group");
+ assertEqualWString(archive_entry_gname_w(e), L"group");
wcscpy(wbuff, L"wgroup");
archive_entry_copy_gname_w(e, wbuff);
assertEqualWString(archive_entry_gname_w(e), L"wgroup");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_gname_w(e), L"wgroup");
+ assertEqualString(archive_entry_gname_utf8(e), "wgroup");
+ assertEqualString(archive_entry_gname(e), "wgroup");
+ archive_entry_set_gname_utf8(e, "group");
+ assertEqualString(archive_entry_gname_utf8(e), "group");
+ assertEqualWString(archive_entry_gname_w(e), L"group");
+ assertEqualString(archive_entry_gname(e), "group");
+ archive_entry_update_gname_utf8(e, "group2");
+ assertEqualString(archive_entry_gname_utf8(e), "group2");
+ assertEqualWString(archive_entry_gname_w(e), L"group2");
+ assertEqualString(archive_entry_gname(e), "group2");
/* hardlink */
archive_entry_set_hardlink(e, "hardlinkname");
assertEqualString(archive_entry_hardlink(e), "hardlinkname");
+ assertEqualString(archive_entry_hardlink_utf8(e), "hardlinkname");
+ assertEqualWString(archive_entry_hardlink_w(e), L"hardlinkname");
strcpy(buff, "hardlinkname2");
archive_entry_copy_hardlink(e, buff);
assertEqualString(archive_entry_hardlink(e), "hardlinkname2");
+ assertEqualWString(archive_entry_hardlink_w(e), L"hardlinkname2");
+ assertEqualString(archive_entry_hardlink_utf8(e), "hardlinkname2");
memset(buff, 0, sizeof(buff));
assertEqualString(archive_entry_hardlink(e), "hardlinkname2");
+ assertEqualString(archive_entry_hardlink_utf8(e), "hardlinkname2");
+ assertEqualWString(archive_entry_hardlink_w(e), L"hardlinkname2");
archive_entry_copy_hardlink(e, NULL);
assertEqualString(archive_entry_hardlink(e), NULL);
assertEqualWString(archive_entry_hardlink_w(e), NULL);
+ assertEqualString(archive_entry_hardlink_utf8(e), NULL);
wcscpy(wbuff, L"whardlink");
archive_entry_copy_hardlink_w(e, wbuff);
assertEqualWString(archive_entry_hardlink_w(e), L"whardlink");
+ assertEqualString(archive_entry_hardlink_utf8(e), "whardlink");
+ assertEqualString(archive_entry_hardlink(e), "whardlink");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_hardlink_w(e), L"whardlink");
archive_entry_copy_hardlink_w(e, NULL);
assertEqualString(archive_entry_hardlink(e), NULL);
assertEqualWString(archive_entry_hardlink_w(e), NULL);
+ archive_entry_set_hardlink_utf8(e, "hardlinkname");
+ assertEqualString(archive_entry_hardlink_utf8(e), "hardlinkname");
+ assertEqualWString(archive_entry_hardlink_w(e), L"hardlinkname");
+ assertEqualString(archive_entry_hardlink(e), "hardlinkname");
+ archive_entry_update_hardlink_utf8(e, "hardlinkname2");
+ assertEqualString(archive_entry_hardlink_utf8(e), "hardlinkname2");
+ assertEqualWString(archive_entry_hardlink_w(e), L"hardlinkname2");
+ assertEqualString(archive_entry_hardlink(e), "hardlinkname2");
/* ino */
assert(!archive_entry_ino_is_set(e));
@@ -270,18 +299,38 @@ DEFINE_TEST(test_entry)
/* pathname */
archive_entry_set_pathname(e, "path");
assertEqualString(archive_entry_pathname(e), "path");
+ assertEqualString(archive_entry_pathname_utf8(e), "path");
+ assertEqualWString(archive_entry_pathname_w(e), L"path");
archive_entry_set_pathname(e, "path");
assertEqualString(archive_entry_pathname(e), "path");
+ assertEqualWString(archive_entry_pathname_w(e), L"path");
+ assertEqualString(archive_entry_pathname_utf8(e), "path");
strcpy(buff, "path2");
archive_entry_copy_pathname(e, buff);
assertEqualString(archive_entry_pathname(e), "path2");
+ assertEqualWString(archive_entry_pathname_w(e), L"path2");
+ assertEqualString(archive_entry_pathname_utf8(e), "path2");
memset(buff, 0, sizeof(buff));
assertEqualString(archive_entry_pathname(e), "path2");
+ assertEqualString(archive_entry_pathname_utf8(e), "path2");
+ assertEqualWString(archive_entry_pathname_w(e), L"path2");
wcscpy(wbuff, L"wpath");
archive_entry_copy_pathname_w(e, wbuff);
assertEqualWString(archive_entry_pathname_w(e), L"wpath");
+ assertEqualString(archive_entry_pathname_utf8(e), "wpath");
+ assertEqualString(archive_entry_pathname(e), "wpath");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_pathname_w(e), L"wpath");
+ assertEqualString(archive_entry_pathname(e), "wpath");
+ assertEqualString(archive_entry_pathname_utf8(e), "wpath");
+ archive_entry_set_pathname_utf8(e, "path");
+ assertEqualWString(archive_entry_pathname_w(e), L"path");
+ assertEqualString(archive_entry_pathname(e), "path");
+ assertEqualString(archive_entry_pathname_utf8(e), "path");
+ archive_entry_update_pathname_utf8(e, "path2");
+ assertEqualWString(archive_entry_pathname_w(e), L"path2");
+ assertEqualString(archive_entry_pathname(e), "path2");
+ assertEqualString(archive_entry_pathname_utf8(e), "path2");
/* rdev */
archive_entry_set_rdev(e, 532);
@@ -302,19 +351,37 @@ DEFINE_TEST(test_entry)
/* symlink */
archive_entry_set_symlink(e, "symlinkname");
assertEqualString(archive_entry_symlink(e), "symlinkname");
+ assertEqualString(archive_entry_symlink_utf8(e), "symlinkname");
+ assertEqualWString(archive_entry_symlink_w(e), L"symlinkname");
strcpy(buff, "symlinkname2");
archive_entry_copy_symlink(e, buff);
assertEqualString(archive_entry_symlink(e), "symlinkname2");
+ assertEqualWString(archive_entry_symlink_w(e), L"symlinkname2");
+ assertEqualString(archive_entry_symlink_utf8(e), "symlinkname2");
memset(buff, 0, sizeof(buff));
assertEqualString(archive_entry_symlink(e), "symlinkname2");
+ assertEqualString(archive_entry_symlink_utf8(e), "symlinkname2");
+ assertEqualWString(archive_entry_symlink_w(e), L"symlinkname2");
archive_entry_copy_symlink_w(e, NULL);
assertEqualWString(archive_entry_symlink_w(e), NULL);
assertEqualString(archive_entry_symlink(e), NULL);
+ assertEqualString(archive_entry_symlink_utf8(e), NULL);
archive_entry_copy_symlink_w(e, L"wsymlink");
assertEqualWString(archive_entry_symlink_w(e), L"wsymlink");
+ assertEqualString(archive_entry_symlink_utf8(e), "wsymlink");
+ assertEqualString(archive_entry_symlink(e), "wsymlink");
archive_entry_copy_symlink(e, NULL);
assertEqualWString(archive_entry_symlink_w(e), NULL);
assertEqualString(archive_entry_symlink(e), NULL);
+ assertEqualString(archive_entry_symlink_utf8(e), NULL);
+ archive_entry_set_symlink_utf8(e, "symlinkname");
+ assertEqualWString(archive_entry_symlink_w(e), L"symlinkname");
+ assertEqualString(archive_entry_symlink(e), "symlinkname");
+ assertEqualString(archive_entry_symlink_utf8(e), "symlinkname");
+ archive_entry_update_symlink_utf8(e, "symlinkname2");
+ assertEqualWString(archive_entry_symlink_w(e), L"symlinkname2");
+ assertEqualString(archive_entry_symlink(e), "symlinkname2");
+ assertEqualString(archive_entry_symlink_utf8(e), "symlinkname2");
/* uid */
archive_entry_set_uid(e, 83);
@@ -323,11 +390,27 @@ DEFINE_TEST(test_entry)
/* uname */
archive_entry_set_uname(e, "user");
assertEqualString(archive_entry_uname(e), "user");
+ assertEqualString(archive_entry_uname_utf8(e), "user");
+ assertEqualWString(archive_entry_uname_w(e), L"user");
wcscpy(wbuff, L"wuser");
- archive_entry_copy_gname_w(e, wbuff);
- assertEqualWString(archive_entry_gname_w(e), L"wuser");
+ archive_entry_copy_uname_w(e, wbuff);
+ assertEqualWString(archive_entry_uname_w(e), L"wuser");
memset(wbuff, 0, sizeof(wbuff));
- assertEqualWString(archive_entry_gname_w(e), L"wuser");
+ assertEqualWString(archive_entry_uname_w(e), L"wuser");
+ assertEqualString(archive_entry_uname_utf8(e), "wuser");
+ assertEqualString(archive_entry_uname(e), "wuser");
+ archive_entry_set_uname_utf8(e, "user");
+ assertEqualString(archive_entry_uname_utf8(e), "user");
+ assertEqualWString(archive_entry_uname_w(e), L"user");
+ assertEqualString(archive_entry_uname(e), "user");
+ archive_entry_set_uname_utf8(e, "user");
+ assertEqualWString(archive_entry_uname_w(e), L"user");
+ assertEqualString(archive_entry_uname(e), "user");
+ assertEqualString(archive_entry_uname_utf8(e), "user");
+ archive_entry_update_uname_utf8(e, "user2");
+ assertEqualWString(archive_entry_uname_w(e), L"user2");
+ assertEqualString(archive_entry_uname(e), "user2");
+ assertEqualString(archive_entry_uname_utf8(e), "user2");
/* Test fflags interface. */
archive_entry_set_fflags(e, 0x55, 0xAA);
diff --git a/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c b/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c
index bbfe91ab8e5e..9efa74281b12 100644
--- a/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c
+++ b/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c
@@ -1833,6 +1833,8 @@ test_parent(void)
}
assertChdir("..");
+ assertChmod("lock", 0755);
+ assertChmod("lock/lock2", 0755);
/* Destroy the disk object. */
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
diff --git a/contrib/libarchive/libarchive/test/test_read_format_mtree.c b/contrib/libarchive/libarchive/test/test_read_format_mtree.c
index 865dda87463b..7e8b5701540c 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_mtree.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_mtree.c
@@ -196,8 +196,80 @@ test_read_format_mtree1(void)
assertEqualInt(archive_entry_is_encrypted(ae), 0);
assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
+ /* md5digest */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/md5file");
+ assertEqualMem(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_MD5),
+ "\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e",
+ 16);
+
+ /* rmd160digest */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/rmd160file");
+ assertEqualMem(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_RMD160),
+ "\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90"
+ "\xaf\xd8\x07\x09", 20);
+
+ /* sha1digest */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/sha1file");
+ assertEqualMem(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_SHA1),
+ "\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90"
+ "\xaf\xd8\x07\x09", 20);
+
+ /* sha256digest */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/sha256file");
+ assertEqualMem(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_SHA256),
+ "\xe3\xb0\xc4\x42\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
+ "\x27\xae\x41\xe4\x64\x9b\x93\x4c\xa4\x95\x99\x1b\x78\x52\xb8\x55",
+ 32);
+
+ /* sha384digest */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/sha384file");
+ assertEqualMem(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_SHA384),
+ "\x38\xb0\x60\xa7\x51\xac\x96\x38\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a"
+ "\x21\xfd\xb7\x11\x14\xbe\x07\x43\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda"
+ "\x27\x4e\xde\xbf\xe7\x6f\x65\xfb\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b",
+ 48);
+
+ /* sha512digest */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/sha512file");
+ assertEqualMem(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_SHA512),
+ "\xcf\x83\xe1\x35\x7e\xef\xb8\xbd\xf1\x54\x28\x50\xd6\x6d\x80\x07"
+ "\xd6\x20\xe4\x05\x0b\x57\x15\xdc\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
+ "\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0\xff\x83\x18\xd2\x87\x7e\xec\x2f"
+ "\x63\xb9\x31\xbd\x47\x41\x7a\x81\xa5\x38\x32\x7a\xf9\x27\xda\x3e",
+ 64);
+
+ /* md5 digest is too short */
+ assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/md5tooshort");
+ assertMemoryFilledWith(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_MD5),
+ 16, 0x00);
+
+ /* md5 digest is too long */
+ assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/md5toolong");
+ assertMemoryFilledWith(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_MD5),
+ 16, 0x00);
+
+ /* md5 digest is uppercase hex */
+ assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/md5caphex");
+ assertMemoryFilledWith(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_MD5),
+ 16, 0x00);
+
+ /* md5 digest is not hex */
+ assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "dir2/md5nothex");
+ assertMemoryFilledWith(archive_entry_digest(ae, ARCHIVE_ENTRY_DIGEST_MD5),
+ 16, 0x00);
+
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
- assertEqualInt(20, archive_file_count(a));
+ assertEqualInt(30, archive_file_count(a));
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
diff --git a/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu b/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu
index a2e47520d353..d45431b72ec9 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu
+++ b/contrib/libarchive/libarchive/test/test_read_format_mtree.mtree.uu
@@ -16,6 +16,26 @@ M<&4]9FEL92!S:7IE/3DR,C,S-S(P,S8X-30W-S4X,#<*9&ER,B]T;V]B:6=F
M:6QE('1Y<&4]9FEL92!S:7IE/3DR,C,S-S(P,S8X-30W-S4X,#@*9&ER,B]V
M97)Y;VQD9FEL92!T>7!E/69I;&4@=&EM93TM.3(R,S,W,C`S-C@U-#<W-3@P
M.`ID:7(R+W1O;V]L9&9I;&4@='EP93UF:6QE('1I;64]+3DR,C,S-S(P,S8X
-*-30W-S4X,#D*"@``
+M-30W-S4X,#D*9&ER,B]M9#5F:6QE('1Y<&4]9FEL92!M9#5D:6=E<W0]9#0Q
+M9#AC9#DX9C`P8C(P-&4Y.#`P.3DX96-F.#0R-V4@("`@("`@("`@("`@("`*
+M9&ER,B]R;60Q-C!F:6QE('1Y<&4]9FEL92!R;60Q-C!D:6=E<W0]9&$S.6$S
+M964U939B-&(P9#,R-35B9F5F.34V,#$X.3!A9F0X,#<P.2`@("`@("`@(`ID
+M:7(R+W-H83%F:6QE('1Y<&4]9FEL92!S:&$Q9&EG97-T/61A,SEA,V5E-64V
+M8C1B,&0S,C4U8F9E9CDU-C`Q.#DP869D.#`W,#D@("`@(`ID:7(R+W-H83(U
+M-F9I;&4@='EP93UF:6QE('-H83(U-F1I9V5S=#UE,V(P8S0T,CDX9F,Q8S$T
+M.6%F8F8T8S@Y.39F8CDR-#(W864T,64T-C0Y8CDS-&-A-#DU.3DQ8C<X-3)B
+M.#4U"F1I<C(O<VAA,S@T9FEL92!T>7!E/69I;&4@<VAA,S@T9&EG97-T/3,X
+M8C`V,&$W-3%A8SDV,S@T8V0Y,S(W96(Q8C%E,S9A,C%F9&(W,3$Q-&)E,#<T
+M,S1C,&-C-V)F-C-F-F4Q9&$R-S1E9&5B9F4W-F8V-69B9#4Q860R9C$T.#DX
+M8CDU8@ID:7(R+W-H834Q,F9I;&4@='EP93UF:6QE('-H834Q,F1I9V5S=#UC
+M9C@S93$S-3=E969B.&)D9C$U-#(X-3!D-C9D.#`P-V0V,C!E-#`U,&(U-S$U
+M9&,X,V8T83DR,60S-F-E.6-E-#=D,&0Q,V,U9#@U9C)B,&9F.#,Q.&0R.#<W
+M965C,F8V,V(Y,S%B9#0W-#$W83@Q834S.#,R-V%F.3(W9&$S90ID:7(R+VUD
+M-71O;W-H;W)T('1Y<&4]9FEL92!M9#5D:6=E<W0]9#0Q9#AC9#DX9C`P8C(P
+M-&4Y.#`P.3DX96-F.#0R-PID:7(R+VUD-71O;VQO;F<@='EP93UF:6QE(&UD
+M-61I9V5S=#UD-#%D.&-D.3AF,#!B,C`T93DX,#`Y.3AE8V8X-#(W96$*9&ER
+M,B]M9#5C87!H97@@='EP93UF:6QE(&UD-61I9V5S=#U$-#%$.$-$.3A&,#!"
+M,C`T13DX,#`Y.3A%0T8X-#(W10ID:7(R+VUD-6YO=&AE>"!T>7!E/69I;&4@
+K;60U9&EG97-T/7$T,60X8V0Y.&8P,&(R,#1E.3@P,#DY.&5C9C@T,C=E"@``
`
end
diff --git a/contrib/libarchive/libarchive/test/test_read_format_raw.c b/contrib/libarchive/libarchive/test/test_read_format_raw.c
index 1c49c7880018..58a341c02226 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_raw.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_raw.c
@@ -72,7 +72,7 @@ DEFINE_TEST(test_read_format_raw)
extract_reference_file(reffile2);
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_raw(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_by_code(a, ARCHIVE_FORMAT_RAW));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_filename(a, reffile2, 1));
@@ -100,8 +100,7 @@ DEFINE_TEST(test_read_format_raw)
extract_reference_file(reffile3);
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_raw(a));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_set_format(a, ARCHIVE_FORMAT_RAW));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_filename(a, reffile3, 1));
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip.c b/contrib/libarchive/libarchive/test/test_read_format_zip.c
index ab99b0a8d92d..3bb4d7467ac6 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip.c
@@ -966,3 +966,35 @@ DEFINE_TEST(test_read_format_zip_lzma_stream_end_blockread)
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
}
+
+DEFINE_TEST(test_read_format_zip_7z_lzma)
+{
+ const char *refname = "test_read_format_zip_7z_lzma.zip";
+ struct archive_entry *ae;
+ struct archive *a;
+
+ assert((a = archive_read_new()) != NULL);
+ if (ARCHIVE_OK != archive_read_support_filter_lzma(a)) {
+ skipping("lzma reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ return;
+ }
+ extract_reference_file(refname);
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+ //read directories
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ //read symlink
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("../samples/abc_measurement_analysis_sample"
+ "/src/abc_measurement_analysis_sample.py",
+ archive_entry_symlink(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_7z_lzma.zip.uu b/contrib/libarchive/libarchive/test/test_read_format_zip_7z_lzma.zip.uu
new file mode 100644
index 000000000000..8ae8df41eaae
--- /dev/null
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_7z_lzma.zip.uu
@@ -0,0 +1,45 @@
+begin 644 test_read_format_zip_7z_lzma.zip
+M4$L#!`H#`````.$#)%$````````````````,````7VEN<W1A;&QD:7(O4$L#
+M!`H#`````,0#)%$````````````````6````7VEN<W1A;&QD:7(O86)C7W1O
+M;VQS+U!+`P0*`P````"``R11````````````````)````%]I;G-T86QL9&ER
+M+V%B8U]T;V]L<R\R,#`P+CDM8F5T83$Q+U!+`P0*`P````"%!"11````````
+M````````*````%]I;G-T86QL9&ER+V%B8U]T;V]L<R\R,#`P+CDM8F5T83$Q
+M+V)I;B]02P,$%`,```X`?00D4<2?]W$]````40```$<```!?:6YS=&%L;&1I
+M<B]A8F-?=&]O;',O,C`P,"XY+6)E=&$Q,2]B:6XO86)C7VUE87-U<F5M96YT
+M7V%N86QY<VES7W-A;7!L900]!0!=````!``78+CF838[WSK=V4<NKP&%(\A'
+MDM]PR'OV^=/9>A79\GCDS+I*=O.=!+"5(),_1O%5^1102P,$"@,`````]0,D
+M40```````````````"P```!?:6YS=&%L;&1I<B]A8F-?=&]O;',O,C`P,"XY
+M+6)E=&$Q,2]S86UP;&5S+U!+`P0*`P````!J`R11````````````````3```
+M`%]I;G-T86QL9&ER+V%B8U]T;V]L<R\R,#`P+CDM8F5T83$Q+W-A;7!L97,O
+M86)C7VUE87-U<F5M96YT7V%N86QY<VES7W-A;7!L92]02P,$"@,`````R00D
+M40```````````````%````!?:6YS=&%L;&1I<B]A8F-?=&]O;',O,C`P,"XY
+M+6)E=&$Q,2]S86UP;&5S+V%B8U]M96%S=7)E;65N=%]A;F%L>7-I<U]S86UP
+M;&4O<W)C+U!+`P04`P``#@#)!"11&O[CEV0```#Z````<@```%]I;G-T86QL
+M9&ER+V%B8U]T;V]L<R\R,#`P+CDM8F5T83$Q+W-A;7!L97,O86)C7VUE87-U
+M<F5M96YT7V%N86QY<VES7W-A;7!L92]S<F,O86)C7VUE87-U<F5M96YT7V%N
+M86QY<VES7W-A;7!L92YP>00]!0!=````!``1B$)'BB,SPW</,_U5E^VGQ_#J
+M*D,VRB^`L-1YB&E9ZQ@#)Z;.!DA4-N"JARAW#NR&V]%F']BN`WU@#,0-<1)%
+M/6DBM+7=&`\IF.F\E3\E9D*1:/'I+057:TA02P$"%`,*`P````#A`R11````
+M````````````#````````````!"`Z$$`````7VEN<W1A;&QD:7(O4$L!`A0#
+M"@,`````Q`,D40```````````````!8````````````0@.A!*@```%]I;G-T
+M86QL9&ER+V%B8U]T;V]L<R]02P$"%`,*`P````"``R11````````````````
+M)````````````!"`Z$%>````7VEN<W1A;&QD:7(O86)C7W1O;VQS+S(P,#`N
+M.2UB971A,3$O4$L!`A0#"@,`````A00D40```````````````"@`````````
+M```0@.A!H````%]I;G-T86QL9&ER+V%B8U]T;V]L<R\R,#`P+CDM8F5T83$Q
+M+V)I;B]02P$"%`,4`P``#@!]!"11Q)_W<3T```!1````1P```````````""`
+M_Z'F````7VEN<W1A;&QD:7(O86)C7W1O;VQS+S(P,#`N.2UB971A,3$O8FEN
+M+V%B8U]M96%S=7)E;65N=%]A;F%L>7-I<U]S86UP;&502P$"%`,*`P````#U
+M`R11````````````````+````````````!"`Z$&(`0``7VEN<W1A;&QD:7(O
+M86)C7W1O;VQS+S(P,#`N.2UB971A,3$O<V%M<&QE<R]02P$"%`,*`P````!J
+M`R11````````````````3````````````!"`Z$'2`0``7VEN<W1A;&QD:7(O
+M86)C7W1O;VQS+S(P,#`N.2UB971A,3$O<V%M<&QE<R]A8F-?;65A<W5R96UE
+M;G1?86YA;'ES:7-?<V%M<&QE+U!+`0(4`PH#`````,D$)%$`````````````
+M``!0````````````$(#H03P"``!?:6YS=&%L;&1I<B]A8F-?=&]O;',O,C`P
+M,"XY+6)E=&$Q,2]S86UP;&5S+V%B8U]M96%S=7)E;65N=%]A;F%L>7-I<U]S
+M86UP;&4O<W)C+U!+`0(4`Q0#```.`,D$)%$:_N.79````/H```!R````````
+M````((#H@:H"``!?:6YS=&%L;&1I<B]A8F-?=&]O;',O,C`P,"XY+6)E=&$Q
+M,2]S86UP;&5S+V%B8U]M96%S=7)E;65N=%]A;F%L>7-I<U]S86UP;&4O<W)C
+M+V%B8U]M96%S=7)E;65N=%]A;F%L>7-I<U]S86UP;&4N<'E02P4&``````D`
+,"0"-`P``G@,`````
+`
+end
diff --git a/contrib/libarchive/libarchive/test/test_read_set_format.c b/contrib/libarchive/libarchive/test/test_read_set_format.c
index b4f414fa2bb2..f357bada82c3 100644
--- a/contrib/libarchive/libarchive/test/test_read_set_format.c
+++ b/contrib/libarchive/libarchive/test/test_read_set_format.c
@@ -201,11 +201,6 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
{
struct archive_entry *ae;
struct archive *a;
-#if !defined(_WIN32) || defined(__CYGWIN__)
- FILE * fp;
- int fd;
- fpos_t pos;
-#endif
/*
* If we have "bunzip2 -q", try using that.
@@ -215,14 +210,6 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
return;
}
-#if !defined(_WIN32) || defined(__CYGWIN__)
- /* bunzip2 will write to stderr, redirect it to a file */
- fflush(stderr);
- fgetpos(stderr, &pos);
- assert((fd = dup(fileno(stderr))) != -1);
- fp = freopen("stderr1", "w", stderr);
-#endif
-
assert((a = archive_read_new()) != NULL);
assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR));
assertEqualIntA(a, ARCHIVE_OK,
@@ -232,16 +219,4 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
assertA(archive_read_next_header(a, &ae) < (ARCHIVE_WARN));
assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
-
-#if !defined(_WIN32) || defined(__CYGWIN__)
- /* restore stderr and verify results */
- if (fp != NULL) {
- fflush(stderr);
- dup2(fd, fileno(stderr));
- clearerr(stderr);
- (void)fsetpos(stderr, &pos);
- }
- close(fd);
- assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1");
-#endif
}
diff --git a/contrib/libarchive/libarchive/test/test_write_disk_secure.c b/contrib/libarchive/libarchive/test/test_write_disk_secure.c
index 5061d9d8f6bc..6dd8fd9b0f7d 100644
--- a/contrib/libarchive/libarchive/test/test_write_disk_secure.c
+++ b/contrib/libarchive/libarchive/test/test_write_disk_secure.c
@@ -40,6 +40,10 @@ DEFINE_TEST(test_write_disk_secure)
struct archive *a;
struct archive_entry *ae;
struct stat st;
+#if defined(HAVE_LCHMOD) && defined(HAVE_SYMLINK) && \
+ defined(S_IRUSR) && defined(S_IWUSR) && defined(S_IXUSR)
+ int working_lchmod;
+#endif
/* Start with a known umask. */
assertUmask(UMASK);
@@ -251,10 +255,32 @@ DEFINE_TEST(test_write_disk_secure)
assert(0 == lstat("link_to_dir", &st));
failure("link_to_dir: st.st_mode=%o", st.st_mode);
assert(S_ISLNK(st.st_mode));
-#if HAVE_LCHMOD
- /* Systems that lack lchmod() can't set symlink perms, so skip this. */
- failure("link_to_dir: st.st_mode=%o", st.st_mode);
- assert((st.st_mode & 07777) == 0755);
+#if defined(HAVE_SYMLINK) && defined(HAVE_LCHMOD) && \
+ defined(S_IRUSR) && defined(S_IWUSR) && defined(S_IXUSR)
+ /* Verify if we are able to lchmod() */
+ if (symlink("dir", "testlink_to_dir") == 0) {
+ if (lchmod("testlink_to_dir",
+ S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
+ switch (errno) {
+ case ENOTSUP:
+ case ENOSYS:
+#if ENOTSUP != EOPNOTSUPP
+ case EOPNOTSUPP:
+#endif
+ working_lchmod = 0;
+ break;
+ default:
+ working_lchmod = 1;
+ }
+ } else
+ working_lchmod = 1;
+ } else
+ working_lchmod = 0;
+
+ if (working_lchmod) {
+ failure("link_to_dir: st.st_mode=%o", st.st_mode);
+ assert((st.st_mode & 07777) == 0755);
+ }
#endif
assert(0 == lstat("dir/filea", &st));
diff --git a/contrib/libarchive/libarchive/test/test_write_format_cpio.c b/contrib/libarchive/libarchive/test/test_write_format_cpio.c
index 6f0fb8f7a4de..92b97bbf8c68 100644
--- a/contrib/libarchive/libarchive/test/test_write_format_cpio.c
+++ b/contrib/libarchive/libarchive/test/test_write_format_cpio.c
@@ -141,6 +141,17 @@ test_format(int (*set_format)(struct archive *))
archive_entry_free(ae);
assertEqualIntA(a, 0, archive_write_data(a, "12345678", 9));
+ /*
+ * Write a character device to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "tty0");
+ archive_entry_set_mode(ae, S_IFCHR | 0600);
+ archive_entry_set_size(ae, 0);
+ archive_entry_set_rdev(ae, 1024);
+ assertA(0 == archive_write_header(a, ae));
+ archive_entry_free(ae);
+
/* Close out the archive. */
assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
@@ -212,6 +223,15 @@ test_format(int (*set_format)(struct archive *))
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, 0, archive_read_data(a, filedata, 10));
+ /*
+ * Read the character device entry back.
+ */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("tty0", archive_entry_pathname(ae));
+ assertEqualInt((S_IFCHR | 0600), archive_entry_mode(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1024, archive_entry_rdev(ae));
+
/* Verify the end of the archive. */
assertEqualIntA(a, 1, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
diff --git a/contrib/libarchive/libarchive/test/test_write_format_warc.c b/contrib/libarchive/libarchive/test/test_write_format_warc.c
index 60d1898fa168..3a4c2da1edf1 100644
--- a/contrib/libarchive/libarchive/test/test_write_format_warc.c
+++ b/contrib/libarchive/libarchive/test/test_write_format_warc.c
@@ -26,6 +26,19 @@
#include "test.h"
__FBSDID("$FreeBSD$");
+static void test_read(struct archive *a, char *buff, size_t used, char *filedata)
+{
+ struct archive_entry *ae;
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_none(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, 9, archive_read_data(a, filedata, 10));
+ assertEqualMem(filedata, "12345678", 9);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
DEFINE_TEST(test_write_format_warc)
{
char filedata[64];
@@ -62,14 +75,15 @@ DEFINE_TEST(test_write_format_warc)
*/
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_warc(a));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_none(a));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
+ test_read(a, buff, used, filedata);
- assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
- assertEqualIntA(a, 9, archive_read_data(a, filedata, 10));
- assertEqualMem(filedata, "12345678", 9);
- assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
- assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_by_code(a, ARCHIVE_FORMAT_WARC));
+ test_read(a, buff, used, filedata);
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_set_format(a, ARCHIVE_FORMAT_WARC));
+ test_read(a, buff, used, filedata);
/* Create a new archive */
assert((a = archive_write_new()) != NULL);