From 690f818afd6c3c0721202dd1e075aeaaae004704 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Tue, 3 Mar 2009 17:02:51 +0000 Subject: [PATCH] Merge r294:337,r348:350 from libarchive.googlecode.com: A lot of work to make libarchive work on Windows. --- lib/libarchive/archive.h | 6 +- lib/libarchive/archive_entry.c | 11 +- lib/libarchive/archive_string.c | 84 + lib/libarchive/archive_write_disk.c | 36 +- lib/libarchive/archive_write_set_format_pax.c | 16 + lib/libarchive/test/main.c | 133 +- lib/libarchive/test/read_open_memory.c | 2 +- lib/libarchive/test/test.h | 14 + lib/libarchive/test/test_acl_pax.c | 4 +- lib/libarchive/test/test_compat_bzip2.c | 4 + lib/libarchive/test/test_compat_gtar.c | 4 +- lib/libarchive/test/test_compat_gtar_1.tar.uu | 232 +++ lib/libarchive/test/test_compat_gtar_1.tgz.uu | 10 - lib/libarchive/test/test_compat_gzip.c | 4 + lib/libarchive/test/test_compat_zip.c | 4 + lib/libarchive/test/test_empty_write.c | 84 +- lib/libarchive/test/test_entry.c | 18 +- lib/libarchive/test/test_fuzz.c | 12 +- .../test/test_pax_filename_encoding.c | 6 +- .../test/test_pax_filename_encoding.tar.gz.uu | 11 - .../test/test_pax_filename_encoding.tar.uu | 119 ++ .../test/test_read_compress_program.c | 9 +- lib/libarchive/test/test_read_extract.c | 6 + .../test/test_read_format_cpio_bin_bz2.c | 4 + .../test/test_read_format_cpio_bin_gz.c | 4 + .../test/test_read_format_cpio_svr4_gzip.c | 4 + lib/libarchive/test/test_read_format_empty.c | 6 +- .../test/test_read_format_gtar_gz.c | 4 + .../test/test_read_format_gtar_sparse.c | 19 +- .../test_read_format_gtar_sparse_1_13.tar.uu | 1371 ++++++++++++++ .../test_read_format_gtar_sparse_1_13.tgz.uu | 27 - .../test_read_format_gtar_sparse_1_17.tar.uu | 1370 ++++++++++++++ .../test_read_format_gtar_sparse_1_17.tgz.uu | 27 - ...ead_format_gtar_sparse_1_17_posix00.tar.uu | 1597 +++++++++++++++++ ...ead_format_gtar_sparse_1_17_posix00.tgz.uu | 30 - ...ead_format_gtar_sparse_1_17_posix01.tar.uu | 1370 ++++++++++++++ ...ead_format_gtar_sparse_1_17_posix01.tgz.uu | 28 - ...ead_format_gtar_sparse_1_17_posix10.tar.uu | 1370 ++++++++++++++ ...ead_format_gtar_sparse_1_17_posix10.tgz.uu | 28 - lib/libarchive/test/test_read_format_iso_gz.c | 4 + .../test/test_read_format_isorr_bz2.c | 13 +- .../test/test_read_format_pax_bz2.c | 4 + lib/libarchive/test/test_read_format_tbz.c | 4 + lib/libarchive/test/test_read_format_tgz.c | 4 + lib/libarchive/test/test_read_format_zip.c | 6 +- lib/libarchive/test/test_read_large.c | 4 +- lib/libarchive/test/test_tar_large.c | 15 +- lib/libarchive/test/test_ustar_filenames.c | 2 +- lib/libarchive/test/test_write_compress.c | 2 +- .../test/test_write_compress_program.c | 8 +- lib/libarchive/test/test_write_disk.c | 12 +- .../test/test_write_disk_hardlink.c | 2 +- lib/libarchive/test/test_write_disk_perms.c | 4 +- lib/libarchive/test/test_write_disk_secure.c | 4 + lib/libarchive/test/test_write_format_ar.c | 2 - .../test/test_write_format_cpio_newc.c | 2 +- .../test/test_write_format_cpio_odc.c | 2 +- lib/libarchive/test/test_write_format_tar.c | 4 +- .../test/test_write_format_tar_empty.c | 2 +- .../test/test_write_format_tar_ustar.c | 2 +- lib/libarchive/test/test_write_open_memory.c | 2 +- 61 files changed, 7871 insertions(+), 321 deletions(-) create mode 100644 lib/libarchive/test/test_compat_gtar_1.tar.uu delete mode 100644 lib/libarchive/test/test_compat_gtar_1.tgz.uu delete mode 100644 lib/libarchive/test/test_pax_filename_encoding.tar.gz.uu create mode 100644 lib/libarchive/test/test_pax_filename_encoding.tar.uu create mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu delete mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_13.tgz.uu create mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu delete mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_17.tgz.uu create mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu delete mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tgz.uu create mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu delete mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tgz.uu create mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu delete mode 100644 lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tgz.uu diff --git a/lib/libarchive/archive.h b/lib/libarchive/archive.h index 0194a5d79068..cfc31979f4b9 100644 --- a/lib/libarchive/archive.h +++ b/lib/libarchive/archive.h @@ -47,7 +47,11 @@ /* These should match the types used in 'struct stat' */ #ifdef _WIN32 #define __LA_INT64_T __int64 -#define __LA_SSIZE_T long +# if defined(_WIN64) +# define __LA_SSIZE_T __int64 +# else +# define __LA_SSIZE_T long +# endif #define __LA_UID_T unsigned int #define __LA_GID_T unsigned int #else diff --git a/lib/libarchive/archive_entry.c b/lib/libarchive/archive_entry.c index 3e52b186407e..063632435902 100644 --- a/lib/libarchive/archive_entry.c +++ b/lib/libarchive/archive_entry.c @@ -62,6 +62,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_WCHAR_H #include #endif +#ifdef _WIN32 +#include +#endif #include "archive.h" #include "archive_entry.h" @@ -227,9 +230,15 @@ aes_get_wcs(struct aes *aes) w = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t)); if (w == NULL) __archive_errx(1, "No memory for aes_get_wcs()"); +#ifndef _WIN32 r = mbstowcs(w, aes->aes_mbs.s, wcs_length); - w[wcs_length] = 0; +#else + r = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, + aes->aes_mbs.s, (int)aes->aes_mbs.length, w, + (int)wcs_length); +#endif if (r > 0) { + w[r] = 0; aes->aes_set |= AES_SET_WCS; return (aes->aes_wcs = w); } diff --git a/lib/libarchive/archive_string.c b/lib/libarchive/archive_string.c index fc6a344e9479..c22031706a2f 100644 --- a/lib/libarchive/archive_string.c +++ b/lib/libarchive/archive_string.c @@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_WCHAR_H #include #endif +#ifdef _WIN32 +#include +#endif #include "archive_private.h" #include "archive_string.h" @@ -175,6 +178,7 @@ __archive_strappend_int(struct archive_string *as, int d, int base) return (as); } +#ifndef _WIN32 /* * Home-grown wctomb for UTF-8. */ @@ -375,3 +379,83 @@ __archive_string_utf8_w(struct archive_string *as) *dest++ = L'\0'; return (ws); } + +#else + +static struct archive_string * +my_archive_strappend_w(struct archive_string *as, + unsigned int codepage, const wchar_t *w) +{ + char *p; + int l, wl; + BOOL useDefaultChar = FALSE; + + wl = (int)wcslen(w); + l = wl * 4 + 4; + p = malloc(l); + if (p == NULL) + __archive_errx(1, "Out of memory"); + /* To check a useDefaultChar is to simulate error handling of + * the my_wcstombs() which is running on non Windows system with + * wctomb(). + * And to set NULL for last argument is necessary when a codepage + * is not CP_ACP(current locale). + */ + l = WideCharToMultiByte(codepage, 0, w, wl, p, l, NULL, + (codepage == CP_ACP) ? &useDefaultChar : NULL); + if (l == 0 || useDefaultChar) { + free(p); + return (NULL); + } + __archive_string_append(as, p, l); + free(p); + return (as); +} + +/* + * Translates a wide character string into UTF-8 and appends + * to the archive_string. Note: returns NULL if conversion fails. + */ +struct archive_string * +__archive_strappend_w_utf8(struct archive_string *as, const wchar_t *w) +{ + + return (my_archive_strappend_w(as, CP_UTF8, w)); +} + +/* + * Translates a wide character string into current locale character set + * and appends to the archive_string. Note: returns NULL if conversion + * fails. + */ +struct archive_string * +__archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w) +{ + + return (my_archive_strappend_w(as, CP_ACP, w)); +} + +/* + * Return a wide-character string by converting this archive_string + * from UTF-8. + */ +wchar_t * +__archive_string_utf8_w(struct archive_string *as) +{ + wchar_t *ws; + int n; + + ws = (wchar_t *)malloc((as->length + 1) * sizeof(wchar_t)); + if (ws == NULL) + __archive_errx(1, "Out of memory"); + n = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, + as->s, (int)as->length, ws, (int)as->length); + if (n == 0) { + free(ws); + return (NULL); + } + ws[n] = L'\0'; + return (ws); +} + +#endif /* !_WIN32 */ diff --git a/lib/libarchive/archive_write_disk.c b/lib/libarchive/archive_write_disk.c index ddac6302e0eb..448d92e91a11 100644 --- a/lib/libarchive/archive_write_disk.c +++ b/lib/libarchive/archive_write_disk.c @@ -83,6 +83,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_UTIME_H #include #endif +#ifdef _WIN32 +#include +#endif #include "archive.h" #include "archive_string.h" @@ -516,6 +519,9 @@ static ssize_t write_data_block(struct archive_write_disk *a, const char *buff, size_t size) { uint64_t start_size = size; +#if _WIN32 + HANDLE handle; +#endif ssize_t bytes_written = 0; ssize_t block_size = 0, bytes_to_write; @@ -524,6 +530,9 @@ write_data_block(struct archive_write_disk *a, const char *buff, size_t size) "Attempt to write to an empty file"); return (ARCHIVE_WARN); } +#if _WIN32 + handle = (HANDLE)_get_osfhandle(a->fd); +#endif if (a->flags & ARCHIVE_EXTRACT_SPARSE) { #if HAVE_STRUCT_STAT_ST_BLKSIZE @@ -572,7 +581,23 @@ write_data_block(struct archive_write_disk *a, const char *buff, size_t size) if (a->offset + bytes_to_write > block_end) bytes_to_write = block_end - a->offset; } - +#ifdef _WIN32 + /* Seek if necessary to the specified offset. */ + if (offset != a->fd_offset) { + LARGE_INTEGER distance; + distance.QuadPart = offset; + if (!SetFilePointerEx(handle, distance, NULL, FILE_BEGIN)) { + archive_set_error(&a->archive, _dosmaperr(GetLastError()), + "Seek failed"); + return (ARCHIVE_FATAL); + } + } + if (!WriteFile(handle, buff, bytes_to_write, &bytes_written, NULL)) { + archive_set_error(&a->archive, _dosmaperr(GetLastError()), + "Write failed"); + return (ARCHIVE_WARN); + } +#else /* Seek if necessary to the specified offset. */ if (a->offset != a->fd_offset) { if (lseek(a->fd, a->offset, SEEK_SET) < 0) { @@ -589,6 +614,7 @@ write_data_block(struct archive_write_disk *a, const char *buff, size_t size) archive_set_error(&a->archive, errno, "Write failed"); return (ARCHIVE_WARN); } +#endif buff += bytes_written; size -= bytes_written; a->offset += bytes_written; @@ -1186,7 +1212,11 @@ _archive_write_close(struct archive *_a) if (p->fixup & TODO_TIMES) { #ifdef HAVE_UTIMES /* {f,l,}utimes() are preferred, when available. */ +#ifdef __timeval + struct __timeval times[2]; +#else struct timeval times[2]; +#endif times[0].tv_sec = p->atime; times[0].tv_usec = p->atime_nanos / 1000; #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME @@ -1717,7 +1747,11 @@ set_time(int fd, int mode, const char *name, time_t atime, long atime_nsec, time_t mtime, long mtime_nsec) { +#ifdef __timeval + struct __timeval times[2]; +#else struct timeval times[2]; +#endif times[0].tv_sec = atime; times[0].tv_usec = atime_nsec / 1000; diff --git a/lib/libarchive/archive_write_set_format_pax.c b/lib/libarchive/archive_write_set_format_pax.c index 621e56823bfa..24d611c89eb9 100644 --- a/lib/libarchive/archive_write_set_format_pax.c +++ b/lib/libarchive/archive_write_set_format_pax.c @@ -203,6 +203,16 @@ utf8_encode(const wchar_t *wval) utf8len = 0; for (wp = wval; *wp != L'\0'; ) { wc = *wp++; + + if (wc >= 0xd800 && wc <= 0xdbff + && *wp >= 0xdc00 && *wp <= 0xdfff) { + /* This is a surrogate pair. Combine into a + * full Unicode value before encoding into + * UTF-8. */ + wc = (wc - 0xd800) << 10; /* High 10 bits */ + wc += (*wp++ - 0xdc00); /* Low 10 bits */ + wc += 0x10000; /* Skip BMP */ + } if (wc <= 0x7f) utf8len++; else if (wc <= 0x7ff) @@ -226,6 +236,12 @@ utf8_encode(const wchar_t *wval) for (wp = wval, p = utf8_value; *wp != L'\0'; ) { wc = *wp++; + if (wc >= 0xd800 && wc <= 0xdbff + && *wp >= 0xdc00 && *wp <= 0xdfff) { + /* Combine surrogate pair. */ + wc = (wc - 0xd800) << 10; + wc += *wp++ - 0xdc00 + 0x10000; + } if (wc <= 0x7f) { *p++ = (char)wc; } else if (wc <= 0x7ff) { diff --git a/lib/libarchive/test/main.c b/lib/libarchive/test/main.c index 6e5610f87243..24ea6c7fdf7c 100644 --- a/lib/libarchive/test/main.c +++ b/lib/libarchive/test/main.c @@ -44,7 +44,7 @@ #define ENVBASE "LIBARCHIVE" /* Prefix for environment variables. */ #define EXTRA_DUMP(x) archive_error_string((struct archive *)(x)) #define EXTRA_VERSION archive_version() -#define KNOWNREF "test_compat_gtar_1.tgz.uu" +#define KNOWNREF "test_compat_gtar_1.tar.uu" __FBSDID("$FreeBSD$"); /* @@ -81,7 +81,20 @@ static int skips = 0; static int assertions = 0; /* Directory where uuencoded reference files can be found. */ -static char *refdir; +static const char *refdir; + + +#ifdef _WIN32 + +static void +invalid_paramter_handler(const wchar_t * expression, + const wchar_t * function, const wchar_t * file, + unsigned int line, uintptr_t pReserved) +{ + /* nop */ +} + +#endif /* * My own implementation of the standard assert() macro emits the @@ -751,7 +764,11 @@ static int test_run(int i, const char *tmpdir) /* If there were no failures, we can remove the work dir. */ if (failures == failures_before) { if (!keep_temp_files && chdir(tmpdir) == 0) { +#ifndef _WIN32 systemf("rm -rf %s", tests[i].name); +#else + systemf("rmdir /S /Q %s", tests[i].name); +#endif } } /* Return appropriate status. */ @@ -844,19 +861,18 @@ extract_reference_file(const char *name) } static char * -get_refdir(const char *tmpdir) +get_refdir(void) { char tried[512] = { '\0' }; char buff[128]; char *pwd, *p; /* Get the current dir. */ - systemf("/bin/pwd > %s/refdir", tmpdir); - pwd = slurpfile(NULL, "%s/refdir", tmpdir); + /* XXX Visual C++ uses _getcwd() XXX */ + pwd = getcwd(NULL, 0); while (pwd[strlen(pwd) - 1] == '\n') pwd[strlen(pwd) - 1] = '\0'; printf("PWD: %s\n", pwd); - systemf("rm %s/refdir", tmpdir); /* Look for a known file. */ snprintf(buff, sizeof(buff), "%s", pwd); @@ -904,24 +920,24 @@ success: int main(int argc, char **argv) { static const int limit = sizeof(tests) / sizeof(tests[0]); - int i, tests_run = 0, tests_failed = 0, opt; + int i, tests_run = 0, tests_failed = 0, option; time_t now; char *refdir_alloc = NULL; - char *progname, *p; - const char *tmp; + const char *progname = LIBRARY "_test"; + const char *tmp, *option_arg, *p; char tmpdir[256]; char tmpdir_timestamp[256]; - /* - * Name of this program, used to build root of our temp directory - * tree. - */ - progname = p = argv[0]; - while (*p != '\0') { - if (*p == '/') - progname = p + 1; - ++p; - } + (void)argc; /* UNUSED */ + +#ifdef _WIN32 + /* To stop to run the default invalid parameter handler. */ + _set_invalid_parameter_handler(invalid_paramter_handler); + /* for open() to a binary mode. */ + _set_fmode(_O_BINARY); + /* Disable annoying assertion message box. */ + _CrtSetReportMode(_CRT_ASSERT, 0); +#endif #ifdef PROGRAM /* Get the target program from environment, if available. */ @@ -947,39 +963,60 @@ int main(int argc, char **argv) refdir = getenv(ENVBASE "_TEST_FILES"); /* - * Parse options. + * Parse options, without using getopt(), which isn't available + * on all platforms. */ - while ((opt = getopt(argc, argv, "dkp:qr:v")) != -1) { - switch (opt) { - case 'd': - dump_on_failure = 1; - break; - case 'k': - keep_temp_files = 1; - break; - case 'p': + ++argv; /* Skip program name */ + while (*argv != NULL) { + p = *argv++; + if (*p++ != '-') + usage(progname); + while (*p != '\0') { + option = *p++; + option_arg = NULL; + /* If 'opt' takes an argument, parse that. */ + if (option == 'p' || option == 'r') { + if (*p != '\0') + option_arg = p; + else if (*argv == NULL) { + fprintf(stderr, + "Option -%c requires argument.\n", + option); + usage(progname); + } else + option_arg = *argv++; + p = ""; /* End of this option word. */ + } + + /* Now, handle the option. */ + switch (option) { + case 'd': + dump_on_failure = 1; + break; + case 'k': + keep_temp_files = 1; + break; + case 'p': #ifdef PROGRAM - testprog = optarg; + testprog = option_arg; #else - usage(progname); + usage(progname); #endif - break; - case 'q': - quiet_flag++; - break; - case 'r': - refdir = optarg; - break; - case 'v': - verbose = 1; - break; - case '?': - default: - usage(progname); + break; + case 'q': + quiet_flag++; + break; + case 'r': + refdir = option_arg; + break; + case 'v': + verbose = 1; + break; + default: + usage(progname); + } } } - argc -= optind; - argv += optind; /* * Sanity-check that our options make sense. @@ -1016,7 +1053,7 @@ int main(int argc, char **argv) * the "usual places." */ if (refdir == NULL) - refdir = refdir_alloc = get_refdir(tmpdir); + refdir = refdir_alloc = get_refdir(); /* * Banner with basic information. @@ -1035,7 +1072,7 @@ int main(int argc, char **argv) /* * Run some or all of the individual tests. */ - if (argc == 0) { + if (*argv == NULL) { /* Default: Run all tests. */ for (i = 0; i < limit; i++) { if (test_run(i, tmpdir)) diff --git a/lib/libarchive/test/read_open_memory.c b/lib/libarchive/test/read_open_memory.c index fac9b23490f8..bae26b99dcf1 100644 --- a/lib/libarchive/test/read_open_memory.c +++ b/lib/libarchive/test/read_open_memory.c @@ -107,7 +107,7 @@ memory_read(struct archive *a, void *client_data, const void **buff) *buff = mine->copy_buff; mine->buffer += size; - return (size); + return ((ssize_t)size); } /* diff --git a/lib/libarchive/test/test.h b/lib/libarchive/test/test.h index f1fbbbeabe2f..5286f5da35c7 100644 --- a/lib/libarchive/test/test.h +++ b/lib/libarchive/test/test.h @@ -45,7 +45,11 @@ #error Oops: No config.h and no pre-built configuration in test.h. #endif +#ifndef _WIN32 #include +#else +#include +#endif #include #include #include @@ -68,6 +72,16 @@ #define __FBSDID(a) /* null */ #endif +#ifdef _WIN32 +#define LOCALE_DE "deu" +#else +#define LOCALE_DE "de_DE.UTF-8" +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + /* * Redefine DEFINE_TEST for use in defining the test functions. */ diff --git a/lib/libarchive/test/test_acl_pax.c b/lib/libarchive/test/test_acl_pax.c index 01c36d196494..4a37199a1792 100644 --- a/lib/libarchive/test/test_acl_pax.c +++ b/lib/libarchive/test/test_acl_pax.c @@ -454,7 +454,7 @@ DEFINE_TEST(test_acl_pax) /* Write out the data we generated to a file for manual inspection. */ assert(-1 < (fd = open("testout", O_WRONLY | O_CREAT | O_TRUNC, 0775))); - assert(used == (size_t)write(fd, buff, used)); + assert(used == (size_t)write(fd, buff, (unsigned int)used)); close(fd); /* Write out the reference data to a file for manual inspection. */ @@ -466,7 +466,7 @@ DEFINE_TEST(test_acl_pax) failure("Generated pax archive does not match reference; check 'testout' and 'reference' files."); assert(0 == memcmp(buff, reference, sizeof(reference))); failure("Generated pax archive does not match reference; check 'testout' and 'reference' files."); - assertEqualInt(used, sizeof(reference)); + assertEqualInt((int)used, sizeof(reference)); /* Read back each entry and check that the ACL data is right. */ assert(NULL != (a = archive_read_new())); diff --git a/lib/libarchive/test/test_compat_bzip2.c b/lib/libarchive/test/test_compat_bzip2.c index 2f5c52279964..143d923c489f 100644 --- a/lib/libarchive/test/test_compat_bzip2.c +++ b/lib/libarchive/test/test_compat_bzip2.c @@ -82,8 +82,12 @@ compat_bzip2(const char *name) DEFINE_TEST(test_compat_bzip2) { +#if HAVE_BZLIB_H compat_bzip2("test_compat_bzip2_1.tbz"); compat_bzip2("test_compat_bzip2_2.tbz"); +#else + skipping("Need bzlib"); +#endif } diff --git a/lib/libarchive/test/test_compat_gtar.c b/lib/libarchive/test/test_compat_gtar.c index bf9817bc5a6a..41fc2f23a24e 100644 --- a/lib/libarchive/test/test_compat_gtar.c +++ b/lib/libarchive/test/test_compat_gtar.c @@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$"); static void test_compat_gtar_1(void) { - char name[] = "test_compat_gtar_1.tgz"; + char name[] = "test_compat_gtar_1.tar"; struct archive_entry *ae; struct archive *a; int r; @@ -99,7 +99,7 @@ test_compat_gtar_1(void) assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); /* Verify that the format detection worked. */ - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP); + assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE); assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); diff --git a/lib/libarchive/test/test_compat_gtar_1.tar.uu b/lib/libarchive/test/test_compat_gtar_1.tar.uu new file mode 100644 index 000000000000..1e8d25be8bfc --- /dev/null +++ b/lib/libarchive/test/test_compat_gtar_1.tar.uu @@ -0,0 +1,232 @@ +$FreeBSD$ +begin 644 test_compat_gtar_1.tar +M+B\N+T!,;VYG3&EN:P`````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````"`@("`@,"``("`@("`P(``@("`@(#`@`"`@("`@("`@,S$Q +M("`@("`@("`@("`P("`Q,#'W+PJB)43=4 -MJO^W:1.Z:#KYATG2)!T5]7Y95/N-Z@:UF)ZO7B9"-TPD[%@4%1W=Y\'IV$P. -M1.I0U\VK<^=566Y#7"@LT9FQN1L,.>[=M]\Q5@%JHX0Y-Z;-NSC+]^LM\S[R -M.G?,XC(B+:Q949"B7O/?5+N7Y]Y]CU32U_[OZS_NZ#X/T/][T\/1_\/K;?XQ -M_P4QF<[FY6*YJM9Q[[[]CK$*4!O_CV%G[6?SGS9^_C/&:I]_'6(X_?/Y#P`` -4````````````?L\%KFMT6@`H```` -` -end diff --git a/lib/libarchive/test/test_compat_gzip.c b/lib/libarchive/test/test_compat_gzip.c index 759af9194417..0140a448f062 100644 --- a/lib/libarchive/test/test_compat_gzip.c +++ b/lib/libarchive/test/test_compat_gzip.c @@ -82,6 +82,7 @@ verify(const char *name) DEFINE_TEST(test_compat_gzip) { +#if HAVE_ZLIB_H /* This sample has been 'split', each piece compressed separately, * then concatenated. Gunzip will emit the concatenated result. */ /* Not supported in libarchive 2.6 and earlier */ @@ -89,6 +90,9 @@ DEFINE_TEST(test_compat_gzip) /* This sample has been compressed as a single stream, but then * some unrelated garbage text has been appended to the end. */ verify("test_compat_gzip_2.tgz"); +#else + skipping("Need zlib"); +#endif } diff --git a/lib/libarchive/test/test_compat_zip.c b/lib/libarchive/test/test_compat_zip.c index 9ead93810ae6..ac26d3475f84 100644 --- a/lib/libarchive/test/test_compat_zip.c +++ b/lib/libarchive/test/test_compat_zip.c @@ -63,7 +63,11 @@ test_compat_zip_1(void) DEFINE_TEST(test_compat_zip) { +#if HAVE_ZLIB_H test_compat_zip_1(); +#else + skipping("Need zlib"); +#endif } diff --git a/lib/libarchive/test/test_empty_write.c b/lib/libarchive/test/test_empty_write.c index a4833a9c47a0..9980e3aa8497 100644 --- a/lib/libarchive/test/test_empty_write.c +++ b/lib/libarchive/test/test_empty_write.c @@ -31,6 +31,7 @@ DEFINE_TEST(test_empty_write) struct archive_entry *ae; struct archive *a; size_t used; + int r; /* * Exercise a zero-byte write to a gzip-compressed archive. @@ -39,27 +40,29 @@ DEFINE_TEST(test_empty_write) /* Create a new archive in memory. */ assert((a = archive_write_new()) != NULL); assertA(0 == archive_write_set_format_ustar(a)); - assertA(0 == archive_write_set_compression_gzip(a)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - /* Write a file to it. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, 0); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); + r = archive_write_set_compression_gzip(a); + if (r == ARCHIVE_FATAL) { + skipping("Empty write to gzip-compressed archive"); + } else { + assertEqualIntA(a, ARCHIVE_OK, r); + assertEqualIntA(a, ARCHIVE_OK, + archive_write_open_memory(a, buff, sizeof(buff), &used)); + /* Write a file to it. */ + assert((ae = archive_entry_new()) != NULL); + archive_entry_copy_pathname(ae, "file"); + archive_entry_set_mode(ae, S_IFREG | 0755); + archive_entry_set_size(ae, 0); + assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); - /* THE TEST: write zero bytes to this entry. */ - /* This used to crash. */ - assertEqualIntA(a, 0, archive_write_data(a, "", 0)); + /* THE TEST: write zero bytes to this entry. */ + /* This used to crash. */ + assertEqualIntA(a, 0, archive_write_data(a, "", 0)); - /* Close out the archive. */ - assertA(0 == archive_write_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assertA(0 == archive_write_finish(a)); -#endif + /* Close out the archive. */ + assertA(0 == archive_write_close(a)); + assertA(0 == archive_write_finish(a)); + } /* * Again, with bzip2 compression. @@ -68,27 +71,28 @@ DEFINE_TEST(test_empty_write) /* Create a new archive in memory. */ assert((a = archive_write_new()) != NULL); assertA(0 == archive_write_set_format_ustar(a)); - assertA(0 == archive_write_set_compression_bzip2(a)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - /* Write a file to it. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, 0); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); + r = archive_write_set_compression_bzip2(a); + if (r == ARCHIVE_FATAL) { + skipping("Empty write to bzip2-compressed archive"); + } else { + assertEqualIntA(a, ARCHIVE_OK, r); + assertEqualIntA(a, ARCHIVE_OK, + archive_write_open_memory(a, buff, sizeof(buff), &used)); + /* Write a file to it. */ + assert((ae = archive_entry_new()) != NULL); + archive_entry_copy_pathname(ae, "file"); + archive_entry_set_mode(ae, S_IFREG | 0755); + archive_entry_set_size(ae, 0); + assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); - /* THE TEST: write zero bytes to this entry. */ - assertEqualIntA(a, 0, archive_write_data(a, "", 0)); - - /* Close out the archive. */ - assertA(0 == archive_write_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assertA(0 == archive_write_finish(a)); -#endif + /* THE TEST: write zero bytes to this entry. */ + assertEqualIntA(a, 0, archive_write_data(a, "", 0)); + /* Close out the archive. */ + assertA(0 == archive_write_close(a)); + assertA(0 == archive_write_finish(a)); + } /* * For good measure, one more time with no compression. @@ -112,9 +116,5 @@ DEFINE_TEST(test_empty_write) /* Close out the archive. */ assertA(0 == archive_write_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else assertA(0 == archive_write_finish(a)); -#endif } diff --git a/lib/libarchive/test/test_entry.c b/lib/libarchive/test/test_entry.c index 8e2d67f26f13..fd1b2f292f1e 100644 --- a/lib/libarchive/test/test_entry.c +++ b/lib/libarchive/test/test_entry.c @@ -287,20 +287,20 @@ DEFINE_TEST(test_entry) assertEqualInt(0, archive_entry_xattr_next(e, &xname, &xval, &xsize)); assertEqualString(xname, "xattr1"); assertEqualString(xval, "xattrvalue1"); - assertEqualInt(xsize, 12); + assertEqualInt((int)xsize, 12); assertEqualInt(1, archive_entry_xattr_count(e)); assertEqualInt(ARCHIVE_WARN, archive_entry_xattr_next(e, &xname, &xval, &xsize)); assertEqualString(xname, NULL); assertEqualString(xval, NULL); - assertEqualInt(xsize, 0); + assertEqualInt((int)xsize, 0); archive_entry_xattr_clear(e); assertEqualInt(0, archive_entry_xattr_reset(e)); assertEqualInt(ARCHIVE_WARN, archive_entry_xattr_next(e, &xname, &xval, &xsize)); assertEqualString(xname, NULL); assertEqualString(xval, NULL); - assertEqualInt(xsize, 0); + assertEqualInt((int)xsize, 0); archive_entry_xattr_add_entry(e, "xattr1", "xattrvalue1", 12); assertEqualInt(1, archive_entry_xattr_reset(e)); archive_entry_xattr_add_entry(e, "xattr2", "xattrvalue2", 12); @@ -311,7 +311,7 @@ DEFINE_TEST(test_entry) archive_entry_xattr_next(e, &xname, &xval, &xsize)); assertEqualString(xname, NULL); assertEqualString(xval, NULL); - assertEqualInt(xsize, 0); + assertEqualInt((int)xsize, 0); /* @@ -437,12 +437,12 @@ DEFINE_TEST(test_entry) assertEqualInt(0, archive_entry_xattr_next(e2, &xname, &xval, &xsize)); assertEqualString(xname, "xattr1"); assertEqualString(xval, "xattrvalue"); - assertEqualInt(xsize, 11); + assertEqualInt((int)xsize, 11); assertEqualInt(ARCHIVE_WARN, archive_entry_xattr_next(e2, &xname, &xval, &xsize)); assertEqualString(xname, NULL); assertEqualString(xval, NULL); - assertEqualInt(xsize, 0); + assertEqualInt((int)xsize, 0); #endif /* Change the original */ @@ -783,7 +783,7 @@ DEFINE_TEST(test_entry) /* * Exercise the character-conversion logic, if we can. */ - if (NULL == setlocale(LC_ALL, "de_DE.UTF-8")) { + if (NULL == setlocale(LC_ALL, LOCALE_DE)) { skipping("Can't exercise charset-conversion logic without" " a suitable locale."); } else { @@ -827,8 +827,8 @@ DEFINE_TEST(test_entry) * "c89 plus GNU extensions.") */ wcscpy(wbuff, L"xxxAyyyBzzz"); - wbuff[3] = 0x12345678; - wbuff[7] = 0x5678; + wbuff[3] = (wchar_t)0x12345678; + wbuff[7] = (wchar_t)0x5678; /* A wide filename that cannot be converted to narrow. */ archive_entry_copy_pathname_w(e, wbuff); failure("Converting wide characters from Unicode should fail."); diff --git a/lib/libarchive/test/test_fuzz.c b/lib/libarchive/test/test_fuzz.c index b47c42aeae4c..673d4b7752a3 100644 --- a/lib/libarchive/test/test_fuzz.c +++ b/lib/libarchive/test/test_fuzz.c @@ -51,13 +51,19 @@ __FBSDID("$FreeBSD$"); static const char * files[] = { "test_fuzz_1.iso", +#if HAVE_BZLIB_H "test_compat_bzip2_1.tbz", - "test_compat_gtar_1.tgz", +#endif + "test_compat_gtar_1.tar", "test_compat_tar_hardlink_1.tar", +#if HAVE_ZLIB_H "test_compat_zip_1.zip", +#endif "test_read_format_gtar_sparse_1_17_posix10_modified.tar", "test_read_format_tar_empty_filename.tar", +#if HAVE_ZLIB_H "test_read_format_zip.zip", +#endif NULL }; @@ -84,7 +90,7 @@ DEFINE_TEST(test_fuzz) /* Fuzz < 1% of the bytes in the archive. */ memcpy(image, rawimage, size); - numbytes = rand() % (size / 100); + numbytes = (int)(rand() % (size / 100)); for (j = 0; j < numbytes; ++j) image[rand() % size] = (char)rand(); @@ -93,7 +99,7 @@ DEFINE_TEST(test_fuzz) fd = open("after.test.failure.send.this.file." "to.libarchive.maintainers.with.system.details", O_WRONLY | O_CREAT | O_TRUNC, 0744); - write(fd, image, size); + write(fd, image, (off_t)size); close(fd); assert((a = archive_read_new()) != NULL); diff --git a/lib/libarchive/test/test_pax_filename_encoding.c b/lib/libarchive/test/test_pax_filename_encoding.c index 217074d8fb26..01061199e63a 100644 --- a/lib/libarchive/test/test_pax_filename_encoding.c +++ b/lib/libarchive/test/test_pax_filename_encoding.c @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); */ DEFINE_TEST(test_pax_filename_encoding_1) { - static const char testname[] = "test_pax_filename_encoding.tar.gz"; + static const char testname[] = "test_pax_filename_encoding.tar"; /* * \314\214 is a valid 2-byte UTF-8 sequence. * \374 is invalid in UTF-8. @@ -105,9 +105,9 @@ DEFINE_TEST(test_pax_filename_encoding_2) * de_DE.UTF-8 seems to be commonly supported. */ /* If it doesn't exist, just warn and return. */ - if (NULL == setlocale(LC_ALL, "de_DE.UTF-8")) { + if (NULL == setlocale(LC_ALL, LOCALE_DE)) { skipping("invalid encoding tests require a suitable locale;" - " de_DE.UTF-8 not available on this system"); + " %s not available on this system", LOCALE_DE); return; } diff --git a/lib/libarchive/test/test_pax_filename_encoding.tar.gz.uu b/lib/libarchive/test/test_pax_filename_encoding.tar.gz.uu deleted file mode 100644 index b365495278aa..000000000000 --- a/lib/libarchive/test/test_pax_filename_encoding.tar.gz.uu +++ /dev/null @@ -1,11 +0,0 @@ -$FreeBSD$ -begin 644 test_pax_filename_encoding.tar.gz -M'XL(`)4;VT<``^V6STK#0!#&<\Y3[!/HS/Z-ASVHEQ1$BE[L<4T6$DP32:-$ -MG\%'\Y%Z,*7$UEJLE"91NK_+P.P>OF'X^&9LZM":V):GYCYZ?YOFQ5W]\NH= -M%`"0G).FHA*P7I>@E`1!22E!`9,$4#"0'JD/*V,[3[/*E(V4*IW^^&_7^W(4 -M\EG_"13)HZD2W6Y_WFS?IT"B9EZKD8(0+)"!6/3,EQZ5/BIR>QF.KB8GL7W6 -M0>!3VC;2O-"#\S,>@[>99FC]H](>>VM'2G>M7[/(_@-CP/V-4>`2Z$K3. -MD?L_M%E6#"W",1CC;_D_[SW_*;+-_!>!RW^'P^$X3CX`98.>C@`4```` -` -end diff --git a/lib/libarchive/test/test_pax_filename_encoding.tar.uu b/lib/libarchive/test/test_pax_filename_encoding.tar.uu new file mode 100644 index 000000000000..e902c706c463 --- /dev/null +++ b/lib/libarchive/test/test_pax_filename_encoding.tar.uu @@ -0,0 +1,119 @@ +$FreeBSD$ + +begin 644 test_pax_filename_encoding.tar +M4&%X2&5A9&5R+V%B8\R,;6YO6'AY>@`````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````#`P,#8T-"``,#`Q-S4P(``P,#$W-3`@`#`P,#`P,#`P,38V +M(#$P-S8V-C`W,#,V(#`Q-3,P-@`@>``````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!U@HR,"!C=&EM +M93TQ,C`U-3,X-C@U"C(P(&%T:6UE/3$R,#4U,S@V,C8*,3<@4T-(24Q9+F1E +M=CTX.`HR,B!30TA)3%DN:6YO/30S,34T-#D*,3@@4T-(24Q9+FYL:6YK/3$* +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````````````````````````````````````&%B8\R,;6YO6'AY +M>@`````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````P +M,#`V-#0@`#`P,3'EZ +M```````````````````````````````````````````````````````````` +M````````````````````````````````````````````,#`P-C0T(``P,#$W +M-3`@`#`P,3'EZ"C(P(&-T:6UE +M/3$R,#4U-#$W,S4*,C`@871I;64],3(P-34S.#8R-@HQ-R!30TA)3%DN9&5V +M/3@X"C(R(%-#2$E,62YI;F\]-#,Q-3$R-@HQ."!30TA)3%DN;FQI;FL],0H` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M````````````````86)CS(QM;F_\>'EZ```````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````````````````````#`P,#8T-"``,#`Q-S4P(``P,#$W-3`@ +M`#`P,#`P,#`P,#`U(#$P-S8V-C`W,#,V(#`Q,S4W,0`@,``````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````````````````````!U +MNYD*Q``P\\L&.(\OYSNP/)LGE` -M!SDF.D#^SP,G94&\7?VS'];:+G\\=JR_?;V^/#U?+MO+QT]W?^YG__ZO[5O09L\]>MN1M__.7:IB -M/=HZO*[O2W<_('?U\.NG?_KUOQ+_(_0#G.=ZW/_K0S_C[OT_>FW?W?]C*[5& -M:]S_[]S_6V]J?=72?US_K92Q8L1JZB%A?_YJI0_QV^I<98KU5D=?:CT/0AU% -MKW6HH^@S0AU%CCINCF)?'S/4G#/Z4'/.T4+-N2)F4>NYV6+./=XIYHSA9JSK;INJW@[_]%;-#5OG_D8 -M+M9'G4W-.XZCOEV?M:FZ8\ZJZCXB5ON:AUW$G#4_N8LY:\F*Q)PUH@XQ9\WO -MB.HWFUBJWUHS8+'?Q]=)S9FG)]25F;^(K$>^]5?K8]UV_%^.8JI^CTN -M4V+.O,VTKN;,[2MJSHRWJSE[7@75G"/#4W/NJVK.F1LD]OGU^98Q;[VW*BI -MYNQYQ5!SYK=0]=M'7HC5G&-4U>]QFU)SSLQ+S9E?FZ;F7!F,F'/LZ8DY1^ZH -MZG<_]ZK?D1=ZU>]Q.[US_D=>F&Z?&O;U5=5SP=B?T]2\&:9Z+AAYHE7'>='N -MJN,\#4UU?-S^U9QSOP.H]?V/6#\>AMZM%_E@A'^$]W9Z`<.^H&#?N"@'SCH!P[Z@8/W -M?YR)?N"@'SCH!P[Z@8-^X*`?.'C_QYGH!P[Z@8-^X*`?..@'#OJ!@_=_G(E^ -MX*`?..@'#OJ!@W[@H!\X>/_'F>@'#OJ!@W[@H!\XZ`<.^H&#]W^9Z`<.^H&#?N"@'SCH!P[Z@8/W?YR)?N"@'SCH!P[Z -M@8-^X*`?.'C_QYGH!P[Z@8-^X*`?..@'#OJ!@_=_G(E^X*`?..@'#OJ!@W[@ -MH!\X>/_'F>@'#OJ!@WX\G__\_/OUR]/S]-],W7Z\O3\^6RO7S\=/?G?O;O`````````/`?\Q>.)E`. -$`/`````` -` -end diff --git a/lib/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu b/lib/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu new file mode 100644 index 000000000000..f8985b077b94 --- /dev/null +++ b/lib/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu @@ -0,0 +1,1370 @@ +$FreeBSD$ +begin 644 test_read_format_gtar_sparse_1_17.tar +M^[O0'H$?N"!!V@4A_GWJ8*$".\V -MK=Y8U1+KB\#H)L2G;BV77=?/EZ?K^]-#E31[WQYCC?+V<5/SSRG*:BU*1,_U -M6"O:Z?SG8\?ZZLOU^?)T/I^>/WR\^W,_^_Y_MFU!FSVV7?BV(Z__SEVJ8CTW -M:?>ROO_[WA.\_H=?[O+K?R5^(_1SK.M^_:\/?8Z[U__HM95X<_V/4ZDU6N7Z -M_\_7_]9Z4^NKEO[C^KM2QHH1:]MF]>RY_WV(WU;G*E.LMSKZ4NMY$.HH>JU# -M'46?$>HH.U6[[_7[^\VQ6 -MU?'^\E?SKNU+K<_],'Y<;SEQ$_.V,O,7B?7(J[_8UY:[=-OQ=CF*J?K=+U-B -MSGR;:5W-F=M7U)P9;U=S]KP*JCE'AJ?FW%;5G#,W2.SSR^7T=GVMH>;,TQQJ -MSMRU<>?\]VU'Q+SYX@G5<<_H5<<]7]"JX_WR+^;M&=X4\_;,L8I][;E14\W9 -M\XJAYLQ7H>JWC[P0JSG'J*K?_6U*S3DS+S5GOFR:FG-E,&+.L:4GYARYHZK? -M[=RK?D=>Z%6_^]OIG?,_\L)T^ZEA6U]5?2X8V^W_[5G'-[!U#KVY=8WS\,O5DO\H,1_A7NW^"@'SCH!P[Z@8-^X*`? -M.-Q^Z`\.^H&#?N"@'SCH!P[Z@8-^X.#^'T>B'SCH!P[Z@8-^X*`?..@'#N[_ -M<23Z@8-^X*`?..@'#OJ!@W[@X/X?1Z(?..@'#OJ!@W[@H!\XZ`<.[O]Q)/J! -M@W[@H!\XZ`<.^H&#?N#@_A]'HA\XZ`<.^H&#?N"@'SCH!P[N_W$D^H&#?N"@ -M'SCH!P[Z@8-^X.#^'T>B'SCH!P[Z@8-^X*`?..@'#N[_<23Z@8-^X*`?..@' -M#OJ!@W[@X/X?1Z(?..@'#OJ!@W[@H!\XZ`<.[O]Q)/J!@W[@H!\XZ`<.^H&# -M?N#@_A]'HA\XZ`<.^O%\^NO3']?/EZ?K^\<]1TFS]^TQUBAO'U^``````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!UF4],S$T-371E71E71E71E$AE861E6V-MYQ;&^BZ9Q=7C&:_A50_CMM_42]%^ -MG:>?Y?GU0KAT]?,OOZ[V.U^-7_X:UMYV(;F\=/'PH[N'V]_^N+_Y?5S[I9W]L#=,G'^W.R[_G/_ZOK7)U?/_+H?H^_FO -ML7CSWTU]?J'G7ZN?^P)PT6^ -M];]2]GMI5+)]`2SE/]$`W6[.Y-.;8YU+77?R7%?G8C8GSX7=G#W]]Q+K7`BG -M_U[R/H&GSPGW5Z;WYTUK[V9Z@>U!.[W!]J";7F%[T$_OL#W832^Q/1BGM_C* -MX/0:VX-)NL[1.>$>72?W1!N$<7A7MT2;K'+-UC -M$>[1&^$>O1/NT3OA'KT7[M%WPCWZ(-RCC\(]^B3=8Q;N\>DXGGZIG1'NL3NB -MW[0'CR@X[<$C&DY[\(B*TQX\HN.T!X\H.>W!(UK.*X/2/4I[3I#VG"#M.4': -MTZ0]IP@[3E1VG.BM.=$:<^)TIX3I3TG2GM.E/:< -M*.TY4=ISHK3G)&G/2=*>DZ0])TE[3I+VG"3M.4G:TZ6]IPL[3E9VG.RM.=D:<_)TIZ3I3TG2WM.D?:<(NTY1=ISBK3G%&G/*=*> -M4Z0]ITA[3IGH.;;XQL-UUWBX;O_G#]'X+#?(##?(##?(##?(##?(##6U^R!\TR`\TR`\TR`\TR`\TR`\T -MR`\TN/_'G,@/-,@/-,@/-,@/-,@/-,@/-+C_QYS(#S3(#S3(#S3(#S3(#S3( -M#S2X_\>5S#.7Z[O[NI_%KOQF',WT/4\6NV[W: -M%,SAZU[]NS7)>VNL[=S"U#]"6EP]GNG[O^EAW/:;>BG:K_/THSR_7@AGKOKM -ME]MA;6W)KOAH[+*^=_/C>W-?)_X=9S_L#9/GWQR>?UO/OPNFGO]W.43?SW\- -B_)O_;NKS"SW_`````````````````(#+]#?B%\M:`!@!```` -` -end diff --git a/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu b/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu new file mode 100644 index 000000000000..7fa0af9cc702 --- /dev/null +++ b/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu @@ -0,0 +1,1370 @@ +$FreeBSD$ +begin 644 test_read_format_gtar_sparse_1_17_posix01.tar +M+B]087A(96%D97)S+C,X-C8Q+W-P87)S90`````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````#`P,#`V-#0`,#`P,3``````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!UF4],S$T-3$AE861EGXG;,#F`_,,F5F>?QSN/ZR'3^O-=IE:K7:^O1DV -MV_7L>,*HYKR[M:X$O=V+)+^R.^AF^ZV]X.F_&E>)_G -MX;U\O3T1L5O\]ON?R\-GOMQ>_K->)JSYT?7?UU^G6XGA?31ZZ&FU4_2O6L6#RS\;)U<7_],.0LS&-8#+>7XU.8]2V./QOB[KZ+ -MY_>%^=1_J9_3\GS\O/[8?UR_7GY>_Y"O@#?6?]PMEZ?U/]YOQ<:OA,6[+*+' -M]3_F]NK/O?7XB:Y_KV'J%X"31C_36GYK_Q>/-^.M[_]JNO]+N_U?*<;^[SW$ -M]I_]7]_OWX'-G^\-GS:`??_RH:<=8)Q;[.MW;@+C[CJTPX9PO.YRWE_G\;JV -ML+\NNVL[_&X=KTLY_&X[_)T/U_+\O3R_!1E@)A,LR@A+,L.R#+$J4ZSJV^AT -M3M,YO9$DSDQRIR894[,,B<6_7M5F1,[G=-T3B]S4I`Y*.^BU@UX[Z+6#7COHM8->.^@?.[`^?>?YUB8ZW[YV_CO6%N#5 -M__\MQQ1,_O^WW?DOYLKY[Q2P?X<'_<"#?N!!/_"@'WC0#SR\_=`?/.@''O0# -M#_J!!_W`@W[@03_PX/R/*=$//.@''O0##_J!!_W`@W[@P?D?4Z(?>-`//.@' -M'O0##_J!!_W`@_,_ID0_\*`?>-`//.@''O0##_J!!^=_3(E^X$$_\*`?>-`/ -M/.@''O0##\[_F!+]P(-^X$$_\*`?>-`//.@''IS_,27Z@0?]P(-^X$$_\*`? -M>-`//#C_8TKT`P_Z@0?]P(-^X$$_\*`?>'#^QY3H!Q[T`P_Z@0?]P(-^X$$_ -M\.#\CRG1#SSH!Q[T`P_Z@0?]P(-^X,'Y'U.B'WC0#SSH!Q[T`P_Z@0?]P(/S -M/Z9$/_"@'WC0C\_R_.-P_V$]?%IOMLO4:K7SZR_7OVQOALUV?:09851SWMU: -M5X+>'HS7%KJ4+)CE-`N68['9XOY(\U]UM[T=-N-+\3[/PUOY>GLB8E@,MY=7 -MZY59WV*?:K#Y>-_%R_NF?IWX,8Z^V/_'F^L_Z/JW/Z'X-_ -9]>?>>OQ$US\``````/CY_0O4#S!&`/`````` -` -end diff --git a/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu b/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu new file mode 100644 index 000000000000..ca1f12b4b910 --- /dev/null +++ b/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu @@ -0,0 +1,1370 @@ +$FreeBSD$ +begin 644 test_read_format_gtar_sparse_1_17_posix10.tar +M+B]087A(96%D97)S+C,X-C8S+W-P87)S90`````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````#`P,#`V-#0`,#`P,3``````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!U``````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````````````````````!U +MF4].3DP,#`P,#$*,C`@ +M871I;64],3$Y.#(Y,S8P,PHR,"!C=&EM93TQ,3DX,CDS-C`Q"@`````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`"XO1TY54W!A``````````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````!UFX24EI=_0U.SWN!9\7WM48O?,^Q87S,96R6-V=\#6\Z-OV=MA,+\7Z//?O -MY>?Q3(2P^O.O?]:'[WQ]/?S[97/IET^N7MU,5]TR%+UZ,UR/EX?S9?3ZR&8< -M/F^OOH^7T:=<0UL&MQINKZ8_][ZWT&-Q87?MX^-K;CGWA_$;6E],7]S?^^_M -MW=7G\9?\!+RR_N-NN?RW_J?K/ON<%ZLW640/ZW]J\>C?O?;XF:[_N.R36);9 -MAZ6?3EL-^_.'MG]?\Z!^_^W\+_N -M_^L+]__3W4)X=@/0^_[#\,_L`.(S.P#/O<9;.W;_?ZJ?@*/K?[K-C,[+^O>[ -M^_^0(_?_;Z'WES8`87?NVF$S,)W7E/;G:3HOS>W/\^[<'_YOF3M\ -M"(=S>?XNS^^=#/!>)O@@(WR4&3[)$%]DBB_Z-JK.:3JGRYS@9$[P,B<$F1.2 -MS`E)YH2LGU>1.:'JG*9SNLR)3N;$('-BD#DQZL8LZ1>394XL,B=6G=-DSOW; -M_1IH!TT[Z-I!UPZZ=M"U@ZX= -M=.V@:P==.^@/'?@>N=^P8O\&"_J!!?W`@GY@03^PH!]86/NA/UC0#RSH!Q;T -M`POZ@07]P()^8,'^'W.B'UC0#RSH!Q;T`POZ@07]P(+]/^9$/["@'UC0#RSH -M!Q;T`POZ@07[?\R)?F!!/["@'UC0#RSH!Q;T`POV_Y@3_<""?F!!/["@'UC0 -M#RSH!Q;L_S$G^H$%_<""?F!!/["@'UC0#RS8_V-.]`,+^H$%_<""?F!!/["@ -M'UBP_\>[].'P:-]MU;*7$BYLO-W]LOPZ;[7BB&6Y24MH=?>[?RL_CF0AN-=Q>78^7 -MWO<6>BS.+Z=K'Y]>F_MUXMI-%M'#^I^"/_IW -5KSU^INL?````P._C!\JB`&$`\``` -` -end diff --git a/lib/libarchive/test/test_read_format_iso_gz.c b/lib/libarchive/test/test_read_format_iso_gz.c index 8aa864afb546..5a84a51e9435 100644 --- a/lib/libarchive/test/test_read_format_iso_gz.c +++ b/lib/libarchive/test/test_read_format_iso_gz.c @@ -53,6 +53,7 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_iso_gz) { +#if HAVE_ZLIB_H struct archive_entry *ae; struct archive *a; assert((a = archive_read_new()) != NULL); @@ -68,6 +69,9 @@ DEFINE_TEST(test_read_format_iso_gz) #else assert(0 == archive_read_finish(a)); #endif +#else + skipping("Need zlib"); +#endif } diff --git a/lib/libarchive/test/test_read_format_isorr_bz2.c b/lib/libarchive/test/test_read_format_isorr_bz2.c index a6ad83291f6e..a6478139e080 100644 --- a/lib/libarchive/test/test_read_format_isorr_bz2.c +++ b/lib/libarchive/test/test_read_format_isorr_bz2.c @@ -51,10 +51,17 @@ DEFINE_TEST(test_read_format_isorr_bz2) const void *p; size_t size; off_t offset; + int r; extract_reference_file(refname); assert((a = archive_read_new()) != NULL); - assertEqualInt(0, archive_read_support_compression_all(a)); + r = archive_read_support_compression_bzip2(a); + if (r == ARCHIVE_FATAL) { + skipping("Bzip2 decompression unsupported on this platform"); + archive_read_finish(a); + return; + } + assertEqualInt(0, r); assertEqualInt(0, archive_read_support_format_all(a)); assertEqualInt(0, archive_read_open_filename(a, refname, 10240)); @@ -70,7 +77,7 @@ DEFINE_TEST(test_read_format_isorr_bz2) assertEqualInt(0, archive_entry_uid(ae)); assertEqualIntA(a, ARCHIVE_EOF, archive_read_data_block(a, &p, &size, &offset)); - assertEqualInt(size, 0); + assertEqualInt((int)size, 0); /* A directory. */ assertEqualInt(0, archive_read_next_header(a, &ae)); @@ -89,7 +96,7 @@ DEFINE_TEST(test_read_format_isorr_bz2) assert(S_ISREG(archive_entry_stat(ae)->st_mode)); assertEqualInt(6, archive_entry_size(ae)); assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset)); - assertEqualInt(6, size); + assertEqualInt(6, (int)size); assertEqualInt(0, offset); assertEqualInt(0, memcmp(p, "hello\n", 6)); assertEqualInt(86401, archive_entry_mtime(ae)); diff --git a/lib/libarchive/test/test_read_format_pax_bz2.c b/lib/libarchive/test/test_read_format_pax_bz2.c index 9c5939404a84..9490440001f9 100644 --- a/lib/libarchive/test/test_read_format_pax_bz2.c +++ b/lib/libarchive/test/test_read_format_pax_bz2.c @@ -42,6 +42,7 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_pax_bz2) { +#if HAVE_BZLIB_H struct archive_entry *ae; struct archive *a; assert((a = archive_read_new()) != NULL); @@ -57,6 +58,9 @@ DEFINE_TEST(test_read_format_pax_bz2) #else assert(0 == archive_read_finish(a)); #endif +#else + skipping("Need bzlib"); +#endif } diff --git a/lib/libarchive/test/test_read_format_tbz.c b/lib/libarchive/test/test_read_format_tbz.c index b952b03c1a79..3b44592c4fce 100644 --- a/lib/libarchive/test/test_read_format_tbz.c +++ b/lib/libarchive/test/test_read_format_tbz.c @@ -35,6 +35,7 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_tbz) { +#if HAVE_BZLIB_H struct archive_entry *ae; struct archive *a; assert((a = archive_read_new()) != NULL); @@ -50,6 +51,9 @@ DEFINE_TEST(test_read_format_tbz) #else assert(0 == archive_read_finish(a)); #endif +#else + skipping("Need bzlib"); +#endif } diff --git a/lib/libarchive/test/test_read_format_tgz.c b/lib/libarchive/test/test_read_format_tgz.c index f046733a22da..67f8e8ad3441 100644 --- a/lib/libarchive/test/test_read_format_tgz.c +++ b/lib/libarchive/test/test_read_format_tgz.c @@ -34,6 +34,7 @@ static unsigned char archive[] = { DEFINE_TEST(test_read_format_tgz) { +#if HAVE_ZLIB_H struct archive_entry *ae; struct archive *a; assert((a = archive_read_new()) != NULL); @@ -49,6 +50,9 @@ DEFINE_TEST(test_read_format_tgz) #else assert(0 == archive_read_finish(a)); #endif +#else + skipping("Need zlib"); +#endif } diff --git a/lib/libarchive/test/test_read_format_zip.c b/lib/libarchive/test/test_read_format_zip.c index 06386ca6f759..77d6616181fa 100644 --- a/lib/libarchive/test/test_read_format_zip.c +++ b/lib/libarchive/test/test_read_format_zip.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_read_format_zip) { +#if HAVE_ZLIB_H const char *refname = "test_read_format_zip.zip"; struct archive_entry *ae; struct archive *a; @@ -52,7 +53,7 @@ DEFINE_TEST(test_read_format_zip) assertEqualInt(0, archive_entry_size(ae)); assertEqualIntA(a, ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o)); - assertEqualInt(s, 0); + assertEqualInt((int)s, 0); assertA(0 == archive_read_next_header(a, &ae)); assertEqualString("file1", archive_entry_pathname(ae)); assertEqualInt(1179604289, archive_entry_mtime(ae)); @@ -77,6 +78,9 @@ DEFINE_TEST(test_read_format_zip) #else assert(0 == archive_read_finish(a)); #endif +#else + skipping("Need zlib"); +#endif } diff --git a/lib/libarchive/test/test_read_large.c b/lib/libarchive/test/test_read_large.c index 6fdae3ff286f..c524ae8a85a6 100644 --- a/lib/libarchive/test/test_read_large.c +++ b/lib/libarchive/test/test_read_large.c @@ -34,7 +34,7 @@ DEFINE_TEST(test_read_large) { unsigned int i; int tmpfilefd; - char tmpfilename[] = "/tmp/test-read_large.XXXXXX"; + char tmpfilename[] = "test-read_large.XXXXXX"; size_t used; struct archive *a; struct archive_entry *entry; @@ -77,7 +77,7 @@ DEFINE_TEST(test_read_large) assertA(0 == archive_read_support_compression_all(a)); assertA(0 == archive_read_open_memory(a, buff, sizeof(buff))); assertA(0 == archive_read_next_header(a, &entry)); - assert(0 < (tmpfilefd = mkstemp(tmpfilename))); + assert(0 < (tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY, 0755))); assertA(0 == archive_read_data_into_fd(a, tmpfilefd)); close(tmpfilefd); #if ARCHIVE_VERSION_NUMBER < 2000000 diff --git a/lib/libarchive/test/test_tar_large.c b/lib/libarchive/test/test_tar_large.c index 542603d11d1e..f56dc6c0fe81 100644 --- a/lib/libarchive/test/test_tar_large.c +++ b/lib/libarchive/test/test_tar_large.c @@ -100,7 +100,7 @@ memory_write(struct archive *a, void *_private, const void *buff, size_t size) if ((const char *)filedata <= (const char *)buff && (const char *)buff < (const char *)filedata + filedatasize) { /* We don't need to store a block of file data. */ - private->last->filebytes += size; + private->last->filebytes += (off_t)size; } else { /* Yes, we're assuming the very first write is metadata. */ /* It's header or metadata, copy and save it. */ @@ -117,7 +117,7 @@ memory_write(struct archive *a, void *_private, const void *buff, size_t size) } block->next = NULL; } - return (size); + return ((long)size); } static ssize_t @@ -141,7 +141,7 @@ memory_read(struct archive *a, void *_private, const void **buff) * passing blocks from the template data. */ if (private->filebytes > (off_t)filedatasize) - size = filedatasize; + size = (ssize_t)filedatasize; else size = (ssize_t)private->filebytes; private->filebytes -= size; @@ -152,7 +152,7 @@ memory_read(struct archive *a, void *_private, const void **buff) */ block = private->first; private->first = block->next; - size = block->size; + size = (ssize_t)block->size; if (block->buff != NULL) { private->buff = block->buff; *buff = block->buff; @@ -220,7 +220,7 @@ DEFINE_TEST(test_tar_large) struct archive *a; off_t filesize, writesize; - filedatasize = 1 * MB; + filedatasize = (size_t)(1 * MB); filedata = malloc(filedatasize); memset(filedata, 0xAA, filedatasize); memset(&memdata, 0, sizeof(memdata)); @@ -236,7 +236,7 @@ DEFINE_TEST(test_tar_large) /* * Write a series of large files to it. */ - for (i = 0; tests[i] > 0; i++) { + for (i = 0; tests[i] != 0; i++) { assert((ae = archive_entry_new()) != NULL); sprintf(namebuff, "file_%d", i); archive_entry_copy_pathname(ae, namebuff); @@ -244,6 +244,7 @@ DEFINE_TEST(test_tar_large) filesize = tests[i]; if (filesize < 0) { + archive_entry_free(ae); skipping("32-bit off_t doesn't permit testing of very large files."); return; } @@ -256,7 +257,7 @@ DEFINE_TEST(test_tar_large) * Write the actual data to the archive. */ while (filesize > 0) { - writesize = filedatasize; + writesize = (off_t)filedatasize; if (writesize > filesize) writesize = filesize; assertA(writesize == archive_write_data(a, filedata, writesize)); diff --git a/lib/libarchive/test/test_ustar_filenames.c b/lib/libarchive/test/test_ustar_filenames.c index 3c842a31186d..09cb85744bef 100644 --- a/lib/libarchive/test/test_ustar_filenames.c +++ b/lib/libarchive/test/test_ustar_filenames.c @@ -43,7 +43,7 @@ test_filename(const char *prefix, int dlen, int flen) if (prefix != NULL) { strcpy(filename, prefix); - i = strlen(prefix); + i = (int)strlen(prefix); } if (dlen > 0) { for (; i < dlen; i++) diff --git a/lib/libarchive/test/test_write_compress.c b/lib/libarchive/test/test_write_compress.c index 4dc51b8302c4..e1b8f3c86371 100644 --- a/lib/libarchive/test/test_write_compress.c +++ b/lib/libarchive/test/test_write_compress.c @@ -88,7 +88,7 @@ DEFINE_TEST(test_write_compress) if (!assertEqualInt(0, archive_read_next_header(a, &ae))) break; assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt(datasize, archive_entry_size(ae)); + assertEqualInt((int)datasize, archive_entry_size(ae)); } assert(0 == archive_read_close(a)); #if ARCHIVE_VERSION_NUMBER < 2000000 diff --git a/lib/libarchive/test/test_write_compress_program.c b/lib/libarchive/test/test_write_compress_program.c index c5d1d9aa2182..9b525e6d13a2 100644 --- a/lib/libarchive/test/test_write_compress_program.c +++ b/lib/libarchive/test/test_write_compress_program.c @@ -37,12 +37,18 @@ DEFINE_TEST(test_write_compress_program) struct archive *a; size_t used; int blocksize = 1024; + int r; /* Create a new archive in memory. */ /* Write it through an external "gzip" program. */ assert((a = archive_write_new()) != NULL); assertA(0 == archive_write_set_format_ustar(a)); - assertA(0 == archive_write_set_compression_program(a, "gzip")); + r = archive_write_set_compression_program(a, "gzip"); + if (r == ARCHIVE_FATAL) { + skipping("Write compression via external program unsupported on this platform"); + archive_write_finish(a); + return; + } assertA(0 == archive_write_set_bytes_per_block(a, blocksize)); assertA(0 == archive_write_set_bytes_in_last_block(a, blocksize)); assertA(blocksize == archive_write_get_bytes_in_last_block(a)); diff --git a/lib/libarchive/test/test_write_disk.c b/lib/libarchive/test/test_write_disk.c index ae87c774e029..789f5714821a 100644 --- a/lib/libarchive/test/test_write_disk.c +++ b/lib/libarchive/test/test_write_disk.c @@ -52,7 +52,9 @@ static void create(struct archive_entry *ae, const char *msg) * that automatically. */ if (archive_entry_filetype(ae) == AE_IFDIR) st.st_mode &= ~S_ISGID; +#ifndef _WIN32 assertEqualInt(st.st_mode, archive_entry_mode(ae) & ~UMASK); +#endif } static void create_reg_file(struct archive_entry *ae, const char *msg) @@ -97,8 +99,10 @@ static void create_reg_file(struct archive_entry *ae, const char *msg) assert(0 == stat(archive_entry_pathname(ae), &st)); failure("st.st_mode=%o archive_entry_mode(ae)=%o", st.st_mode, archive_entry_mode(ae)); +#ifndef _WIN32 assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); - assertEqualInt(st.st_size, sizeof(data)); +#endif + assertEqualInt(st.st_size, sizeof(data)); /* test_write_disk_times has more detailed tests of this area. */ assertEqualInt(st.st_mtime, 123456789); failure("No atime was specified, so atime should get set to current time"); @@ -142,7 +146,9 @@ static void create_reg_file2(struct archive_entry *ae, const char *msg) assert(0 == stat(archive_entry_pathname(ae), &st)); failure("st.st_mode=%o archive_entry_mode(ae)=%o", st.st_mode, archive_entry_mode(ae)); +#ifndef _WIN32 assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); +#endif assertEqualInt(st.st_size, i); compare = malloc(datasize); @@ -177,7 +183,9 @@ static void create_reg_file3(struct archive_entry *ae, const char *msg) assert(0 == stat(archive_entry_pathname(ae), &st)); failure("st.st_mode=%o archive_entry_mode(ae)=%o", st.st_mode, archive_entry_mode(ae)); +#ifndef _WIN32 assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); +#endif assertEqualInt(st.st_size, 5); } @@ -204,7 +212,9 @@ static void create_reg_file4(struct archive_entry *ae, const char *msg) assert(0 == stat(archive_entry_pathname(ae), &st)); failure("st.st_mode=%o archive_entry_mode(ae)=%o", st.st_mode, archive_entry_mode(ae)); +#ifndef _WIN32 assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); +#endif failure(msg); assertEqualInt(st.st_size, sizeof(data)); } diff --git a/lib/libarchive/test/test_write_disk_hardlink.c b/lib/libarchive/test/test_write_disk_hardlink.c index 6e38d86b5bc6..f9bcfae6cbc2 100644 --- a/lib/libarchive/test/test_write_disk_hardlink.c +++ b/lib/libarchive/test/test_write_disk_hardlink.c @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); */ DEFINE_TEST(test_write_disk_hardlink) { -#if ARCHIVE_VERSION_NUMBER < 1009000 +#if ARCHIVE_VERSION_NUMBER < 1009000 || defined(_WIN32) skipping("archive_write_disk_hardlink tests"); #else static const char data[]="abcdefghijklmnopqrstuvwxyz"; diff --git a/lib/libarchive/test/test_write_disk_perms.c b/lib/libarchive/test/test_write_disk_perms.c index 4bec700df963..87e2a2d168aa 100644 --- a/lib/libarchive/test/test_write_disk_perms.c +++ b/lib/libarchive/test/test_write_disk_perms.c @@ -25,7 +25,7 @@ #include "test.h" __FBSDID("$FreeBSD$"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 +#if ARCHIVE_VERSION_NUMBER >= 1009000 && !defined(_WIN32) #define UMASK 022 @@ -125,7 +125,7 @@ defaultgid(void) DEFINE_TEST(test_write_disk_perms) { -#if ARCHIVE_VERSION_NUMBER < 1009000 +#if ARCHIVE_VERSION_NUMBER < 1009000 || defined(_WIN32) skipping("archive_write_disk interface"); #else struct archive *a; diff --git a/lib/libarchive/test/test_write_disk_secure.c b/lib/libarchive/test/test_write_disk_secure.c index b898c97119e4..4c014b164057 100644 --- a/lib/libarchive/test/test_write_disk_secure.c +++ b/lib/libarchive/test/test_write_disk_secure.c @@ -55,6 +55,7 @@ DEFINE_TEST(test_write_disk_secure) archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); +#ifndef _WIN32 /* Write a symlink to the dir above. */ assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "link_to_dir"); @@ -149,6 +150,7 @@ DEFINE_TEST(test_write_disk_secure) assertEqualInt(0, lstat("link_to_dir4", &st)); assert(S_ISDIR(st.st_mode)); archive_entry_free(ae); +#endif /* * As above, but a link to a non-dir, so the link should get replaced. @@ -185,6 +187,7 @@ DEFINE_TEST(test_write_disk_secure) assert(0 == archive_write_finish(a)); #endif +#ifndef _WIN32 /* Test the entries on disk. */ assert(0 == lstat("dir", &st)); failure("dir: st.st_mode=%o", st.st_mode); @@ -217,4 +220,5 @@ DEFINE_TEST(test_write_disk_secure) failure("link_to_dir2/filec: st.st_mode=%o", st.st_mode); assert((st.st_mode & 07777) == 0755); #endif +#endif } diff --git a/lib/libarchive/test/test_write_format_ar.c b/lib/libarchive/test/test_write_format_ar.c index 6f54139944e1..81224b37f428 100644 --- a/lib/libarchive/test/test_write_format_ar.c +++ b/lib/libarchive/test/test_write_format_ar.c @@ -46,7 +46,6 @@ DEFINE_TEST(test_write_format_ar) */ assert((a = archive_write_new()) != NULL); assertA(0 == archive_write_set_format_ar_svr4(a)); - assertA(0 == archive_write_set_compression_gzip(a)); assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); /* write the filename table */ @@ -153,7 +152,6 @@ DEFINE_TEST(test_write_format_ar) memset(buff, 0, sizeof(buff)); assert((a = archive_write_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ar_bsd(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a)); assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used)); /* write a entry need long name extension */ diff --git a/lib/libarchive/test/test_write_format_cpio_newc.c b/lib/libarchive/test/test_write_format_cpio_newc.c index 83c88ad7d331..512df7422912 100644 --- a/lib/libarchive/test/test_write_format_cpio_newc.c +++ b/lib/libarchive/test/test_write_format_cpio_newc.c @@ -205,7 +205,7 @@ DEFINE_TEST(test_write_format_cpio_newc) assertEqualMem(e + 121, "\0\0\0", 3); /* Pad to multiple of 4 bytes */ e += 124; /* Must be multiple of four here! */ - assertEqualInt(used, e - buff); + assertEqualInt((int)used, e - buff); free(buff); } diff --git a/lib/libarchive/test/test_write_format_cpio_odc.c b/lib/libarchive/test/test_write_format_cpio_odc.c index 0434a84c3317..73cc3e6218c5 100644 --- a/lib/libarchive/test/test_write_format_cpio_odc.c +++ b/lib/libarchive/test/test_write_format_cpio_odc.c @@ -218,7 +218,7 @@ DEFINE_TEST(test_write_format_cpio_odc) assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */ e += 87; - assertEqualInt(used, e - buff); + assertEqualInt((int)used, e - buff); free(buff); } diff --git a/lib/libarchive/test/test_write_format_tar.c b/lib/libarchive/test/test_write_format_tar.c index 7cd11bf08487..ef210e63ff21 100644 --- a/lib/libarchive/test/test_write_format_tar.c +++ b/lib/libarchive/test/test_write_format_tar.c @@ -42,8 +42,8 @@ DEFINE_TEST(test_write_format_tar) assert((a = archive_write_new()) != NULL); assertA(0 == archive_write_set_format_ustar(a)); assertA(0 == archive_write_set_compression_none(a)); - assertA(0 == archive_write_set_bytes_per_block(a, blocksize)); - assertA(0 == archive_write_set_bytes_in_last_block(a, blocksize)); + assertA(0 == archive_write_set_bytes_per_block(a, (int)blocksize)); + assertA(0 == archive_write_set_bytes_in_last_block(a, (int)blocksize)); assertA(blocksize == (size_t)archive_write_get_bytes_in_last_block(a)); assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); assertA(blocksize == (size_t)archive_write_get_bytes_in_last_block(a)); diff --git a/lib/libarchive/test/test_write_format_tar_empty.c b/lib/libarchive/test/test_write_format_tar_empty.c index 538bccfe26d7..570325379556 100644 --- a/lib/libarchive/test/test_write_format_tar_empty.c +++ b/lib/libarchive/test/test_write_format_tar_empty.c @@ -83,7 +83,7 @@ DEFINE_TEST(test_write_format_tar_empty) /* Earlier versions wrote 0-length files for empty tar archives. */ skipping("empty tar archive size"); #else - assertEqualInt(used, 1024); + assertEqualInt((int)used, 1024); #endif for (i = 0; i < used; i++) { failure("Empty tar archive should be all nulls."); diff --git a/lib/libarchive/test/test_write_format_tar_ustar.c b/lib/libarchive/test/test_write_format_tar_ustar.c index 53d21e15ab68..3adacb4e90d1 100644 --- a/lib/libarchive/test/test_write_format_tar_ustar.c +++ b/lib/libarchive/test/test_write_format_tar_ustar.c @@ -340,7 +340,7 @@ DEFINE_TEST(test_write_format_tar_ustar) assert(is_null(e, 1024)); e += 1024; - assertEqualInt(used, e - buff); + assertEqualInt((int)used, e - buff); free(buff); } diff --git a/lib/libarchive/test/test_write_open_memory.c b/lib/libarchive/test/test_write_open_memory.c index d5f982c74a11..14ce6e972fb0 100644 --- a/lib/libarchive/test/test_write_open_memory.c +++ b/lib/libarchive/test/test_write_open_memory.c @@ -50,7 +50,7 @@ DEFINE_TEST(test_write_open_memory) assert((a = archive_write_new()) != NULL); assertA(0 == archive_write_set_format_ustar(a)); assertA(0 == archive_write_set_bytes_in_last_block(a, 1)); - assertA(0 == archive_write_set_bytes_per_block(a, blocksize)); + assertA(0 == archive_write_set_bytes_per_block(a, (int)blocksize)); buff[i] = 0xAE; assertA(0 == archive_write_open_memory(a, buff, i, &s)); /* If buffer is smaller than a tar header, this should fail. */