svn commit: r189308 - in head/lib/libarchive: . test
Tim Kientzle
kientzle at FreeBSD.org
Tue Mar 3 09:02:54 PST 2009
Author: kientzle
Date: Tue Mar 3 17:02:51 2009
New Revision: 189308
URL: http://svn.freebsd.org/changeset/base/189308
Log:
Merge r294:337,r348:350 from libarchive.googlecode.com: A lot
of work to make libarchive work on Windows.
Added:
head/lib/libarchive/test/test_compat_gtar_1.tar.uu (contents, props changed)
head/lib/libarchive/test/test_pax_filename_encoding.tar.uu (contents, props changed)
head/lib/libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu (contents, props changed)
head/lib/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu (contents, props changed)
head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu (contents, props changed)
head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu (contents, props changed)
head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu (contents, props changed)
Deleted:
head/lib/libarchive/test/test_compat_gtar_1.tgz.uu
head/lib/libarchive/test/test_pax_filename_encoding.tar.gz.uu
head/lib/libarchive/test/test_read_format_gtar_sparse_1_13.tgz.uu
head/lib/libarchive/test/test_read_format_gtar_sparse_1_17.tgz.uu
head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tgz.uu
head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tgz.uu
head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tgz.uu
Modified:
head/lib/libarchive/archive.h
head/lib/libarchive/archive_entry.c
head/lib/libarchive/archive_string.c
head/lib/libarchive/archive_write_disk.c
head/lib/libarchive/archive_write_set_format_pax.c
head/lib/libarchive/test/ (props changed)
head/lib/libarchive/test/main.c
head/lib/libarchive/test/read_open_memory.c
head/lib/libarchive/test/test.h
head/lib/libarchive/test/test_acl_pax.c
head/lib/libarchive/test/test_compat_bzip2.c
head/lib/libarchive/test/test_compat_gtar.c
head/lib/libarchive/test/test_compat_gzip.c
head/lib/libarchive/test/test_compat_zip.c
head/lib/libarchive/test/test_empty_write.c
head/lib/libarchive/test/test_entry.c
head/lib/libarchive/test/test_fuzz.c
head/lib/libarchive/test/test_pax_filename_encoding.c
head/lib/libarchive/test/test_read_compress_program.c
head/lib/libarchive/test/test_read_extract.c
head/lib/libarchive/test/test_read_format_cpio_bin_bz2.c
head/lib/libarchive/test/test_read_format_cpio_bin_gz.c
head/lib/libarchive/test/test_read_format_cpio_svr4_gzip.c
head/lib/libarchive/test/test_read_format_empty.c
head/lib/libarchive/test/test_read_format_gtar_gz.c
head/lib/libarchive/test/test_read_format_gtar_sparse.c
head/lib/libarchive/test/test_read_format_iso_gz.c
head/lib/libarchive/test/test_read_format_isorr_bz2.c
head/lib/libarchive/test/test_read_format_pax_bz2.c
head/lib/libarchive/test/test_read_format_tbz.c
head/lib/libarchive/test/test_read_format_tgz.c
head/lib/libarchive/test/test_read_format_zip.c
head/lib/libarchive/test/test_read_large.c
head/lib/libarchive/test/test_tar_large.c
head/lib/libarchive/test/test_ustar_filenames.c
head/lib/libarchive/test/test_write_compress.c
head/lib/libarchive/test/test_write_compress_program.c
head/lib/libarchive/test/test_write_disk.c
head/lib/libarchive/test/test_write_disk_hardlink.c
head/lib/libarchive/test/test_write_disk_perms.c
head/lib/libarchive/test/test_write_disk_secure.c
head/lib/libarchive/test/test_write_format_ar.c
head/lib/libarchive/test/test_write_format_cpio_newc.c
head/lib/libarchive/test/test_write_format_cpio_odc.c
head/lib/libarchive/test/test_write_format_tar.c
head/lib/libarchive/test/test_write_format_tar_empty.c
head/lib/libarchive/test/test_write_format_tar_ustar.c
head/lib/libarchive/test/test_write_open_memory.c
Modified: head/lib/libarchive/archive.h
==============================================================================
--- head/lib/libarchive/archive.h Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/archive.h Tue Mar 3 17:02:51 2009 (r189308)
@@ -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
Modified: head/lib/libarchive/archive_entry.c
==============================================================================
--- head/lib/libarchive/archive_entry.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/archive_entry.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -62,6 +62,9 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
+#ifdef _WIN32
+#include <windows.h>
+#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);
}
Modified: head/lib/libarchive/archive_string.c
==============================================================================
--- head/lib/libarchive/archive_string.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/archive_string.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
+#ifdef _WIN32
+#include <windows.h>
+#endif
#include "archive_private.h"
#include "archive_string.h"
@@ -175,6 +178,7 @@ __archive_strappend_int(struct archive_s
return (as);
}
+#ifndef _WIN32
/*
* Home-grown wctomb for UTF-8.
*/
@@ -375,3 +379,83 @@ __archive_string_utf8_w(struct archive_s
*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 */
Modified: head/lib/libarchive/archive_write_disk.c
==============================================================================
--- head/lib/libarchive/archive_write_disk.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/archive_write_disk.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -83,6 +83,9 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
+#ifdef _WIN32
+#include <windows.h>
+#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_di
"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_di
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_di
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 *n
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;
Modified: head/lib/libarchive/archive_write_set_format_pax.c
==============================================================================
--- head/lib/libarchive/archive_write_set_format_pax.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/archive_write_set_format_pax.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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) {
Modified: head/lib/libarchive/test/main.c
==============================================================================
--- head/lib/libarchive/test/main.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/main.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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 *t
/* 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))
Modified: head/lib/libarchive/test/read_open_memory.c
==============================================================================
--- head/lib/libarchive/test/read_open_memory.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/read_open_memory.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -107,7 +107,7 @@ memory_read(struct archive *a, void *cli
*buff = mine->copy_buff;
mine->buffer += size;
- return (size);
+ return ((ssize_t)size);
}
/*
Modified: head/lib/libarchive/test/test.h
==============================================================================
--- head/lib/libarchive/test/test.h Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/test.h Tue Mar 3 17:02:51 2009 (r189308)
@@ -45,7 +45,11 @@
#error Oops: No config.h and no pre-built configuration in test.h.
#endif
+#ifndef _WIN32
#include <dirent.h>
+#else
+#include <direct.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -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.
*/
Modified: head/lib/libarchive/test/test_acl_pax.c
==============================================================================
--- head/lib/libarchive/test/test_acl_pax.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/test_acl_pax.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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()));
Modified: head/lib/libarchive/test/test_compat_bzip2.c
==============================================================================
--- head/lib/libarchive/test/test_compat_bzip2.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/test_compat_bzip2.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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
}
Modified: head/lib/libarchive/test/test_compat_gtar.c
==============================================================================
--- head/lib/libarchive/test/test_compat_gtar.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/test_compat_gtar.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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));
Added: head/lib/libarchive/test/test_compat_gtar_1.tar.uu
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/lib/libarchive/test/test_compat_gtar_1.tar.uu Tue Mar 3 17:02:51 2009 (r189308)
@@ -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,#<P,0`@3```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<B`@`')O;W0`
+M````````````````````````````````````=VAE96P`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X
+M.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S
+M-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X
+M.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S
+M-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,```````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````#$R,S0U-C<X.3`Q
+M,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V
+M-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.0`Q
+M,#`V-#0@`"`@,3<U,"``("`Q-S4P(``@("`@("`@("`@,"`Q,#<R-C<P,#$W
+M,R`@,C$P,C``(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(@(`!T:6T`````````````````
+M`````````````````````'1I;0``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````+B\N+T!,;VYG3&EN:P``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````"`@("`@,"``("`@("`P(``@("`@(#`@`"`@("`@
+M("`@,S$Q("`@("`@("`@("`P("`Q,#<P,``@2P``````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!U<W1A<B`@
+M`')O;W0`````````````````````````````````````=VAE96P`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R
+M,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W
+M.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R
+M,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W
+M.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,```
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````"XO+B]`
+M3&]N9TQI;FL`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````@("`@(#`@`"`@("`@,"``("`@("`P(``@("`@("`@(#,Q,2`@("`@
+M("`@("`@,"`@,3`W,#$`($P`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````=7-T87(@(`!R;V]T````````
+M`````````````````````````````'=H965L````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C
+M9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H
+M:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C
+M9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H
+M:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6H`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A8F-D969G:&EJ86)C9&5F
+M9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA
+M8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&D`,3(P-S4U
+M(``@(#$W-3`@`"`@,3<U,"``("`@("`@("`@(#`@,3`W,C8W,#`R-#,@(#0T
+M-3(Q`"`R,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y
+M,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S at Y,#$R,S0U-C<X.3`Q,C,T
+M-38W.#DP,3(S-#4V-S at Y`'5S=&%R("``=&EM````````````````````````
+M``````````````!T:6T`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+9````````````````````````````````````
+`
+end
Modified: head/lib/libarchive/test/test_compat_gzip.c
==============================================================================
--- head/lib/libarchive/test/test_compat_gzip.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/test_compat_gzip.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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
}
Modified: head/lib/libarchive/test/test_compat_zip.c
==============================================================================
--- head/lib/libarchive/test/test_compat_zip.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/test_compat_zip.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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
}
Modified: head/lib/libarchive/test/test_empty_write.c
==============================================================================
--- head/lib/libarchive/test/test_empty_write.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/test_empty_write.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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);
-
- /* 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
+ 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));
+
+ /* 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);
-
- /* 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
-
+ 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));
+ 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
}
Modified: head/lib/libarchive/test/test_entry.c
==============================================================================
--- head/lib/libarchive/test/test_entry.c Tue Mar 3 16:56:15 2009 (r189307)
+++ head/lib/libarchive/test/test_entry.c Tue Mar 3 17:02:51 2009 (r189308)
@@ -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);
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-all
mailing list