diff options
Diffstat (limited to 'archivers/libarchive/files/libarchive/test')
76 files changed, 0 insertions, 14114 deletions
diff --git a/archivers/libarchive/files/libarchive/test/list.h b/archivers/libarchive/files/libarchive/test/list.h deleted file mode 100644 index 10efb873a64..00000000000 --- a/archivers/libarchive/files/libarchive/test/list.h +++ /dev/null @@ -1,106 +0,0 @@ -DEFINE_TEST(test_acl_basic) -DEFINE_TEST(test_acl_freebsd) -DEFINE_TEST(test_acl_pax) -DEFINE_TEST(test_archive_api_feature) -DEFINE_TEST(test_bad_fd) -DEFINE_TEST(test_compat_bzip2) -DEFINE_TEST(test_compat_cpio) -DEFINE_TEST(test_compat_gtar) -DEFINE_TEST(test_compat_gzip) -DEFINE_TEST(test_compat_lzma) -DEFINE_TEST(test_compat_solaris_tar_acl) -DEFINE_TEST(test_compat_tar_hardlink) -DEFINE_TEST(test_compat_xz) -DEFINE_TEST(test_compat_zip) -DEFINE_TEST(test_empty_write) -DEFINE_TEST(test_entry) -DEFINE_TEST(test_entry_strmode) -DEFINE_TEST(test_extattr_freebsd) -DEFINE_TEST(test_fuzz) -DEFINE_TEST(test_link_resolver) -DEFINE_TEST(test_open_fd) -DEFINE_TEST(test_open_file) -DEFINE_TEST(test_open_filename) -DEFINE_TEST(test_pax_filename_encoding) -DEFINE_TEST(test_read_compress_program) -DEFINE_TEST(test_read_data_large) -DEFINE_TEST(test_read_disk) -DEFINE_TEST(test_read_disk_entry_from_file) -DEFINE_TEST(test_read_extract) -DEFINE_TEST(test_read_file_nonexistent) -DEFINE_TEST(test_read_format_ar) -DEFINE_TEST(test_read_format_cpio_bin) -DEFINE_TEST(test_read_format_cpio_bin_Z) -DEFINE_TEST(test_read_format_cpio_bin_be) -DEFINE_TEST(test_read_format_cpio_bin_bz2) -DEFINE_TEST(test_read_format_cpio_bin_gz) -DEFINE_TEST(test_read_format_cpio_bin_lzma) -DEFINE_TEST(test_read_format_cpio_bin_xz) -DEFINE_TEST(test_read_format_cpio_odc) -DEFINE_TEST(test_read_format_cpio_svr4_bzip2_rpm) -DEFINE_TEST(test_read_format_cpio_svr4_gzip) -DEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm) -DEFINE_TEST(test_read_format_cpio_svr4c_Z) -DEFINE_TEST(test_read_format_empty) -DEFINE_TEST(test_read_format_gtar_gz) -DEFINE_TEST(test_read_format_gtar_lzma) -DEFINE_TEST(test_read_format_gtar_sparse) -DEFINE_TEST(test_read_format_iso_gz) -DEFINE_TEST(test_read_format_iso_multi_extent) -DEFINE_TEST(test_read_format_isojoliet_bz2) -DEFINE_TEST(test_read_format_isojoliet_long) -DEFINE_TEST(test_read_format_isojoliet_rr) -DEFINE_TEST(test_read_format_isorr_bz2) -DEFINE_TEST(test_read_format_isorr_ce) -DEFINE_TEST(test_read_format_isorr_new_bz2) -DEFINE_TEST(test_read_format_isorr_rr_moved) -DEFINE_TEST(test_read_format_isozisofs_bz2) -DEFINE_TEST(test_read_format_mtree) -DEFINE_TEST(test_read_format_pax_bz2) -DEFINE_TEST(test_read_format_raw) -DEFINE_TEST(test_read_format_tar) -DEFINE_TEST(test_read_format_tar_empty_filename) -DEFINE_TEST(test_read_format_tbz) -DEFINE_TEST(test_read_format_tgz) -DEFINE_TEST(test_read_format_tlz) -DEFINE_TEST(test_read_format_txz) -DEFINE_TEST(test_read_format_tz) -DEFINE_TEST(test_read_format_xar) -DEFINE_TEST(test_read_format_zip) -DEFINE_TEST(test_read_large) -DEFINE_TEST(test_read_pax_truncated) -DEFINE_TEST(test_read_position) -DEFINE_TEST(test_read_truncated) -DEFINE_TEST(test_read_uu) -DEFINE_TEST(test_tar_filenames) -DEFINE_TEST(test_tar_large) -DEFINE_TEST(test_ustar_filenames) -DEFINE_TEST(test_write_compress) -DEFINE_TEST(test_write_compress_bzip2) -DEFINE_TEST(test_write_compress_gzip) -DEFINE_TEST(test_write_compress_lzma) -DEFINE_TEST(test_write_compress_program) -DEFINE_TEST(test_write_compress_xz) -DEFINE_TEST(test_write_disk) -DEFINE_TEST(test_write_disk_failures) -DEFINE_TEST(test_write_disk_hardlink) -DEFINE_TEST(test_write_disk_perms) -DEFINE_TEST(test_write_disk_secure) -DEFINE_TEST(test_write_disk_sparse) -DEFINE_TEST(test_write_disk_symlink) -DEFINE_TEST(test_write_disk_times) -DEFINE_TEST(test_write_format_ar) -DEFINE_TEST(test_write_format_cpio) -DEFINE_TEST(test_write_format_cpio_empty) -DEFINE_TEST(test_write_format_cpio_newc) -DEFINE_TEST(test_write_format_cpio_odc) -DEFINE_TEST(test_write_format_mtree) -DEFINE_TEST(test_write_format_pax) -DEFINE_TEST(test_write_format_shar_empty) -DEFINE_TEST(test_write_format_tar) -DEFINE_TEST(test_write_format_tar_empty) -DEFINE_TEST(test_write_format_tar_ustar) -DEFINE_TEST(test_write_format_zip) -DEFINE_TEST(test_write_format_zip_empty) -DEFINE_TEST(test_write_format_zip_no_compression) -DEFINE_TEST(test_write_open_memory) diff --git a/archivers/libarchive/files/libarchive/test/main.c b/archivers/libarchive/files/libarchive/test/main.c deleted file mode 100644 index b143074d119..00000000000 --- a/archivers/libarchive/files/libarchive/test/main.c +++ /dev/null @@ -1,2114 +0,0 @@ -/* - * Copyright (c) 2003-2009 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "test.h" -#include <errno.h> -#include <locale.h> -#include <stdarg.h> -#include <time.h> - -/* - * This same file is used pretty much verbatim for all test harnesses. - * - * The next few lines are the only differences. - * TODO: Move this into a separate configuration header, have all test - * suites share one copy of this file. - */ -__FBSDID("$FreeBSD: head/lib/libarchive/test/main.c 201247 2009-12-30 05:59:21Z kientzle $"); -#define KNOWNREF "test_compat_gtar_1.tar.uu" -#define ENVBASE "LIBARCHIVE" /* Prefix for environment variables. */ -#undef PROGRAM /* Testing a library, not a program. */ -#define LIBRARY "libarchive" -#define EXTRA_DUMP(x) archive_error_string((struct archive *)(x)) -#define EXTRA_VERSION archive_version() - -/* - * - * Windows support routines - * - * Note: Configuration is a tricky issue. Using HAVE_* feature macros - * in the test harness is dangerous because they cover up - * configuration errors. The classic example of this is omitting a - * configure check. If libarchive and libarchive_test both look for - * the same feature macro, such errors are hard to detect. Platform - * macros (e.g., _WIN32 or __GNUC__) are a little better, but can - * easily lead to very messy code. It's best to limit yourself - * to only the most generic programming techniques in the test harness - * and thus avoid conditionals altogether. Where that's not possible, - * try to minimize conditionals by grouping platform-specific tests in - * one place (e.g., test_acl_freebsd) or by adding new assert() - * functions (e.g., assertMakeHardlink()) to cover up platform - * differences. Platform-specific coding in libarchive_test is often - * a symptom that some capability is missing from libarchive itself. - */ -#if defined(_WIN32) && !defined(__CYGWIN__) -#include <io.h> -#include <windows.h> -#ifndef F_OK -#define F_OK (0) -#endif -#ifndef S_ISDIR -#define S_ISDIR(m) ((m) & _S_IFDIR) -#endif -#ifndef S_ISREG -#define S_ISREG(m) ((m) & _S_IFREG) -#endif -#if !defined(__BORLANDC__) -#define access _access -#define chdir _chdir -#endif -#ifndef fileno -#define fileno _fileno -#endif -/*#define fstat _fstat64*/ -#if !defined(__BORLANDC__) -#define getcwd _getcwd -#endif -#define lstat stat -/*#define lstat _stat64*/ -/*#define stat _stat64*/ -#define rmdir _rmdir -#if !defined(__BORLANDC__) -#define strdup _strdup -#define umask _umask -#endif -#define int64_t __int64 -#endif - -#if defined(HAVE__CrtSetReportMode) -# include <crtdbg.h> -#endif - -#if defined(_WIN32) && !defined(__CYGWIN__) -void *GetFunctionKernel32(const char *name) -{ - static HINSTANCE lib; - static int set; - if (!set) { - set = 1; - lib = LoadLibrary("kernel32.dll"); - } - if (lib == NULL) { - fprintf(stderr, "Can't load kernel32.dll?!\n"); - exit(1); - } - return (void *)GetProcAddress(lib, name); -} - -static int -my_CreateSymbolicLinkA(const char *linkname, const char *target, int flags) -{ - static BOOLEAN (WINAPI *f)(LPCSTR, LPCSTR, DWORD); - static int set; - if (!set) { - set = 1; - f = GetFunctionKernel32("CreateSymbolicLinkA"); - } - return f == NULL ? 0 : (*f)(linkname, target, flags); -} - -static int -my_CreateHardLinkA(const char *linkname, const char *target) -{ - static BOOLEAN (WINAPI *f)(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES); - static int set; - if (!set) { - set = 1; - f = GetFunctionKernel32("CreateHardLinkA"); - } - return f == NULL ? 0 : (*f)(linkname, target, NULL); -} - -int -my_GetFileInformationByName(const char *path, BY_HANDLE_FILE_INFORMATION *bhfi) -{ - HANDLE h; - int r; - - memset(bhfi, 0, sizeof(*bhfi)); - h = CreateFile(path, FILE_READ_ATTRIBUTES, 0, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_HANDLE_VALUE) - return (0); - r = GetFileInformationByHandle(h, bhfi); - CloseHandle(h); - return (r); -} -#endif - -#if defined(HAVE__CrtSetReportMode) -static void -invalid_parameter_handler(const wchar_t * expression, - const wchar_t * function, const wchar_t * file, - unsigned int line, uintptr_t pReserved) -{ - /* nop */ -} -#endif - -/* - * - * OPTIONS FLAGS - * - */ - -/* Enable core dump on failure. */ -static int dump_on_failure = 0; -/* Default is to remove temp dirs and log data for successful tests. */ -static int keep_temp_files = 0; -/* Default is to just report pass/fail for each test. */ -static int verbosity = 0; -#define VERBOSITY_SUMMARY_ONLY -1 /* -q */ -#define VERBOSITY_PASSFAIL 0 /* Default */ -#define VERBOSITY_LIGHT_REPORT 1 /* -v */ -#define VERBOSITY_FULL 2 /* -vv */ -/* A few places generate even more output for verbosity > VERBOSITY_FULL, - * mostly for debugging the test harness itself. */ -/* Cumulative count of assertion failures. */ -static int failures = 0; -/* Cumulative count of reported skips. */ -static int skips = 0; -/* Cumulative count of assertions checked. */ -static int assertions = 0; - -/* Directory where uuencoded reference files can be found. */ -static const char *refdir; - -/* - * Report log information selectively to console and/or disk log. - */ -static int log_console = 0; -static FILE *logfile; -static void -vlogprintf(const char *fmt, va_list ap) -{ -#ifdef va_copy - va_list lfap; - va_copy(lfap, ap); -#endif - if (log_console) - vfprintf(stdout, fmt, ap); - if (logfile != NULL) -#ifdef va_copy - vfprintf(logfile, fmt, lfap); - va_end(lfap); -#else - vfprintf(logfile, fmt, ap); -#endif -} - -static void -logprintf(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vlogprintf(fmt, ap); - va_end(ap); -} - -/* Set up a message to display only if next assertion fails. */ -static char msgbuff[4096]; -static const char *msg, *nextmsg; -void -failure(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vsprintf(msgbuff, fmt, ap); - va_end(ap); - nextmsg = msgbuff; -} - -/* - * Copy arguments into file-local variables. - * This was added to permit vararg assert() functions without needing - * variadic wrapper macros. Turns out that the vararg capability is almost - * never used, so almost all of the vararg assertions can be simplified - * by removing the vararg capability and reworking the wrapper macro to - * pass __FILE__, __LINE__ directly into the function instead of using - * this hook. I suspect this machinery is used so rarely that we - * would be better off just removing it entirely. That would simplify - * the code here noticably. - */ -static const char *test_filename; -static int test_line; -static void *test_extra; -void assertion_setup(const char *filename, int line) -{ - test_filename = filename; - test_line = line; -} - -/* Called at the beginning of each assert() function. */ -static void -assertion_count(const char *file, int line) -{ - (void)file; /* UNUSED */ - (void)line; /* UNUSED */ - ++assertions; - /* Proper handling of "failure()" message. */ - msg = nextmsg; - nextmsg = NULL; - /* Uncomment to print file:line after every assertion. - * Verbose, but occasionally useful in tracking down crashes. */ - /* printf("Checked %s:%d\n", file, line); */ -} - -/* - * For each test source file, we remember how many times each - * assertion was reported. Cleared before each new test, - * used by test_summarize(). - */ -static struct line { - int count; - int skip; -} failed_lines[10000]; - -/* Count this failure, setup up log destination and handle initial report. */ -static void -failure_start(const char *filename, int line, const char *fmt, ...) -{ - va_list ap; - - /* Record another failure for this line. */ - ++failures; - /* test_filename = filename; */ - failed_lines[line].count++; - - /* Determine whether to log header to console. */ - switch (verbosity) { - case VERBOSITY_LIGHT_REPORT: - log_console = (failed_lines[line].count < 2); - break; - default: - log_console = (verbosity >= VERBOSITY_FULL); - } - - /* Log file:line header for this failure */ - va_start(ap, fmt); -#if _MSC_VER - logprintf("%s(%d): ", filename, line); -#else - logprintf("%s:%d: ", filename, line); -#endif - vlogprintf(fmt, ap); - va_end(ap); - logprintf("\n"); - - if (msg != NULL && msg[0] != '\0') { - logprintf(" Description: %s\n", msg); - msg = NULL; - } - - /* Determine whether to log details to console. */ - if (verbosity == VERBOSITY_LIGHT_REPORT) - log_console = 0; -} - -/* Complete reporting of failed tests. */ -/* - * The 'extra' hook here is used by libarchive to include libarchive - * error messages with assertion failures. It could also be used - * to add strerror() output, for example. Just define the EXTRA_DUMP() - * macro appropriately. - */ -static void -failure_finish(void *extra) -{ - (void)extra; /* UNUSED (maybe) */ -#ifdef EXTRA_DUMP - if (extra != NULL) - logprintf(" detail: %s\n", EXTRA_DUMP(extra)); -#endif - - if (dump_on_failure) { - fprintf(stderr, - " *** forcing core dump so failure can be debugged ***\n"); - abort(); - exit(1); - } -} - -/* Inform user that we're skipping some checks. */ -void -test_skipping(const char *fmt, ...) -{ - char buff[1024]; - va_list ap; - - va_start(ap, fmt); - vsprintf(buff, fmt, ap); - va_end(ap); - /* failure_start() isn't quite right, but is awfully convenient. */ - failure_start(test_filename, test_line, "SKIPPING: %s", buff); - --failures; /* Undo failures++ in failure_start() */ - /* Don't failure_finish() here. */ - /* Mark as skip, so doesn't count as failed test. */ - failed_lines[test_line].skip = 1; - ++skips; -} - -/* - * - * ASSERTIONS - * - */ - -/* Generic assert() just displays the failed condition. */ -int -assertion_assert(const char *file, int line, int value, - const char *condition, void *extra) -{ - assertion_count(file, line); - if (!value) { - failure_start(file, line, "Assertion failed: %s", condition); - failure_finish(extra); - } - return (value); -} - -/* chdir() and report any errors */ -int -assertion_chdir(const char *file, int line, const char *pathname) -{ - assertion_count(file, line); - if (chdir(pathname) == 0) - return (1); - failure_start(file, line, "chdir(\"%s\")", pathname); - failure_finish(NULL); - return (0); - -} - -/* Verify two integers are equal. */ -int -assertion_equal_int(const char *file, int line, - long long v1, const char *e1, long long v2, const char *e2, void *extra) -{ - assertion_count(file, line); - if (v1 == v2) - return (1); - failure_start(file, line, "%s != %s", e1, e2); - logprintf(" %s=%lld (0x%llx, 0%llo)\n", e1, v1, v1, v1); - logprintf(" %s=%lld (0x%llx, 0%llo)\n", e2, v2, v2, v2); - failure_finish(extra); - return (0); -} - -static void strdump(const char *e, const char *p) -{ - const char *q = p; - - logprintf(" %s = ", e); - if (p == NULL) { - logprintf("NULL"); - return; - } - logprintf("\""); - while (*p != '\0') { - unsigned int c = 0xff & *p++; - switch (c) { - case '\a': printf("\a"); break; - case '\b': printf("\b"); break; - case '\n': printf("\n"); break; - case '\r': printf("\r"); break; - default: - if (c >= 32 && c < 127) - logprintf("%c", c); - else - logprintf("\\x%02X", c); - } - } - logprintf("\""); - logprintf(" (length %d)\n", q == NULL ? -1 : (int)strlen(q)); -} - -/* Verify two strings are equal, dump them if not. */ -int -assertion_equal_string(const char *file, int line, - const char *v1, const char *e1, - const char *v2, const char *e2, - void *extra) -{ - assertion_count(file, line); - if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0)) - return (1); - failure_start(file, line, "%s != %s", e1, e2); - strdump(e1, v1); - strdump(e2, v2); - failure_finish(extra); - return (0); -} - -static void -wcsdump(const char *e, const wchar_t *w) -{ - logprintf(" %s = ", e); - if (w == NULL) { - logprintf("(null)"); - return; - } - logprintf("\""); - while (*w != L'\0') { - unsigned int c = *w++; - if (c >= 32 && c < 127) - logprintf("%c", c); - else if (c < 256) - logprintf("\\x%02X", c); - else if (c < 0x10000) - logprintf("\\u%04X", c); - else - logprintf("\\U%08X", c); - } - logprintf("\"\n"); -} - -/* Verify that two wide strings are equal, dump them if not. */ -int -assertion_equal_wstring(const char *file, int line, - const wchar_t *v1, const char *e1, - const wchar_t *v2, const char *e2, - void *extra) -{ - assertion_count(file, line); - if (v1 == v2 || wcscmp(v1, v2) == 0) - return (1); - failure_start(file, line, "%s != %s", e1, e2); - wcsdump(e1, v1); - wcsdump(e2, v2); - failure_finish(extra); - return (0); -} - -/* - * Pretty standard hexdump routine. As a bonus, if ref != NULL, then - * any bytes in p that differ from ref will be highlighted with '_' - * before and after the hex value. - */ -static void -hexdump(const char *p, const char *ref, size_t l, size_t offset) -{ - size_t i, j; - char sep; - - if (p == NULL) { - logprintf("(null)\n"); - return; - } - for(i=0; i < l; i+=16) { - logprintf("%04x", (unsigned)(i + offset)); - sep = ' '; - for (j = 0; j < 16 && i + j < l; j++) { - if (ref != NULL && p[i + j] != ref[i + j]) - sep = '_'; - logprintf("%c%02x", sep, 0xff & (int)p[i+j]); - if (ref != NULL && p[i + j] == ref[i + j]) - sep = ' '; - } - for (; j < 16; j++) { - logprintf("%c ", sep); - sep = ' '; - } - logprintf("%c", sep); - for (j=0; j < 16 && i + j < l; j++) { - int c = p[i + j]; - if (c >= ' ' && c <= 126) - logprintf("%c", c); - else - logprintf("."); - } - logprintf("\n"); - } -} - -/* Verify that two blocks of memory are the same, display the first - * block of differences if they're not. */ -int -assertion_equal_mem(const char *file, int line, - const void *_v1, const char *e1, - const void *_v2, const char *e2, - size_t l, const char *ld, void *extra) -{ - const char *v1 = (const char *)_v1; - const char *v2 = (const char *)_v2; - size_t offset; - - assertion_count(file, line); - if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0)) - return (1); - - failure_start(file, line, "%s != %s", e1, e2); - logprintf(" size %s = %d\n", ld, (int)l); - /* Dump 48 bytes (3 lines) so that the first difference is - * in the second line. */ - offset = 0; - while (l > 64 && memcmp(v1, v2, 32) == 0) { - /* Two lines agree, so step forward one line. */ - v1 += 16; - v2 += 16; - l -= 16; - offset += 16; - } - logprintf(" Dump of %s\n", e1); - hexdump(v1, v2, l < 64 ? l : 64, offset); - logprintf(" Dump of %s\n", e2); - hexdump(v2, v1, l < 64 ? l : 64, offset); - logprintf("\n"); - failure_finish(extra); - return (0); -} - -/* Verify that the named file exists and is empty. */ -int -assertion_empty_file(const char *f1fmt, ...) -{ - char buff[1024]; - char f1[1024]; - struct stat st; - va_list ap; - ssize_t s; - FILE *f; - - assertion_count(test_filename, test_line); - va_start(ap, f1fmt); - vsprintf(f1, f1fmt, ap); - va_end(ap); - - if (stat(f1, &st) != 0) { - failure_start(test_filename, test_line, "Stat failed: %s", f1); - failure_finish(NULL); - return (0); - } - if (st.st_size == 0) - return (1); - - failure_start(test_filename, test_line, "File should be empty: %s", f1); - logprintf(" File size: %d\n", (int)st.st_size); - logprintf(" Contents:\n"); - f = fopen(f1, "rb"); - if (f == NULL) { - logprintf(" Unable to open %s\n", f1); - } else { - s = ((off_t)sizeof(buff) < st.st_size) ? - (ssize_t)sizeof(buff) : (ssize_t)st.st_size; - s = fread(buff, 1, s, f); - hexdump(buff, NULL, s, 0); - fclose(f); - } - failure_finish(NULL); - return (0); -} - -/* Verify that the named file exists and is not empty. */ -int -assertion_non_empty_file(const char *f1fmt, ...) -{ - char f1[1024]; - struct stat st; - va_list ap; - - assertion_count(test_filename, test_line); - va_start(ap, f1fmt); - vsprintf(f1, f1fmt, ap); - va_end(ap); - - if (stat(f1, &st) != 0) { - failure_start(test_filename, test_line, "Stat failed: %s", f1); - failure_finish(NULL); - return (0); - } - if (st.st_size == 0) { - failure_start(test_filename, test_line, "File empty: %s", f1); - failure_finish(NULL); - return (0); - } - return (1); -} - -/* Verify that two files have the same contents. */ -/* TODO: hexdump the first bytes that actually differ. */ -int -assertion_equal_file(const char *fn1, const char *f2pattern, ...) -{ - char fn2[1024]; - va_list ap; - char buff1[1024]; - char buff2[1024]; - FILE *f1, *f2; - int n1, n2; - - assertion_count(test_filename, test_line); - va_start(ap, f2pattern); - vsprintf(fn2, f2pattern, ap); - va_end(ap); - - f1 = fopen(fn1, "rb"); - f2 = fopen(fn2, "rb"); - for (;;) { - n1 = fread(buff1, 1, sizeof(buff1), f1); - n2 = fread(buff2, 1, sizeof(buff2), f2); - if (n1 != n2) - break; - if (n1 == 0 && n2 == 0) { - fclose(f1); - fclose(f2); - return (1); - } - if (memcmp(buff1, buff2, n1) != 0) - break; - } - fclose(f1); - fclose(f2); - failure_start(test_filename, test_line, "Files not identical"); - logprintf(" file1=\"%s\"\n", fn1); - logprintf(" file2=\"%s\"\n", fn2); - failure_finish(test_extra); - return (0); -} - -/* Verify that the named file does exist. */ -int -assertion_file_exists(const char *fpattern, ...) -{ - char f[1024]; - va_list ap; - - assertion_count(test_filename, test_line); - va_start(ap, fpattern); - vsprintf(f, fpattern, ap); - va_end(ap); - -#if defined(_WIN32) && !defined(__CYGWIN__) - if (!_access(f, 0)) - return (1); -#else - if (!access(f, F_OK)) - return (1); -#endif - failure_start(test_filename, test_line, "File should exist: %s", f); - failure_finish(test_extra); - return (0); -} - -/* Verify that the named file doesn't exist. */ -int -assertion_file_not_exists(const char *fpattern, ...) -{ - char f[1024]; - va_list ap; - - assertion_count(test_filename, test_line); - va_start(ap, fpattern); - vsprintf(f, fpattern, ap); - va_end(ap); - -#if defined(_WIN32) && !defined(__CYGWIN__) - if (_access(f, 0)) - return (1); -#else - if (access(f, F_OK)) - return (1); -#endif - failure_start(test_filename, test_line, "File should not exist: %s", f); - failure_finish(test_extra); - return (0); -} - -/* Compare the contents of a file to a block of memory. */ -int -assertion_file_contents(const void *buff, int s, const char *fpattern, ...) -{ - char fn[1024]; - va_list ap; - char *contents; - FILE *f; - int n; - - assertion_count(test_filename, test_line); - va_start(ap, fpattern); - vsprintf(fn, fpattern, ap); - va_end(ap); - - f = fopen(fn, "rb"); - if (f == NULL) { - failure_start(test_filename, test_line, - "File should exist: %s", fn); - failure_finish(test_extra); - return (0); - } - contents = malloc(s * 2); - n = fread(contents, 1, s * 2, f); - fclose(f); - if (n == s && memcmp(buff, contents, s) == 0) { - free(contents); - return (1); - } - failure_start(test_filename, test_line, "File contents don't match"); - logprintf(" file=\"%s\"\n", fn); - if (n > 0) - hexdump(contents, buff, n > 512 ? 512 : n, 0); - else { - logprintf(" File empty, contents should be:\n"); - hexdump(buff, NULL, s > 512 ? 512 : n, 0); - } - failure_finish(test_extra); - free(contents); - return (0); -} - -/* Check the contents of a text file, being tolerant of line endings. */ -int -assertion_text_file_contents(const char *buff, const char *fn) -{ - char *contents; - const char *btxt, *ftxt; - FILE *f; - int n, s; - - assertion_count(test_filename, test_line); - f = fopen(fn, "r"); - s = strlen(buff); - contents = malloc(s * 2 + 128); - n = fread(contents, 1, s * 2 + 128 - 1, f); - if (n >= 0) - contents[n] = '\0'; - fclose(f); - /* Compare texts. */ - btxt = buff; - ftxt = (const char *)contents; - while (*btxt != '\0' && *ftxt != '\0') { - if (*btxt == *ftxt) { - ++btxt; - ++ftxt; - continue; - } - if (btxt[0] == '\n' && ftxt[0] == '\r' && ftxt[1] == '\n') { - /* Pass over different new line characters. */ - ++btxt; - ftxt += 2; - continue; - } - break; - } - if (*btxt == '\0' && *ftxt == '\0') { - free(contents); - return (1); - } - failure_start(test_filename, test_line, "Contents don't match"); - logprintf(" file=\"%s\"\n", fn); - if (n > 0) - hexdump(contents, buff, n, 0); - else { - logprintf(" File empty, contents should be:\n"); - hexdump(buff, NULL, s, 0); - } - failure_finish(test_extra); - free(contents); - return (0); -} - -/* Test that two paths point to the same file. */ -/* As a side-effect, asserts that both files exist. */ -static int -is_hardlink(const char *file, int line, - const char *path1, const char *path2) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - BY_HANDLE_FILE_INFORMATION bhfi1, bhfi2; - int r; - - assertion_count(file, line); - r = my_GetFileInformationByName(path1, &bhfi1); - if (r == 0) { - failure_start(file, line, "File %s can't be inspected?", path1); - failure_finish(NULL); - return (0); - } - r = my_GetFileInformationByName(path2, &bhfi2); - if (r == 0) { - failure_start(file, line, "File %s can't be inspected?", path2); - failure_finish(NULL); - return (0); - } - return (bhfi1.dwVolumeSerialNumber == bhfi2.dwVolumeSerialNumber - && bhfi1.nFileIndexHigh == bhfi2.nFileIndexHigh - && bhfi1.nFileIndexLow == bhfi2.nFileIndexLow); -#else - struct stat st1, st2; - int r; - - assertion_count(file, line); - r = lstat(path1, &st1); - if (r != 0) { - failure_start(file, line, "File should exist: %s", path1); - failure_finish(NULL); - return (0); - } - r = lstat(path2, &st2); - if (r != 0) { - failure_start(file, line, "File should exist: %s", path2); - failure_finish(NULL); - return (0); - } - return (st1.st_ino == st2.st_ino && st1.st_dev == st2.st_dev); -#endif -} - -int -assertion_is_hardlink(const char *file, int line, - const char *path1, const char *path2) -{ - if (is_hardlink(file, line, path1, path2)) - return (1); - failure_start(file, line, - "Files %s and %s are not hardlinked", path1, path2); - failure_finish(NULL); - return (0); -} - -int -assertion_is_not_hardlink(const char *file, int line, - const char *path1, const char *path2) -{ - if (!is_hardlink(file, line, path1, path2)) - return (1); - failure_start(file, line, - "Files %s and %s should not be hardlinked", path1, path2); - failure_finish(NULL); - return (0); -} - -/* Verify a/b/mtime of 'pathname'. */ -/* If 'recent', verify that it's within last 10 seconds. */ -static int -assertion_file_time(const char *file, int line, - const char *pathname, long t, long nsec, char type, int recent) -{ - long long filet, filet_nsec; - int r; - -#if defined(_WIN32) && !defined(__CYGWIN__) -#define EPOC_TIME (116444736000000000ULL) - FILETIME ftime, fbirthtime, fatime, fmtime; - ULARGE_INTEGER wintm; - HANDLE h; - ftime.dwLowDateTime = 0; - ftime.dwHighDateTime = 0; - - assertion_count(file, line); - h = CreateFile(pathname, FILE_READ_ATTRIBUTES, 0, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_HANDLE_VALUE) { - failure_start(file, line, "Can't access %s\n", pathname); - failure_finish(NULL); - return (0); - } - r = GetFileTime(h, &fbirthtime, &fatime, &fmtime); - switch (type) { - case 'a': ftime = fatime; break; - case 'b': ftime = fbirthtime; break; - case 'm': ftime = fmtime; break; - } - CloseHandle(h); - if (r == 0) { - failure_start(file, line, "Can't GetFileTime %s\n", pathname); - failure_finish(NULL); - return (0); - } - wintm.LowPart = ftime.dwLowDateTime; - wintm.HighPart = ftime.dwHighDateTime; - filet = (wintm.QuadPart - EPOC_TIME) / 10000000; - filet_nsec = ((wintm.QuadPart - EPOC_TIME) % 10000000) * 100; - nsec = (nsec / 100) * 100; /* Round the request */ -#else - struct stat st; - - assertion_count(file, line); - r = lstat(pathname, &st); - if (r != 0) { - failure_start(file, line, "Can't stat %s\n", pathname); - failure_finish(NULL); - return (0); - } - switch (type) { - case 'a': filet = st.st_atime; break; - case 'm': filet = st.st_mtime; break; - case 'b': filet = 0; break; - default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); - exit(1); - } -#if defined(__FreeBSD__) - switch (type) { - case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; - case 'b': filet = st.st_birthtime; - filet_nsec = st.st_birthtimespec.tv_nsec; break; - case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; - default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); - exit(1); - } - /* FreeBSD generally only stores to microsecond res, so round. */ - filet_nsec = (filet_nsec / 1000) * 1000; - nsec = (nsec / 1000) * 1000; -#else - filet_nsec = nsec = 0; /* Generic POSIX only has whole seconds. */ - if (type == 'b') return (1); /* Generic POSIX doesn't have birthtime */ -#if defined(__HAIKU__) - if (type == 'a') return (1); /* Haiku doesn't have atime. */ -#endif -#endif -#endif - if (recent) { - /* Check that requested time is up-to-date. */ - time_t now = time(NULL); - if (filet < now - 10 || filet > now + 1) { - failure_start(file, line, - "File %s has %ctime %ld, %ld seconds ago\n", - pathname, type, filet, now - filet); - failure_finish(NULL); - return (0); - } - } else if (filet != t || filet_nsec != nsec) { - failure_start(file, line, - "File %s has %ctime %ld.%09ld, expected %ld.%09ld", - pathname, type, filet, filet_nsec, t, nsec); - failure_finish(NULL); - return (0); - } - return (1); -} - -/* Verify atime of 'pathname'. */ -int -assertion_file_atime(const char *file, int line, - const char *pathname, long t, long nsec) -{ - return assertion_file_time(file, line, pathname, t, nsec, 'a', 0); -} - -/* Verify atime of 'pathname' is up-to-date. */ -int -assertion_file_atime_recent(const char *file, int line, const char *pathname) -{ - return assertion_file_time(file, line, pathname, 0, 0, 'a', 1); -} - -/* Verify birthtime of 'pathname'. */ -int -assertion_file_birthtime(const char *file, int line, - const char *pathname, long t, long nsec) -{ - return assertion_file_time(file, line, pathname, t, nsec, 'b', 0); -} - -/* Verify birthtime of 'pathname' is up-to-date. */ -int -assertion_file_birthtime_recent(const char *file, int line, - const char *pathname) -{ - return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); -} - -/* Verify mtime of 'pathname'. */ -int -assertion_file_mtime(const char *file, int line, - const char *pathname, long t, long nsec) -{ - return assertion_file_time(file, line, pathname, t, nsec, 'm', 0); -} - -/* Verify mtime of 'pathname' is up-to-date. */ -int -assertion_file_mtime_recent(const char *file, int line, const char *pathname) -{ - return assertion_file_time(file, line, pathname, 0, 0, 'm', 1); -} - -/* Verify number of links to 'pathname'. */ -int -assertion_file_nlinks(const char *file, int line, - const char *pathname, int nlinks) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - BY_HANDLE_FILE_INFORMATION bhfi; - int r; - - assertion_count(file, line); - r = my_GetFileInformationByName(pathname, &bhfi); - if (r != 0 && bhfi.nNumberOfLinks == (DWORD)nlinks) - return (1); - failure_start(file, line, "File %s has %d links, expected %d", - pathname, bhfi.nNumberOfLinks, nlinks); - failure_finish(NULL); - return (0); -#else - struct stat st; - int r; - - assertion_count(file, line); - r = lstat(pathname, &st); - if (r == 0 && st.st_nlink == nlinks) - return (1); - failure_start(file, line, "File %s has %d links, expected %d", - pathname, st.st_nlink, nlinks); - failure_finish(NULL); - return (0); -#endif -} - -/* Verify size of 'pathname'. */ -int -assertion_file_size(const char *file, int line, const char *pathname, long size) -{ - int64_t filesize; - int r; - - assertion_count(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) - { - BY_HANDLE_FILE_INFORMATION bhfi; - r = !my_GetFileInformationByName(pathname, &bhfi); - filesize = ((int64_t)bhfi.nFileSizeHigh << 32) + bhfi.nFileSizeLow; - } -#else - { - struct stat st; - r = lstat(pathname, &st); - filesize = st.st_size; - } -#endif - if (r == 0 && filesize == size) - return (1); - failure_start(file, line, "File %s has size %ld, expected %ld", - pathname, (long)filesize, (long)size); - failure_finish(NULL); - return (0); -} - -/* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */ -int -assertion_is_dir(const char *file, int line, const char *pathname, int mode) -{ - struct stat st; - int r; - -#if defined(_WIN32) && !defined(__CYGWIN__) - (void)mode; /* UNUSED */ -#endif - assertion_count(file, line); - r = lstat(pathname, &st); - if (r != 0) { - failure_start(file, line, "Dir should exist: %s", pathname); - failure_finish(NULL); - return (0); - } - if (!S_ISDIR(st.st_mode)) { - failure_start(file, line, "%s is not a dir", pathname); - failure_finish(NULL); - return (0); - } -#if !defined(_WIN32) || defined(__CYGWIN__) - /* Windows doesn't handle permissions the same way as POSIX, - * so just ignore the mode tests. */ - /* TODO: Can we do better here? */ - if (mode >= 0 && mode != (st.st_mode & 07777)) { - failure_start(file, line, "Dir %s has wrong mode", pathname); - logprintf(" Expected: 0%3o\n", mode); - logprintf(" Found: 0%3o\n", st.st_mode & 07777); - failure_finish(NULL); - return (0); - } -#endif - return (1); -} - -/* Verify that 'pathname' is a regular file. If 'mode' is >= 0, - * verify that too. */ -int -assertion_is_reg(const char *file, int line, const char *pathname, int mode) -{ - struct stat st; - int r; - -#if defined(_WIN32) && !defined(__CYGWIN__) - (void)mode; /* UNUSED */ -#endif - assertion_count(file, line); - r = lstat(pathname, &st); - if (r != 0 || !S_ISREG(st.st_mode)) { - failure_start(file, line, "File should exist: %s", pathname); - failure_finish(NULL); - return (0); - } -#if !defined(_WIN32) || defined(__CYGWIN__) - /* Windows doesn't handle permissions the same way as POSIX, - * so just ignore the mode tests. */ - /* TODO: Can we do better here? */ - if (mode >= 0 && mode != (st.st_mode & 07777)) { - failure_start(file, line, "File %s has wrong mode", pathname); - logprintf(" Expected: 0%3o\n", mode); - logprintf(" Found: 0%3o\n", st.st_mode & 07777); - failure_finish(NULL); - return (0); - } -#endif - return (1); -} - -/* Check whether 'pathname' is a symbolic link. If 'contents' is - * non-NULL, verify that the symlink has those contents. */ -static int -is_symlink(const char *file, int line, - const char *pathname, const char *contents) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - (void)pathname; /* UNUSED */ - (void)contents; /* UNUSED */ - assertion_count(file, line); - /* Windows sort-of has real symlinks, but they're only usable - * by privileged users and are crippled even then, so there's - * really not much point in bothering with this. */ - return (0); -#else - char buff[300]; - struct stat st; - ssize_t linklen; - int r; - - assertion_count(file, line); - r = lstat(pathname, &st); - if (r != 0) { - failure_start(file, line, - "Symlink should exist: %s", pathname); - failure_finish(NULL); - return (0); - } - if (!S_ISLNK(st.st_mode)) - return (0); - if (contents == NULL) - return (1); - linklen = readlink(pathname, buff, sizeof(buff)); - if (linklen < 0) { - failure_start(file, line, "Can't read symlink %s", pathname); - failure_finish(NULL); - return (0); - } - buff[linklen] = '\0'; - if (strcmp(buff, contents) != 0) - return (0); - return (1); -#endif -} - -/* Assert that path is a symlink that (optionally) contains contents. */ -int -assertion_is_symlink(const char *file, int line, - const char *path, const char *contents) -{ - if (is_symlink(file, line, path, contents)) - return (1); - if (contents) - failure_start(file, line, "File %s is not a symlink to %s", - path, contents); - else - failure_start(file, line, "File %s is not a symlink", path); - failure_finish(NULL); - return (0); -} - - -/* Create a directory and report any errors. */ -int -assertion_make_dir(const char *file, int line, const char *dirname, int mode) -{ - assertion_count(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) - (void)mode; /* UNUSED */ - if (0 == _mkdir(dirname)) - return (1); -#else - if (0 == mkdir(dirname, mode)) - return (1); -#endif - failure_start(file, line, "Could not create directory %s", dirname); - failure_finish(NULL); - return(0); -} - -/* Create a file with the specified contents and report any failures. */ -int -assertion_make_file(const char *file, int line, - const char *path, int mode, const char *contents) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - /* TODO: Rework this to set file mode as well. */ - FILE *f; - (void)mode; /* UNUSED */ - assertion_count(file, line); - f = fopen(path, "wb"); - if (f == NULL) { - failure_start(file, line, "Could not create file %s", path); - failure_finish(NULL); - return (0); - } - if (contents != NULL) { - if (strlen(contents) - != fwrite(contents, 1, strlen(contents), f)) { - fclose(f); - failure_start(file, line, - "Could not write file %s", path); - failure_finish(NULL); - return (0); - } - } - fclose(f); - return (1); -#else - int fd; - assertion_count(file, line); - fd = open(path, O_CREAT | O_WRONLY, mode >= 0 ? mode : 0644); - if (fd < 0) { - failure_start(file, line, "Could not create %s", path); - failure_finish(NULL); - return (0); - } - if (contents != NULL) { - if ((ssize_t)strlen(contents) - != write(fd, contents, strlen(contents))) { - close(fd); - failure_start(file, line, "Could not write to %s", path); - failure_finish(NULL); - return (0); - } - } - close(fd); - return (1); -#endif -} - -/* Create a hardlink and report any failures. */ -int -assertion_make_hardlink(const char *file, int line, - const char *newpath, const char *linkto) -{ - int succeeded; - - assertion_count(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) - succeeded = my_CreateHardLinkA(newpath, linkto); -#elif HAVE_LINK - succeeded = !link(linkto, newpath); -#else - succeeded = 0; -#endif - if (succeeded) - return (1); - failure_start(file, line, "Could not create hardlink"); - logprintf(" New link: %s\n", newpath); - logprintf(" Old name: %s\n", linkto); - failure_finish(NULL); - return(0); -} - -/* Create a symlink and report any failures. */ -int -assertion_make_symlink(const char *file, int line, - const char *newpath, const char *linkto) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - int targetIsDir = 0; /* TODO: Fix this */ - assertion_count(file, line); - if (my_CreateSymbolicLinkA(newpath, linkto, targetIsDir)) - return (1); -#elif HAVE_SYMLINK - assertion_count(file, line); - if (0 == symlink(linkto, newpath)) - return (1); -#endif - failure_start(file, line, "Could not create symlink"); - logprintf(" New link: %s\n", newpath); - logprintf(" Old name: %s\n", linkto); - failure_finish(NULL); - return(0); -} - -/* Set umask, report failures. */ -int -assertion_umask(const char *file, int line, int mask) -{ - assertion_count(file, line); - (void)file; /* UNUSED */ - (void)line; /* UNUSED */ - umask(mask); - return (1); -} - -/* - * - * UTILITIES for use by tests. - * - */ - -/* - * Check whether platform supports symlinks. This is intended - * for tests to use in deciding whether to bother testing symlink - * support; if the platform doesn't support symlinks, there's no point - * in checking whether the program being tested can create them. - * - * Note that the first time this test is called, we actually go out to - * disk to create and verify a symlink. This is necessary because - * symlink support is actually a property of a particular filesystem - * and can thus vary between directories on a single system. After - * the first call, this returns the cached result from memory, so it's - * safe to call it as often as you wish. - */ -int -canSymlink(void) -{ - /* Remember the test result */ - static int value = 0, tested = 0; - if (tested) - return (value); - - ++tested; - assertion_make_file(__FILE__, __LINE__, "canSymlink.0", 0644, "a"); - /* Note: Cygwin has its own symlink() emulation that does not - * use the Win32 CreateSymbolicLink() function. */ -#if defined(_WIN32) && !defined(__CYGWIN__) - value = my_CreateSymbolicLinkA("canSymlink.1", "canSymlink.0", 0) - && is_symlink(__FILE__, __LINE__, "canSymlink.1", "canSymlink.0"); -#elif HAVE_SYMLINK - value = (0 == symlink("canSymlink.0", "canSymlink.1")) - && is_symlink(__FILE__, __LINE__, "canSymlink.1","canSymlink.0"); -#endif - return (value); -} - -/* - * Can this platform run the gzip program? - */ -/* Platform-dependent options for hiding the output of a subcommand. */ -#if defined(_WIN32) && !defined(__CYGWIN__) -static const char *redirectArgs = ">NUL 2>NUL"; /* Win32 cmd.exe */ -#else -static const char *redirectArgs = ">/dev/null 2>/dev/null"; /* POSIX 'sh' */ -#endif -int -canGzip(void) -{ - static int tested = 0, value = 0; - if (!tested) { - tested = 1; - if (systemf("gzip -V %s", redirectArgs) == 0) - value = 1; - } - return (value); -} - -/* - * Can this platform run the gunzip program? - */ -int -canGunzip(void) -{ - static int tested = 0, value = 0; - if (!tested) { - tested = 1; - if (systemf("gunzip -V %s", redirectArgs) == 0) - value = 1; - } - return (value); -} - -/* - * Sleep as needed; useful for verifying disk timestamp changes by - * ensuring that the wall-clock time has actually changed before we - * go back to re-read something from disk. - */ -void -sleepUntilAfter(time_t t) -{ - while (t >= time(NULL)) -#if defined(_WIN32) && !defined(__CYGWIN__) - Sleep(500); -#else - sleep(1); -#endif -} - -/* - * Call standard system() call, but build up the command line using - * sprintf() conventions. - */ -int -systemf(const char *fmt, ...) -{ - char buff[8192]; - va_list ap; - int r; - - va_start(ap, fmt); - vsprintf(buff, fmt, ap); - if (verbosity > VERBOSITY_FULL) - logprintf("Cmd: %s\n", buff); - r = system(buff); - va_end(ap); - return (r); -} - -/* - * Slurp a file into memory for ease of comparison and testing. - * Returns size of file in 'sizep' if non-NULL, null-terminates - * data in memory for ease of use. - */ -char * -slurpfile(size_t * sizep, const char *fmt, ...) -{ - char filename[8192]; - struct stat st; - va_list ap; - char *p; - ssize_t bytes_read; - FILE *f; - int r; - - va_start(ap, fmt); - vsprintf(filename, fmt, ap); - va_end(ap); - - f = fopen(filename, "rb"); - if (f == NULL) { - /* Note: No error; non-existent file is okay here. */ - return (NULL); - } - r = fstat(fileno(f), &st); - if (r != 0) { - logprintf("Can't stat file %s\n", filename); - fclose(f); - return (NULL); - } - p = malloc((size_t)st.st_size + 1); - if (p == NULL) { - logprintf("Can't allocate %ld bytes of memory to read file %s\n", - (long int)st.st_size, filename); - fclose(f); - return (NULL); - } - bytes_read = fread(p, 1, (size_t)st.st_size, f); - if (bytes_read < st.st_size) { - logprintf("Can't read file %s\n", filename); - fclose(f); - free(p); - return (NULL); - } - p[st.st_size] = '\0'; - if (sizep != NULL) - *sizep = (size_t)st.st_size; - fclose(f); - return (p); -} - -/* Read a uuencoded file from the reference directory, decode, and - * write the result into the current directory. */ -#define UUDECODE(c) (((c) - 0x20) & 0x3f) -void -extract_reference_file(const char *name) -{ - char buff[1024]; - FILE *in, *out; - - sprintf(buff, "%s/%s.uu", refdir, name); - in = fopen(buff, "r"); - failure("Couldn't open reference file %s", buff); - assert(in != NULL); - if (in == NULL) - return; - /* Read up to and including the 'begin' line. */ - for (;;) { - if (fgets(buff, sizeof(buff), in) == NULL) { - /* TODO: This is a failure. */ - return; - } - if (memcmp(buff, "begin ", 6) == 0) - break; - } - /* Now, decode the rest and write it. */ - /* Not a lot of error checking here; the input better be right. */ - out = fopen(name, "wb"); - while (fgets(buff, sizeof(buff), in) != NULL) { - char *p = buff; - int bytes; - - if (memcmp(buff, "end", 3) == 0) - break; - - bytes = UUDECODE(*p++); - while (bytes > 0) { - int n = 0; - /* Write out 1-3 bytes from that. */ - if (bytes > 0) { - n = UUDECODE(*p++) << 18; - n |= UUDECODE(*p++) << 12; - fputc(n >> 16, out); - --bytes; - } - if (bytes > 0) { - n |= UUDECODE(*p++) << 6; - fputc((n >> 8) & 0xFF, out); - --bytes; - } - if (bytes > 0) { - n |= UUDECODE(*p++); - fputc(n & 0xFF, out); - --bytes; - } - } - } - fclose(out); - fclose(in); -} - -/* - * - * TEST management - * - */ - -/* - * "list.h" is simply created by "grep DEFINE_TEST test_*.c"; it has - * a line like - * DEFINE_TEST(test_function) - * for each test. - */ - -/* Use "list.h" to declare all of the test functions. */ -#undef DEFINE_TEST -#define DEFINE_TEST(name) void name(void); -#include "list.h" - -/* Use "list.h" to create a list of all tests (functions and names). */ -#undef DEFINE_TEST -#define DEFINE_TEST(n) { n, #n, 0 }, -struct { void (*func)(void); const char *name; int failures; } tests[] = { - #include "list.h" -}; - -/* - * Summarize repeated failures in the just-completed test. - */ -static void -test_summarize(const char *filename, int failed) -{ - unsigned int i; - - switch (verbosity) { - case VERBOSITY_SUMMARY_ONLY: - printf(failed ? "E" : "."); - fflush(stdout); - break; - case VERBOSITY_PASSFAIL: - printf(failed ? "FAIL\n" : "ok\n"); - break; - } - - log_console = (verbosity == VERBOSITY_LIGHT_REPORT); - - for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) { - if (failed_lines[i].count > 1 && !failed_lines[i].skip) - logprintf("%s:%d: Summary: Failed %d times\n", - filename, i, failed_lines[i].count); - } - /* Clear the failure history for the next file. */ - memset(failed_lines, 0, sizeof(failed_lines)); -} - -/* - * Actually run a single test, with appropriate setup and cleanup. - */ -static int -test_run(int i, const char *tmpdir) -{ - char logfilename[64]; - int failures_before = failures; - int oldumask; - - switch (verbosity) { - case VERBOSITY_SUMMARY_ONLY: /* No per-test reports at all */ - break; - case VERBOSITY_PASSFAIL: /* rest of line will include ok/FAIL marker */ - printf("%3d: %-50s", i, tests[i].name); - fflush(stdout); - break; - default: /* Title of test, details will follow */ - printf("%3d: %s\n", i, tests[i].name); - } - - /* Chdir to the top-level work directory. */ - if (!assertChdir(tmpdir)) { - fprintf(stderr, - "ERROR: Can't chdir to top work dir %s\n", tmpdir); - exit(1); - } - /* Create a log file for this test. */ - sprintf(logfilename, "%s.log", tests[i].name); - logfile = fopen(logfilename, "w"); - fprintf(logfile, "%s\n\n", tests[i].name); - /* Chdir() to a work dir for this specific test. */ - if (!assertMakeDir(tests[i].name, 0755) - || !assertChdir(tests[i].name)) { - fprintf(stderr, - "ERROR: Can't chdir to work dir %s/%s\n", - tmpdir, tests[i].name); - exit(1); - } - /* Explicitly reset the locale before each test. */ - setlocale(LC_ALL, "C"); - /* Record the umask before we run the test. */ - umask(oldumask = umask(0)); - /* - * Run the actual test. - */ - (*tests[i].func)(); - /* - * Clean up and report afterwards. - */ - /* Restore umask */ - umask(oldumask); - /* Reset locale. */ - setlocale(LC_ALL, "C"); - /* Reset directory. */ - if (!assertChdir(tmpdir)) { - fprintf(stderr, "ERROR: Couldn't chdir to temp dir %s\n", - tmpdir); - exit(1); - } - /* Report per-test summaries. */ - tests[i].failures = failures - failures_before; - test_summarize(test_filename, tests[i].failures); - /* Close the per-test log file. */ - fclose(logfile); - logfile = NULL; - /* If there were no failures, we can remove the work dir and logfile. */ - if (tests[i].failures == 0) { - if (!keep_temp_files && assertChdir(tmpdir)) { -#if defined(_WIN32) && !defined(__CYGWIN__) - /* Make sure not to leave empty directories. - * Sometimes a processing of closing files used by tests - * is not done, then rmdir will be failed and it will - * leave a empty test directory. So we should wait a few - * seconds and retry rmdir. */ - int r, t; - for (t = 0; t < 10; t++) { - if (t > 0) - Sleep(1000); - r = systemf("rmdir /S /Q %s", tests[i].name); - if (r == 0) - break; - } - systemf("del %s", logfilename); -#else - systemf("rm -rf %s", tests[i].name); - systemf("rm %s", logfilename); -#endif - } - } - /* Return appropriate status. */ - return (tests[i].failures); -} - -/* - * - * - * MAIN and support routines. - * - * - */ - -static void -usage(const char *program) -{ - static const int limit = sizeof(tests) / sizeof(tests[0]); - int i; - - printf("Usage: %s [options] <test> <test> ...\n", program); - printf("Default is to run all tests.\n"); - printf("Otherwise, specify the numbers of the tests you wish to run.\n"); - printf("Options:\n"); - printf(" -d Dump core after any failure, for debugging.\n"); - printf(" -k Keep all temp files.\n"); - printf(" Default: temp files for successful tests deleted.\n"); -#ifdef PROGRAM - printf(" -p <path> Path to executable to be tested.\n"); - printf(" Default: path taken from " ENVBASE " environment variable.\n"); -#endif - printf(" -q Quiet.\n"); - printf(" -r <dir> Path to dir containing reference files.\n"); - printf(" Default: Current directory.\n"); - printf(" -v Verbose.\n"); - printf("Available tests:\n"); - for (i = 0; i < limit; i++) - printf(" %d: %s\n", i, tests[i].name); - exit(1); -} - -static char * -get_refdir(const char *d) -{ - char tried[512] = { '\0' }; - char buff[128]; - char *pwd, *p; - - /* If a dir was specified, try that */ - if (d != NULL) { - pwd = NULL; - snprintf(buff, sizeof(buff), "%s", d); - p = slurpfile(NULL, "%s/%s", buff, KNOWNREF); - if (p != NULL) goto success; - strncat(tried, buff, sizeof(tried) - strlen(tried) - 1); - strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1); - goto failure; - } - - /* Get the current dir. */ - pwd = getcwd(NULL, 0); - while (pwd[strlen(pwd) - 1] == '\n') - pwd[strlen(pwd) - 1] = '\0'; - - /* Look for a known file. */ - snprintf(buff, sizeof(buff), "%s", pwd); - p = slurpfile(NULL, "%s/%s", buff, KNOWNREF); - if (p != NULL) goto success; - strncat(tried, buff, sizeof(tried) - strlen(tried) - 1); - strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1); - - snprintf(buff, sizeof(buff), "%s/test", pwd); - p = slurpfile(NULL, "%s/%s", buff, KNOWNREF); - if (p != NULL) goto success; - strncat(tried, buff, sizeof(tried) - strlen(tried) - 1); - strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1); - -#if defined(LIBRARY) - snprintf(buff, sizeof(buff), "%s/%s/test", pwd, LIBRARY); -#else - snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM); -#endif - p = slurpfile(NULL, "%s/%s", buff, KNOWNREF); - if (p != NULL) goto success; - strncat(tried, buff, sizeof(tried) - strlen(tried) - 1); - strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1); - - if (memcmp(pwd, "/usr/obj", 8) == 0) { - snprintf(buff, sizeof(buff), "%s", pwd + 8); - p = slurpfile(NULL, "%s/%s", buff, KNOWNREF); - if (p != NULL) goto success; - strncat(tried, buff, sizeof(tried) - strlen(tried) - 1); - strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1); - - snprintf(buff, sizeof(buff), "%s/test", pwd + 8); - p = slurpfile(NULL, "%s/%s", buff, KNOWNREF); - if (p != NULL) goto success; - strncat(tried, buff, sizeof(tried) - strlen(tried) - 1); - strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1); - } - -failure: - printf("Unable to locate known reference file %s\n", KNOWNREF); - printf(" Checked following directories:\n%s\n", tried); -#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG) - DebugBreak(); -#endif - exit(1); - -success: - free(p); - free(pwd); - return strdup(buff); -} - -int -main(int argc, char **argv) -{ - static const int limit = sizeof(tests) / sizeof(tests[0]); - int i, tests_run = 0, tests_failed = 0, option; - time_t now; - char *refdir_alloc = NULL; - const char *progname; - const char *tmp, *option_arg, *p; - char tmpdir[256]; - char tmpdir_timestamp[256]; - - (void)argc; /* UNUSED */ - -#if defined(HAVE__CrtSetReportMode) - /* To stop to run the default invalid parameter handler. */ - _set_invalid_parameter_handler(invalid_parameter_handler); - /* Disable annoying assertion message box. */ - _CrtSetReportMode(_CRT_ASSERT, 0); -#endif - - /* - * Name of this program, used to build root of our temp directory - * tree. - */ - progname = p = argv[0]; - while (*p != '\0') { - /* Support \ or / dir separators for Windows compat. */ - if (*p == '/' || *p == '\\') - progname = p + 1; - ++p; - } - -#ifdef PROGRAM - /* Get the target program from environment, if available. */ - testprogfile = getenv(ENVBASE); -#endif - - if (getenv("TMPDIR") != NULL) - tmp = getenv("TMPDIR"); - else if (getenv("TMP") != NULL) - tmp = getenv("TMP"); - else if (getenv("TEMP") != NULL) - tmp = getenv("TEMP"); - else if (getenv("TEMPDIR") != NULL) - tmp = getenv("TEMPDIR"); - else - tmp = "/tmp"; - - /* Allow -d to be controlled through the environment. */ - if (getenv(ENVBASE "_DEBUG") != NULL) - dump_on_failure = 1; - - /* Get the directory holding test files from environment. */ - refdir = getenv(ENVBASE "_TEST_FILES"); - - /* - * Parse options, without using getopt(), which isn't available - * on all platforms. - */ - ++argv; /* Skip program name */ - while (*argv != NULL) { - if (**argv != '-') - break; - p = *argv++; - ++p; /* Skip '-' */ - 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 - testprogfile = option_arg; -#else - usage(progname); -#endif - break; - case 'q': - verbosity--; - break; - case 'r': - refdir = option_arg; - break; - case 'v': - verbosity++; - break; - default: - usage(progname); - } - } - } - - /* - * Sanity-check that our options make sense. - */ -#ifdef PROGRAM - if (testprogfile == NULL) - usage(progname); - { - char *testprg; -#if defined(_WIN32) && !defined(__CYGWIN__) - /* Command.com sometimes rejects '/' separators. */ - testprg = strdup(testprogfile); - for (i = 0; testprg[i] != '\0'; i++) { - if (testprg[i] == '/') - testprg[i] = '\\'; - } - testprogfile = testprg; -#endif - /* Quote the name that gets put into shell command lines. */ - testprg = malloc(strlen(testprogfile) + 3); - strcpy(testprg, "\""); - strcat(testprg, testprogfile); - strcat(testprg, "\""); - testprog = testprg; - } -#endif - - /* - * Create a temp directory for the following tests. - * Include the time the tests started as part of the name, - * to make it easier to track the results of multiple tests. - */ - now = time(NULL); - for (i = 0; ; i++) { - strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp), - "%Y-%m-%dT%H.%M.%S", - localtime(&now)); - sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname, - tmpdir_timestamp, i); - if (assertMakeDir(tmpdir,0755)) - break; - if (i >= 999) { - fprintf(stderr, - "ERROR: Unable to create temp directory %s\n", - tmpdir); - exit(1); - } - } - - /* - * If the user didn't specify a directory for locating - * reference files, try to find the reference files in - * the "usual places." - */ - refdir = refdir_alloc = get_refdir(refdir); - - /* - * Banner with basic information. - */ - printf("\n"); - printf("If tests fail or crash, details will be in:\n"); - printf(" %s\n", tmpdir); - printf("\n"); - if (verbosity > VERBOSITY_SUMMARY_ONLY) { - printf("Reference files will be read from: %s\n", refdir); -#ifdef PROGRAM - printf("Running tests on: %s\n", testprog); -#endif - printf("Exercising: "); - fflush(stdout); - printf("%s\n", EXTRA_VERSION); - } else { - printf("Running "); - fflush(stdout); - } - - /* - * Run some or all of the individual tests. - */ - if (*argv == NULL) { - /* Default: Run all tests. */ - for (i = 0; i < limit; i++) { - if (test_run(i, tmpdir)) - tests_failed++; - tests_run++; - } - } else { - while (*(argv) != NULL) { - if (**argv >= '0' && **argv <= '9') { - i = atoi(*argv); - if (i < 0 || i >= limit) { - printf("*** INVALID Test %s\n", *argv); - free(refdir_alloc); - usage(progname); - /* usage() never returns */ - } - } else { - for (i = 0; i < limit; ++i) { - if (strcmp(*argv, tests[i].name) == 0) - break; - } - if (i >= limit) { - printf("*** INVALID Test ``%s''\n", - *argv); - free(refdir_alloc); - usage(progname); - /* usage() never returns */ - } - } - if (test_run(i, tmpdir)) - tests_failed++; - tests_run++; - argv++; - } - } - - /* - * Report summary statistics. - */ - if (verbosity > VERBOSITY_SUMMARY_ONLY) { - printf("\n"); - printf("Totals:\n"); - printf(" Tests run: %8d\n", tests_run); - printf(" Tests failed: %8d\n", tests_failed); - printf(" Assertions checked:%8d\n", assertions); - printf(" Assertions failed: %8d\n", failures); - printf(" Skips reported: %8d\n", skips); - } - if (failures) { - printf("\n"); - printf("Failing tests:\n"); - for (i = 0; i < limit; ++i) { - if (tests[i].failures) - printf(" %d: %s (%d failures)\n", i, - tests[i].name, tests[i].failures); - } - printf("\n"); - printf("Details for failing tests: %s\n", tmpdir); - printf("\n"); - } else { - if (verbosity == VERBOSITY_SUMMARY_ONLY) - printf("\n"); - printf("%d tests passed, no failures\n", tests_run); - } - - free(refdir_alloc); - - /* If the final tmpdir is empty, we can remove it. */ - /* This should be the usual case when all tests succeed. */ - assertChdir(".."); - rmdir(tmpdir); - - return (tests_failed ? 1 : 0); -} diff --git a/archivers/libarchive/files/libarchive/test/read_open_memory.c b/archivers/libarchive/files/libarchive/test/read_open_memory.c deleted file mode 100644 index e4e911c2f8b..00000000000 --- a/archivers/libarchive/files/libarchive/test/read_open_memory.c +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/read_open_memory.c 191183 2009-04-17 01:06:31Z kientzle $"); - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -/* - * Read an archive from a block of memory. - * - * This is identical to archive_read_open_memory(), except - * that it goes out of its way to be a little bit unpleasant, - * in order to better test the libarchive internals. - */ - -struct read_memory_data { - unsigned char *buffer; - unsigned char *end; - size_t read_size; - size_t copy_buff_size; - size_t copy_buff_offset; - char *copy_buff; -}; - -static int memory_read_close(struct archive *, void *); -static int memory_read_open(struct archive *, void *); -static off_t memory_read_skip(struct archive *, void *, off_t request); -static ssize_t memory_read(struct archive *, void *, const void **buff); -static int read_open_memory_internal(struct archive *a, void *buff, - size_t size, size_t read_size, int fullapi); - - -int -read_open_memory(struct archive *a, void *buff, size_t size, size_t read_size) -{ - return read_open_memory_internal(a, buff, size, read_size, 1); -} - -/* - * As above, but don't register any optional part of the API, to verify - * that internals work correctly with just the minimal entry points. - */ -int -read_open_memory2(struct archive *a, void *buff, size_t size, size_t read_size) -{ - return read_open_memory_internal(a, buff, size, read_size, 0); -} - -static int -read_open_memory_internal(struct archive *a, void *buff, - size_t size, size_t read_size, int fullapi) -{ - struct read_memory_data *mine; - - mine = (struct read_memory_data *)malloc(sizeof(*mine)); - if (mine == NULL) { - archive_set_error(a, ENOMEM, "No memory"); - return (ARCHIVE_FATAL); - } - memset(mine, 0, sizeof(*mine)); - mine->buffer = (unsigned char *)buff; - mine->end = mine->buffer + size; - mine->read_size = read_size; - mine->copy_buff_offset = 32; - mine->copy_buff_size = read_size + mine->copy_buff_offset * 2; - mine->copy_buff = malloc(mine->copy_buff_size); - memset(mine->copy_buff, 0xA5, mine->copy_buff_size); - if (fullapi) - return (archive_read_open2(a, mine, memory_read_open, - memory_read, memory_read_skip, memory_read_close)); - else - return (archive_read_open2(a, mine, NULL, - memory_read, NULL, memory_read_close)); -} - -/* - * There's nothing to open. - */ -static int -memory_read_open(struct archive *a, void *client_data) -{ - (void)a; /* UNUSED */ - (void)client_data; /* UNUSED */ - return (ARCHIVE_OK); -} - -/* - * In order to exercise libarchive's internal read-combining logic, - * we deliberately copy data for each read to a separate buffer. - * That way, code that runs off the end of the provided data - * will screw up. - */ -static ssize_t -memory_read(struct archive *a, void *client_data, const void **buff) -{ - struct read_memory_data *mine = (struct read_memory_data *)client_data; - size_t size; - - (void)a; /* UNUSED */ - size = mine->end - mine->buffer; - if (size > mine->read_size) - size = mine->read_size; - else - memset(mine->copy_buff, 0xA5, mine->copy_buff_size); - memcpy(mine->copy_buff + mine->copy_buff_offset, mine->buffer, size); - *buff = mine->copy_buff + mine->copy_buff_offset; - - mine->buffer += size; - return ((ssize_t)size); -} - -/* - * How mean can a skip() routine be? Let's try to find out. - */ -static off_t -memory_read_skip(struct archive *a, void *client_data, off_t skip) -{ - struct read_memory_data *mine = (struct read_memory_data *)client_data; - - (void)a; /* UNUSED */ - /* We can't skip by more than is available. */ - if ((off_t)skip > (off_t)(mine->end - mine->buffer)) - skip = mine->end - mine->buffer; - /* Always do small skips by prime amounts. */ - if (skip > 71) - skip = 71; - mine->buffer += skip; - return (skip); -} - -/* - * Close is just cleaning up our one small bit of data. - */ -static int -memory_read_close(struct archive *a, void *client_data) -{ - struct read_memory_data *mine = (struct read_memory_data *)client_data; - (void)a; /* UNUSED */ - free(mine->copy_buff); - free(mine); - return (ARCHIVE_OK); -} diff --git a/archivers/libarchive/files/libarchive/test/test.h b/archivers/libarchive/files/libarchive/test/test.h deleted file mode 100644 index 40c31e13dba..00000000000 --- a/archivers/libarchive/files/libarchive/test/test.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2003-2006 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: head/lib/libarchive/test/test.h 201247 2009-12-30 05:59:21Z kientzle $ - */ - -/* Every test program should #include "test.h" as the first thing. */ - -/* - * The goal of this file (and the matching test.c) is to - * simplify the very repetitive test-*.c test programs. - */ -#if defined(HAVE_CONFIG_H) -/* Most POSIX platforms use the 'configure' script to build config.h */ -#include "config.h" -#elif defined(__FreeBSD__) -/* Building as part of FreeBSD system requires a pre-built config.h. */ -#include "config_freebsd.h" -#elif defined(_WIN32) && !defined(__CYGWIN__) -/* Win32 can't run the 'configure' script. */ -#include "config_windows.h" -#else -/* Warn if the library hasn't been (automatically or manually) configured. */ -#error Oops: No config.h and no pre-built configuration in test.h. -#endif - -#include <sys/types.h> /* Windows requires this before sys/stat.h */ -#include <sys/stat.h> - -#if HAVE_DIRENT_H -#include <dirent.h> -#endif -#ifdef HAVE_DIRECT_H -#include <direct.h> -#define dirent direct -#endif -#include <errno.h> -#include <fcntl.h> -#ifdef HAVE_IO_H -#include <io.h> -#endif -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <wchar.h> -#ifdef HAVE_WINDOWS_H -#include <windows.h> -#endif - -/* - * System-specific tweaks. We really want to minimize these - * as much as possible, since they make it harder to understand - * the mainline code. - */ - -/* Windows (including Visual Studio and MinGW but not Cygwin) */ -#if defined(_WIN32) && !defined(__CYGWIN__) -#if !defined(__BORLANDC__) -#define strdup _strdup -#endif -#define LOCALE_UTF8 NULL -#else -#define LOCALE_UTF8 "de_DE.UTF-8" -#endif - -/* Visual Studio */ -#ifdef _MSC_VER -#define snprintf sprintf_s -#endif - -#if defined(__BORLANDC__) -#pragma warn -8068 /* Constant out of range in comparison. */ -#endif - -/* Cygwin */ -#if defined(__CYGWIN__) -/* Cygwin-1.7.x is lazy about populating nlinks, so don't - * expect it to be accurate. */ -# define NLINKS_INACCURATE_FOR_DIRS -#endif - -/* Haiku OS */ -#if defined(__HAIKU__) -/* Haiku has typedefs in stdint.h (needed for int64_t) */ -#include <stdint.h> -#endif - -/* Get a real definition for __FBSDID if we can */ -#if HAVE_SYS_CDEFS_H -#include <sys/cdefs.h> -#endif - -/* If not, define it so as to avoid dangling semicolons. */ -#ifndef __FBSDID -#define __FBSDID(a) struct _undefined_hack -#endif - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -/* - * Redefine DEFINE_TEST for use in defining the test functions. - */ -#undef DEFINE_TEST -#define DEFINE_TEST(name) void name(void); void name(void) - -/* An implementation of the standard assert() macro */ -#define assert(e) assertion_assert(__FILE__, __LINE__, (e), #e, NULL) -/* chdir() and error if it fails */ -#define assertChdir(path) \ - assertion_chdir(__FILE__, __LINE__, path) -/* Assert two integers are the same. Reports value of each one if not. */ -#define assertEqualInt(v1,v2) \ - assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL) -/* Assert two strings are the same. Reports value of each one if not. */ -#define assertEqualString(v1,v2) \ - assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL) -/* As above, but v1 and v2 are wchar_t * */ -#define assertEqualWString(v1,v2) \ - assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL) -/* As above, but raw blocks of bytes. */ -#define assertEqualMem(v1, v2, l) \ - assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL) -/* Assert two files are the same; allow printf-style expansion of second name. - * See below for comments about variable arguments here... - */ -#define assertEqualFile \ - assertion_setup(__FILE__, __LINE__);assertion_equal_file -/* Assert that a file is empty; supports printf-style arguments. */ -#define assertEmptyFile \ - assertion_setup(__FILE__, __LINE__);assertion_empty_file -/* Assert that a file is not empty; supports printf-style arguments. */ -#define assertNonEmptyFile \ - assertion_setup(__FILE__, __LINE__);assertion_non_empty_file -#define assertFileAtime(pathname, sec, nsec) \ - assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec) -#define assertFileAtimeRecent(pathname) \ - assertion_file_atime_recent(__FILE__, __LINE__, pathname) -#define assertFileBirthtime(pathname, sec, nsec) \ - assertion_file_birthtime(__FILE__, __LINE__, pathname, sec, nsec) -#define assertFileBirthtimeRecent(pathname) \ - assertion_file_birthtime_recent(__FILE__, __LINE__, pathname) -/* Assert that a file exists; supports printf-style arguments. */ -#define assertFileExists \ - assertion_setup(__FILE__, __LINE__);assertion_file_exists -/* Assert that a file exists; supports printf-style arguments. */ -#define assertFileNotExists \ - assertion_setup(__FILE__, __LINE__);assertion_file_not_exists -/* Assert that file contents match a string; supports printf-style arguments. */ -#define assertFileContents \ - assertion_setup(__FILE__, __LINE__);assertion_file_contents -#define assertFileMtime(pathname, sec, nsec) \ - assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec) -#define assertFileMtimeRecent(pathname) \ - assertion_file_mtime_recent(__FILE__, __LINE__, pathname) -#define assertFileNLinks(pathname, nlinks) \ - assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) -#define assertFileSize(pathname, size) \ - assertion_file_size(__FILE__, __LINE__, pathname, size) -#define assertTextFileContents \ - assertion_setup(__FILE__, __LINE__);assertion_text_file_contents -#define assertIsDir(pathname, mode) \ - assertion_is_dir(__FILE__, __LINE__, pathname, mode) -#define assertIsHardlink(path1, path2) \ - assertion_is_hardlink(__FILE__, __LINE__, path1, path2) -#define assertIsNotHardlink(path1, path2) \ - assertion_is_not_hardlink(__FILE__, __LINE__, path1, path2) -#define assertIsReg(pathname, mode) \ - assertion_is_reg(__FILE__, __LINE__, pathname, mode) -#define assertIsSymlink(pathname, contents) \ - assertion_is_symlink(__FILE__, __LINE__, pathname, contents) -/* Create a directory, report error if it fails. */ -#define assertMakeDir(dirname, mode) \ - assertion_make_dir(__FILE__, __LINE__, dirname, mode) -#define assertMakeFile(path, mode, contents) \ - assertion_make_file(__FILE__, __LINE__, path, mode, contents) -#define assertMakeHardlink(newfile, oldfile) \ - assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile) -#define assertMakeSymlink(newfile, linkto) \ - assertion_make_symlink(__FILE__, __LINE__, newfile, linkto) -#define assertUmask(mask) \ - assertion_umask(__FILE__, __LINE__, mask) - -/* - * This would be simple with C99 variadic macros, but I don't want to - * require that. Instead, I insert a function call before each - * skipping() call to pass the file and line information down. Crude, - * but effective. - */ -#define skipping \ - assertion_setup(__FILE__, __LINE__);test_skipping - -/* Function declarations. These are defined in test_utility.c. */ -void failure(const char *fmt, ...); -int assertion_assert(const char *, int, int, const char *, void *); -int assertion_chdir(const char *, int, const char *); -int assertion_empty_file(const char *, ...); -int assertion_equal_file(const char *, const char *, ...); -int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *); -int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *); -int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *); -int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *); -int assertion_file_atime(const char *, int, const char *, long, long); -int assertion_file_atime_recent(const char *, int, const char *); -int assertion_file_birthtime(const char *, int, const char *, long, long); -int assertion_file_birthtime_recent(const char *, int, const char *); -int assertion_file_contents(const void *, int, const char *, ...); -int assertion_file_exists(const char *, ...); -int assertion_file_mtime(const char *, int, const char *, long, long); -int assertion_file_mtime_recent(const char *, int, const char *); -int assertion_file_nlinks(const char *, int, const char *, int); -int assertion_file_not_exists(const char *, ...); -int assertion_file_size(const char *, int, const char *, long); -int assertion_is_dir(const char *, int, const char *, int); -int assertion_is_hardlink(const char *, int, const char *, const char *); -int assertion_is_not_hardlink(const char *, int, const char *, const char *); -int assertion_is_reg(const char *, int, const char *, int); -int assertion_is_symlink(const char *, int, const char *, const char *); -int assertion_make_dir(const char *, int, const char *, int); -int assertion_make_file(const char *, int, const char *, int, const char *); -int assertion_make_hardlink(const char *, int, const char *newpath, const char *); -int assertion_make_symlink(const char *, int, const char *newpath, const char *); -int assertion_non_empty_file(const char *, ...); -int assertion_text_file_contents(const char *buff, const char *f); -int assertion_umask(const char *, int, int); -void assertion_setup(const char *, int); - -void test_skipping(const char *fmt, ...); - -/* Like sprintf, then system() */ -int systemf(const char * fmt, ...); - -/* Delay until time() returns a value after this. */ -void sleepUntilAfter(time_t); - -/* Return true if this platform can create symlinks. */ -int canSymlink(void); - -/* Return true if this platform can run the "gzip" program. */ -int canGzip(void); - -/* Return true if this platform can run the "gunzip" program. */ -int canGunzip(void); - -/* Suck file into string allocated via malloc(). Call free() when done. */ -/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */ -char *slurpfile(size_t *, const char *fmt, ...); - -/* Extracts named reference file to the current directory. */ -void extract_reference_file(const char *); - -/* - * Special interfaces for libarchive test harness. - */ - -#include "archive.h" -#include "archive_entry.h" - -/* Special customized read-from-memory interface. */ -int read_open_memory(struct archive *, void *, size_t, size_t); -/* "2" version exercises a slightly different set of libarchive APIs. */ -int read_open_memory2(struct archive *, void *, size_t, size_t); - -/* Versions of above that accept an archive argument for additional info. */ -#define assertA(e) assertion_assert(__FILE__, __LINE__, (e), #e, (a)) -#define assertEqualIntA(a,v1,v2) \ - assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a)) -#define assertEqualStringA(a,v1,v2) \ - assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a)) - -#ifdef USE_DMALLOC -#include <dmalloc.h> -#endif diff --git a/archivers/libarchive/files/libarchive/test/test_acl_basic.c b/archivers/libarchive/files/libarchive/test/test_acl_basic.c deleted file mode 100644 index f66014cdd31..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_acl_basic.c +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_basic.c,v 1.6 2008/10/19 00:13:57 kientzle Exp $"); - -/* - * Exercise the system-independent portion of the ACL support. - * Check that archive_entry objects can save and restore ACL data. - * - * This should work on all systems, regardless of whether local - * filesystems support ACLs or not. - */ - -struct acl_t { - int type; /* Type of ACL: "access" or "default" */ - int permset; /* Permissions for this class of users. */ - int tag; /* Owner, User, Owning group, group, other, etc. */ - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct acl_t acls0[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, - ARCHIVE_ENTRY_ACL_OTHER, 0, "" }, -}; - -static struct acl_t acls1[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, - ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, -}; - -static struct acl_t acls2[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, - ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007, - ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, -}; - -static void -set_acls(struct archive_entry *ae, struct acl_t *acls, int n) -{ - int i; - - archive_entry_acl_clear(ae); - for (i = 0; i < n; i++) { - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, - acls[i].name); - } -} - -static int -acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name) -{ - if (type != acl->type) - return (0); - if (permset != acl->permset) - return (0); - if (tag != acl->tag) - return (0); - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_OTHER) - return (1); - if (qual != acl->qual) - return (0); - if (name == NULL) { - if (acl->name == NULL || acl->name[0] == '\0') - return (1); - } - if (acl->name == NULL) { - if (name[0] == '\0') - return (1); - } - return (0 == strcmp(name, acl->name)); -} - -static void -compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) -{ - int *marker = malloc(sizeof(marker[0]) * n); - int i; - int r; - int type, permset, tag, qual; - int matched; - const char *name; - - for (i = 0; i < n; i++) - marker[i] = i; - - while (0 == (r = archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name))) { - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(&acls[marker[i]], type, permset, - tag, qual, name)) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { - if (!matched) printf("No match for user_obj perm\n"); - failure("USER_OBJ permset (%02o) != user mode (%02o)", - permset, 07 & (mode >> 6)); - assert((permset << 6) == (mode & 0700)); - } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { - if (!matched) printf("No match for group_obj perm\n"); - failure("GROUP_OBJ permset %02o != group mode %02o", - permset, 07 & (mode >> 3)); - assert((permset << 3) == (mode & 0070)); - } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) { - if (!matched) printf("No match for other perm\n"); - failure("OTHER permset (%02o) != other mode (%02o)", - permset, mode & 07); - assert((permset << 0) == (mode & 0007)); - } else { - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - type, permset, tag, qual, name); - assert(matched == 1); - } - } -#if ARCHIVE_VERSION_NUMBER < 1009000 - /* Known broken before 1.9.0. */ - skipping("archive_entry_acl_next() exits with ARCHIVE_EOF"); -#else - assertEqualInt(ARCHIVE_EOF, r); -#endif - assert((mode & 0777) == (archive_entry_mode(ae) & 0777)); - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - acls[marker[0]].type, acls[marker[0]].permset, - acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); - assert(n == 0); /* Number of ACLs not matched should == 0 */ - free(marker); -} - -DEFINE_TEST(test_acl_basic) -{ - struct archive_entry *ae; - - /* Create a simple archive_entry. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0777); - - /* Basic owner/owning group should just update mode bits. */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); - failure("Basic ACLs shouldn't be stored as extended ACLs"); - assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - - /* With any extended ACL entry, we should read back a full set. */ - set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); - failure("One extended ACL should flag all ACLs to be returned."); - assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - - /* A more extensive set of ACLs. */ - set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); - assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543); - failure("Basic ACLs should set mode to 0543, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0543); - - /* - * Check that clearing ACLs gets rid of them all by repeating - * the first test. - */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); - failure("Basic ACLs shouldn't be stored as extended ACLs"); - assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - archive_entry_free(ae); -} diff --git a/archivers/libarchive/files/libarchive/test/test_acl_pax.c b/archivers/libarchive/files/libarchive/test/test_acl_pax.c deleted file mode 100644 index 1f0468ca115..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_acl_pax.c +++ /dev/null @@ -1,517 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_pax.c 201247 2009-12-30 05:59:21Z kientzle $"); - -/* - * Exercise the system-independent portion of the ACL support. - * Check that pax archive can save and restore ACL data. - * - * This should work on all systems, regardless of whether local - * filesystems support ACLs or not. - */ - -static unsigned char buff[16384]; - -static unsigned char reference[] = { -'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0', -'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2',' ','0', -'0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7',0,' ', -'x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r', -0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', -'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10, -'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ', -'S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0', -'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0', -'0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ', -'0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r', -0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', -'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', -0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','1','7','2', -' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','1', -0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t', -'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', -'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,'7','2',' ','S','C','H','I','L','Y','.','a','c','l','.', -'a','c','c','e','s','s','=','u','s','e','r',':',':','-','-','x',',','g','r', -'o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w','-', -',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7','7', -10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10,'1','6', -' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ','S','C', -'H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0','0', -'0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0','0', -'0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ','0', -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0, -'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', -'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ', -0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','2','4','3', -' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','5', -0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t', -'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', -'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,'1','1','3',' ','S','C','H','I','L','Y','.','a','c','l', -'.','a','c','c','e','s','s','=','u','s','e','r',':',':','r','-','x',',','g', -'r','o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w', -'x',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7', -'7',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',':','7', -'8',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x', -':','7','8',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0', -10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8', -' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ',0,'0','0', -'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0', -'0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','1','3',0,' ', -'0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r', -0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', -'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', -0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2', -' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7', -0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t', -'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', -'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=', -'0',10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1', -'8',' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', -0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0', -' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6', -0,' ','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t', -'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', -'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - - -struct acl_t { - int type; /* Type of ACL: "access" or "default" */ - int permset; /* Permissions for this class of users. */ - int tag; /* Owner, User, Owning group, group, other, etc. */ - int qual; /* GID or UID of user/group, depending on tag. */ - const char *name; /* Name of user/group, depending on tag. */ -}; - -static struct acl_t acls0[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, - ARCHIVE_ENTRY_ACL_OTHER, 0, "" }, -}; - -static struct acl_t acls1[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, - ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, -}; - -static struct acl_t acls2[] = { - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, - ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, - ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007, - ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, - { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE, - ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, -}; - -static void -set_acls(struct archive_entry *ae, struct acl_t *acls, int n) -{ - int i; - - archive_entry_acl_clear(ae); - for (i = 0; i < n; i++) { - archive_entry_acl_add_entry(ae, - acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, - acls[i].name); - } -} - -static int -acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name) -{ - if (type != acl->type) - return (0); - if (permset != acl->permset) - return (0); - if (tag != acl->tag) - return (0); - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) - return (1); - if (tag == ARCHIVE_ENTRY_ACL_OTHER) - return (1); - if (qual != acl->qual) - return (0); - if (name == NULL) - return (acl->name == NULL || acl->name[0] == '\0'); - if (acl->name == NULL) - return (name == NULL || name[0] == '\0'); - return (0 == strcmp(name, acl->name)); -} - -static void -compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) -{ - int *marker = malloc(sizeof(marker[0]) * n); - int i; - int r; - int type, permset, tag, qual; - int matched; - const char *name; - - for (i = 0; i < n; i++) - marker[i] = i; - - while (0 == (r = archive_entry_acl_next(ae, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name))) { - for (i = 0, matched = 0; i < n && !matched; i++) { - if (acl_match(&acls[marker[i]], type, permset, - tag, qual, name)) { - /* We found a match; remove it. */ - marker[i] = marker[n - 1]; - n--; - matched = 1; - } - } - if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { - if (!matched) printf("No match for user_obj perm\n"); - failure("USER_OBJ permset (%02o) != user mode (%02o)", - permset, 07 & (mode >> 6)); - assert((permset << 6) == (mode & 0700)); - } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { - if (!matched) printf("No match for group_obj perm\n"); - failure("GROUP_OBJ permset %02o != group mode %02o", - permset, 07 & (mode >> 3)); - assert((permset << 3) == (mode & 0070)); - } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) { - if (!matched) printf("No match for other perm\n"); - failure("OTHER permset (%02o) != other mode (%02o)", - permset, mode & 07); - assert((permset << 0) == (mode & 0007)); - } else { - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - type, permset, tag, qual, name); - assert(matched == 1); - } - } -#if ARCHIVE_VERSION_NUMBER < 1009000 - /* Known broken before 1.9.0. */ - skipping("archive_entry_acl_next() exits with ARCHIVE_EOF"); -#else - assertEqualInt(ARCHIVE_EOF, r); -#endif - assert((mode & 0777) == (archive_entry_mode(ae) & 0777)); - failure("Could not find match for ACL " - "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", - acls[marker[0]].type, acls[marker[0]].permset, - acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); - assert(n == 0); /* Number of ACLs not matched should == 0 */ - free(marker); -} - -DEFINE_TEST(test_acl_pax) -{ - struct archive *a; - struct archive_entry *ae; - size_t used; - FILE *f; - - /* Write an archive to memory. */ - assert(NULL != (a = archive_write_new())); - assertA(0 == archive_write_set_format_pax(a)); - assertA(0 == archive_write_set_compression_none(a)); - assertA(0 == archive_write_set_bytes_per_block(a, 1)); - assertA(0 == archive_write_set_bytes_in_last_block(a, 1)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - - /* Write a series of files to the archive with different ACL info. */ - - /* Create a simple archive_entry. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0777); - - /* Basic owner/owning group should just update mode bits. */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); - assertA(0 == archive_write_header(a, ae)); - - /* With any extended ACL entry, we should read back a full set. */ - set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); - assertA(0 == archive_write_header(a, ae)); - - - /* A more extensive set of ACLs. */ - set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); - assertA(0 == archive_write_header(a, ae)); - - /* - * Check that clearing ACLs gets rid of them all by repeating - * the first test. - */ - set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - - /* 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 - - /* Write out the data we generated to a file for manual inspection. */ - assert(NULL != (f = fopen("testout", "wb"))); - assertEqualInt(used, (size_t)fwrite(buff, 1, (unsigned int)used, f)); - fclose(f); - - /* Write out the reference data to a file for manual inspection. */ - assert(NULL != (f = fopen("reference", "wb"))); - assert(sizeof(reference) == fwrite(reference, 1, sizeof(reference), f)); - fclose(f); - - /* Assert that the generated data matches the built-in reference data.*/ - failure("Generated pax archive does not match reference; check 'testout' and 'reference' files."); - assertEqualMem(buff, reference, sizeof(reference)); - failure("Generated pax archive does not match reference; check 'testout' and 'reference' files."); - assertEqualInt((int)used, sizeof(reference)); - - /* Read back each entry and check that the ACL data is right. */ - assert(NULL != (a = archive_read_new())); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used)); - - /* First item has no ACLs */ - assertA(0 == archive_read_next_header(a, &ae)); - failure("Basic ACLs shouldn't be stored as extended ACLs"); - assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - /* Second item has a few ACLs */ - assertA(0 == archive_read_next_header(a, &ae)); - failure("One extended ACL should flag all ACLs to be returned."); - assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - /* Third item has pretty extensive ACLs */ - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543); - failure("Basic ACLs should set mode to 0543, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0543); - - /* Fourth item has no ACLs */ - assertA(0 == archive_read_next_header(a, &ae)); - failure("Basic ACLs shouldn't be stored as extended ACLs"); - assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - failure("Basic ACLs should set mode to 0142, not %04o", - archive_entry_mode(ae)&0777); - assert((archive_entry_mode(ae) & 0777) == 0142); - - /* Close the archive. */ - assertA(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertA(0 == archive_read_finish(a)); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c b/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c deleted file mode 100644 index 23a7083c07f..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_archive_api_feature.c,v 1.5 2008/05/26 17:00:24 kientzle Exp $"); - -DEFINE_TEST(test_archive_api_feature) -{ - char buff[128]; - const char *p; - - /* This is the (hopefully) final versioning API. */ - assertEqualInt(ARCHIVE_VERSION_NUMBER, archive_version_number()); - sprintf(buff, "libarchive %d.%d.%d", - archive_version_number() / 1000000, - (archive_version_number() / 1000) % 1000, - archive_version_number() % 1000); - failure("Version string is: %s, computed is: %s", - archive_version_string(), buff); - assert(memcmp(buff, archive_version_string(), strlen(buff)) == 0); - if (strlen(buff) < strlen(archive_version_string())) { - p = archive_version_string() + strlen(buff); - failure("Version string is: %s", archive_version_string()); - assert(*p == 'a' || *p == 'b' || *p == 'c' || *p == 'd'); - ++p; - failure("Version string is: %s", archive_version_string()); - assert(*p == '\0'); - } - -/* This is all scheduled to disappear in libarchive 3.0 */ -#if ARCHIVE_VERSION_NUMBER < 3000000 - assertEqualInt(ARCHIVE_VERSION_STAMP, ARCHIVE_VERSION_NUMBER); - assertEqualInt(ARCHIVE_API_FEATURE, archive_api_feature()); - assertEqualInt(ARCHIVE_API_VERSION, archive_api_version()); - /* - * Even though ARCHIVE_VERSION_STAMP only appears in - * archive.h after 1.9.0 and 2.2.3, the macro is synthesized - * in test.h, so this test is always valid. - */ - assertEqualInt(ARCHIVE_VERSION_STAMP / 1000, ARCHIVE_API_VERSION * 1000 + ARCHIVE_API_FEATURE); - /* - * The function, however, isn't always available. It appeared - * sometime in the middle of 2.2.3, but the synthesized value - * never has a release version, so the following conditional - * exactly determines whether the current library has the - * function. - */ -#if ARCHIVE_VERSION_STAMP / 1000 == 1009 || ARCHIVE_VERSION_STAMP > 2002000 - assertEqualInt(ARCHIVE_VERSION_STAMP, archive_version_stamp()); -#else - skipping("archive_version_stamp()"); -#endif - assertEqualString(ARCHIVE_LIBRARY_VERSION, archive_version()); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_bad_fd.c b/archivers/libarchive/files/libarchive/test/test_bad_fd.c deleted file mode 100644 index 3ea7daacf2e..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_bad_fd.c +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_bad_fd.c,v 1.2 2008/09/01 05:38:33 kientzle Exp $"); - -/* Verify that attempting to open an invalid fd returns correct error. */ -DEFINE_TEST(test_bad_fd) -{ - struct archive *a; - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_compression_all(a)); - assertA(ARCHIVE_FATAL == archive_read_open_fd(a, -1, 1024)); - assertA(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertA(0 == archive_read_finish(a)); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_compat_gtar.c b/archivers/libarchive/files/libarchive/test/test_compat_gtar.c deleted file mode 100644 index c0a69598e98..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_compat_gtar.c +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_compat_gtar.c 189308 2009-03-03 17:02:51Z kientzle $"); - -/* - * Verify our ability to read sample files created by GNU tar. - * It should be easy to add any new sample files sent in by users - * to this collection of tests. - */ - -/* Copy this function for each test file and adjust it accordingly. */ - -/* - * test_compat_gtar_1.tgz exercises reading long filenames and - * symlink targets stored in the GNU tar format. - */ -static void -test_compat_gtar_1(void) -{ - char name[] = "test_compat_gtar_1.tar"; - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - extract_reference_file(name); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240)); - - /* Read first entry. */ - assertEqualIntA(a, ARCHIVE_OK, r = archive_read_next_header(a, &ae)); - if (r != ARCHIVE_OK) { - archive_read_finish(a); - return; - } - assertEqualString( - "12345678901234567890123456789012345678901234567890" - "12345678901234567890123456789012345678901234567890" - "12345678901234567890123456789012345678901234567890" - "12345678901234567890123456789012345678901234567890", - archive_entry_pathname(ae)); - assertEqualInt(1197179003, archive_entry_mtime(ae)); - assertEqualInt(1000, archive_entry_uid(ae)); - assertEqualString("tim", archive_entry_uname(ae)); - assertEqualInt(1000, archive_entry_gid(ae)); - assertEqualString("tim", archive_entry_gname(ae)); - assertEqualInt(0100644, archive_entry_mode(ae)); - - /* Read second entry. */ - assertEqualIntA(a, ARCHIVE_OK, r = archive_read_next_header(a, &ae)); - if (r != ARCHIVE_OK) { - archive_read_finish(a); - return; - } - assertEqualString( - "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij" - "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij" - "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij" - "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij", - archive_entry_pathname(ae)); - assertEqualString( - "12345678901234567890123456789012345678901234567890" - "12345678901234567890123456789012345678901234567890" - "12345678901234567890123456789012345678901234567890" - "12345678901234567890123456789012345678901234567890", - archive_entry_symlink(ae)); - assertEqualInt(1197179043, archive_entry_mtime(ae)); - assertEqualInt(1000, archive_entry_uid(ae)); - assertEqualString("tim", archive_entry_uname(ae)); - assertEqualInt(1000, archive_entry_gid(ae)); - assertEqualString("tim", archive_entry_gname(ae)); - assertEqualInt(0120755, archive_entry_mode(ae)); - - /* Verify the end-of-archive. */ - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - - /* Verify that the format detection worked. */ - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR); - - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} - - -DEFINE_TEST(test_compat_gtar) -{ - test_compat_gtar_1(); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_compat_gtar_1.tgz.uu b/archivers/libarchive/files/libarchive/test/test_compat_gtar_1.tgz.uu deleted file mode 100644 index f088a4a5fe6..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_compat_gtar_1.tgz.uu +++ /dev/null @@ -1,9 +0,0 @@ -begin 644 test_compat_gtar_1.tgz -M'XL(`,N`6T<``^W62PZ",!`&X!YE3@`SI:6Z<R^7\(&*+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/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c b/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c deleted file mode 100644 index 30785d1fb0c..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_tar_hardlink.c,v 1.3 2008/08/11 01:19:36 kientzle Exp $"); - -/* - * Background: There are two written standards for the tar file format. - * The first is the POSIX 1988 "ustar" format, the second is the 2001 - * "pax extended" format that builds on the "ustar" format by adding - * support for generic additional attributes. Buried in the details - * is one frustrating incompatibility: The 1988 standard says that - * tar readers MUST ignore the size field on hardlink entries; the - * 2001 standard says that tar readers MUST obey the size field on - * hardlink entries. libarchive tries to navigate this particular - * minefield by using auto-detect logic to guess whether it should - * or should not obey the size field. - * - * This test tries to probe the boundaries of such handling; the test - * archives here were adapted from real archives created by real - * tar implementations that are (as of early 2008) apparently still - * in use. - */ - -static void -test_compat_tar_hardlink_1(void) -{ - char name[] = "test_compat_tar_hardlink_1.tar"; - struct archive_entry *ae; - struct archive *a; - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - extract_reference_file(name); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240)); - - /* Read first entry, which is a regular file. */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("xmcd-3.3.2/docs_d/READMf", - archive_entry_pathname(ae)); - assertEqualString(NULL, archive_entry_hardlink(ae)); - assertEqualInt(321, archive_entry_size(ae)); - assertEqualInt(1082575645, archive_entry_mtime(ae)); - assertEqualInt(1851, archive_entry_uid(ae)); - assertEqualInt(3, archive_entry_gid(ae)); - assertEqualInt(0100444, archive_entry_mode(ae)); - - /* Read second entry, which is a hard link at the end of archive. */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("xmcd-3.3.2/README", - archive_entry_pathname(ae)); - assertEqualString( - "xmcd-3.3.2/docs_d/READMf", - archive_entry_hardlink(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualInt(1082575645, archive_entry_mtime(ae)); - assertEqualInt(1851, archive_entry_uid(ae)); - assertEqualInt(3, archive_entry_gid(ae)); - assertEqualInt(0100444, archive_entry_mode(ae)); - - /* Verify the end-of-archive. */ - /* - * This failed in libarchive 2.4.12 because the tar reader - * tried to obey the size field for the hard link and ended - * up running past the end of the file. - */ - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - - /* Verify that the format detection worked. */ - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR); - - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} - -DEFINE_TEST(test_compat_tar_hardlink) -{ - test_compat_tar_hardlink_1(); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink_1.tar.uu b/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink_1.tar.uu deleted file mode 100644 index 95dba54c256..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink_1.tar.uu +++ /dev/null @@ -1,39 +0,0 @@ -$FreeBSD: src/lib/libarchive/test/test_compat_tar_hardlink_1.tar.uu,v 1.1 2008/01/31 07:47:38 kientzle Exp $ -begin 644 test_compat_tar_hardlink_1.tar -M>&UC9"TS+C,N,B]D;V-S7V0O4D5!1$UF```````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````"`@(#0T-"``("`S-#<S(``@("`@(#,@`"`@("`@("`@-3`Q -M(#$P,#0Q-30U-#,U("`@-S8U-``@```````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````!X>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX -M>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX -M>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX -M>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX -M>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX -M>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX -M>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX -M>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'@````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````'AM8V0M,RXS+C(O -M4D5!1$U%```````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````@ -M("`T-#0@`"`@,S0W,R``("`@("`S(``@("`@("`@(#4P,2`Q,#`T,34T-30S -M-2`@,3(R,#<`(#%X;6-D+3,N,RXR+V1O8W-?9"]214%$368````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -&```````` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_compat_zip.c b/archivers/libarchive/files/libarchive/test/test_compat_zip.c deleted file mode 100644 index d8bc4de3608..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_compat_zip.c +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_compat_zip.c 196962 2009-09-08 05:02:41Z kientzle $"); - -/* Copy this function for each test file and adjust it accordingly. */ -static void -test_compat_zip_1(void) -{ - char name[] = "test_compat_zip_1.zip"; - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); - extract_reference_file(name); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240)); - - /* Read first entry. */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("META-INF/MANIFEST.MF", archive_entry_pathname(ae)); - - /* Read second entry. */ - r = archive_read_next_header(a, &ae); - if (r != ARCHIVE_OK) { - if (strcmp(archive_error_string(a), - "libarchive compiled without deflate support (no libz)") == 0) { - skipping("Skipping ZIP compression check: %s", - archive_error_string(a)); - goto finish; - } - } - assertEqualIntA(a, ARCHIVE_OK, r); - assertEqualString("tmp.class", archive_entry_pathname(ae)); - - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ZIP); - - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); -finish: -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} - - -DEFINE_TEST(test_compat_zip) -{ - test_compat_zip_1(); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_compat_zip_1.zip.uu b/archivers/libarchive/files/libarchive/test/test_compat_zip_1.zip.uu deleted file mode 100644 index 29cdf96b029..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_compat_zip_1.zip.uu +++ /dev/null @@ -1,15 +0,0 @@ -$FreeBSD: src/lib/libarchive/test/test_compat_zip_1.zip.uu,v 1.2 2008/06/30 15:49:12 des Exp $ -begin 644 test_compat_zip_1.zip -M4$L#!!0`"``(``B$@S<````````````````4````345402U)3D8O34%.249% -M4U0N34;S3<S+3$LM+M$-2RTJSLS/LU(PU#/@Y7+,0Q)Q+$A,SDA5`(H!)<U! -MTLY%J8DEJ2FZ3I56"BF9B4DY^;J&>J9Z!O$&YKI)!H8*&L&E>0J^F<E%^<65 -MQ26IN<4*GGG)>IJ\7+Q<`%!+!PAHTY\490```'$```!02P,$%``(``@`"(2# -M-P````````````````D```!T;7`N8VQA<W,[]6_7/@8&!D,&+G8&#G8&3BX& -M1@86'@8V!E9&!F8-S3!&!C:;S+S,$CN@L'-^2BHC@T!68EFB?DYB7KJ^?U)6 -M:G()4&%);@&#(@,34"\(,`(AT``@R0[D"8+Y#`RL6ML9F#>"%3```%!+!P@+ -M(*8V:````'8```!02P$"%``4``@`"``(A(,W:-.?%&4```!Q````%``````` -M````````````````345402U)3D8O34%.249%4U0N34902P$"%``4``@`"``( -MA(,W"R"F-F@```!V````"0````````````````"G````=&UP+F-L87-S4$L% -J!@`````"``(`>0```$8!```7`%!R;T=U87)D+"!V97)S:6]N(#0N,"XQ -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_empty_write.c b/archivers/libarchive/files/libarchive/test/test_empty_write.c deleted file mode 100644 index 0523ec362c3..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_empty_write.c +++ /dev/null @@ -1,120 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_empty_write.c 189308 2009-03-03 17:02:51Z kientzle $"); - -DEFINE_TEST(test_empty_write) -{ - char buff[32768]; - struct archive_entry *ae; - struct archive *a; - size_t used; - int r; - - /* - * Exercise a zero-byte write to a gzip-compressed archive. - */ - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - 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. - */ - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - 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. - */ - - /* 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_none(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)); - assertA(0 == archive_write_finish(a)); -} diff --git a/archivers/libarchive/files/libarchive/test/test_entry.c b/archivers/libarchive/files/libarchive/test/test_entry.c deleted file mode 100644 index b6a2da177ac..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_entry.c +++ /dev/null @@ -1,891 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_entry.c 201247 2009-12-30 05:59:21Z kientzle $"); - -#include <locale.h> - -/* - * Most of these tests are system-independent, though a few depend on - * features of the local system. Such tests are conditionalized on - * the platform name. On unsupported platforms, only the - * system-independent features will be tested. - * - * No, I don't want to use config.h in the test files because I want - * the tests to also serve as a check on the correctness of config.h. - * A mis-configured library build should cause tests to fail. - */ - -DEFINE_TEST(test_entry) -{ - char buff[128]; - wchar_t wbuff[128]; - struct stat st; - struct archive_entry *e, *e2; - const struct stat *pst; - unsigned long set, clear; /* For fflag testing. */ - int type, permset, tag, qual; /* For ACL testing. */ - const char *name; /* For ACL testing. */ - const char *xname; /* For xattr tests. */ - const void *xval; /* For xattr tests. */ - size_t xsize; /* For xattr tests. */ - wchar_t wc; - long l; - - assert((e = archive_entry_new()) != NULL); - - /* - * Verify that the AE_IF* defines match S_IF* defines - * on this platform. See comments in archive_entry.h. - */ -#ifdef S_IFREG - assertEqualInt(S_IFREG, AE_IFREG); -#endif -#ifdef S_IFLNK - assertEqualInt(S_IFLNK, AE_IFLNK); -#endif -#ifdef S_IFSOCK - assertEqualInt(S_IFSOCK, AE_IFSOCK); -#endif -#ifdef S_IFCHR - assertEqualInt(S_IFCHR, AE_IFCHR); -#endif -/* Work around MinGW, which defines S_IFBLK wrong. */ -/* sourceforge.net/tracker/?func=detail&atid=102435&aid=1942809&group_id=2435 */ -#if defined(S_IFBLK) && !defined(_WIN32) - assertEqualInt(S_IFBLK, AE_IFBLK); -#endif -#ifdef S_IFDIR - assertEqualInt(S_IFDIR, AE_IFDIR); -#endif -#ifdef S_IFIFO - assertEqualInt(S_IFIFO, AE_IFIFO); -#endif - - /* - * Basic set/read tests for all fields. - * We should be able to set any field and read - * back the same value. - * - * For methods that "copy" a string, we should be able - * to overwrite the original passed-in string without - * changing the value in the entry. - * - * The following tests are ordered alphabetically by the - * name of the field. - */ - - /* atime */ - archive_entry_set_atime(e, 13579, 24680); - assertEqualInt(archive_entry_atime(e), 13579); - assertEqualInt(archive_entry_atime_nsec(e), 24680); - archive_entry_unset_atime(e); - assertEqualInt(archive_entry_atime(e), 0); - assertEqualInt(archive_entry_atime_nsec(e), 0); - assert(!archive_entry_atime_is_set(e)); - - /* birthtime */ - archive_entry_set_birthtime(e, 17579, 24990); - assertEqualInt(archive_entry_birthtime(e), 17579); - assertEqualInt(archive_entry_birthtime_nsec(e), 24990); - archive_entry_unset_birthtime(e); - assertEqualInt(archive_entry_birthtime(e), 0); - assertEqualInt(archive_entry_birthtime_nsec(e), 0); - assert(!archive_entry_birthtime_is_set(e)); - - /* ctime */ - archive_entry_set_ctime(e, 13580, 24681); - assertEqualInt(archive_entry_ctime(e), 13580); - assertEqualInt(archive_entry_ctime_nsec(e), 24681); - archive_entry_unset_ctime(e); - assertEqualInt(archive_entry_ctime(e), 0); - assertEqualInt(archive_entry_ctime_nsec(e), 0); - assert(!archive_entry_ctime_is_set(e)); - -#if ARCHIVE_VERSION_NUMBER >= 1009000 - /* dev */ - archive_entry_set_dev(e, 235); - assertEqualInt(archive_entry_dev(e), 235); -#else - skipping("archive_entry_dev()"); -#endif - /* devmajor/devminor are tested specially below. */ - -#if ARCHIVE_VERSION_NUMBER >= 1009000 - /* filetype */ - archive_entry_set_filetype(e, AE_IFREG); - assertEqualInt(archive_entry_filetype(e), AE_IFREG); -#else - skipping("archive_entry_filetype()"); -#endif - - /* fflags are tested specially below */ - - /* gid */ - archive_entry_set_gid(e, 204); - assertEqualInt(archive_entry_gid(e), 204); - - /* gname */ - archive_entry_set_gname(e, "group"); - assertEqualString(archive_entry_gname(e), "group"); - wcscpy(wbuff, L"wgroup"); - archive_entry_copy_gname_w(e, wbuff); - assertEqualWString(archive_entry_gname_w(e), L"wgroup"); - memset(wbuff, 0, sizeof(wbuff)); - assertEqualWString(archive_entry_gname_w(e), L"wgroup"); - - /* hardlink */ - archive_entry_set_hardlink(e, "hardlinkname"); - assertEqualString(archive_entry_hardlink(e), "hardlinkname"); - strcpy(buff, "hardlinkname2"); - archive_entry_copy_hardlink(e, buff); - assertEqualString(archive_entry_hardlink(e), "hardlinkname2"); - memset(buff, 0, sizeof(buff)); - assertEqualString(archive_entry_hardlink(e), "hardlinkname2"); - archive_entry_copy_hardlink(e, NULL); - assertEqualString(archive_entry_hardlink(e), NULL); - assertEqualWString(archive_entry_hardlink_w(e), NULL); - wcscpy(wbuff, L"whardlink"); - archive_entry_copy_hardlink_w(e, wbuff); - assertEqualWString(archive_entry_hardlink_w(e), L"whardlink"); - memset(wbuff, 0, sizeof(wbuff)); - assertEqualWString(archive_entry_hardlink_w(e), L"whardlink"); - archive_entry_copy_hardlink_w(e, NULL); - assertEqualString(archive_entry_hardlink(e), NULL); - assertEqualWString(archive_entry_hardlink_w(e), NULL); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - /* ino */ - archive_entry_set_ino(e, 8593); - assertEqualInt(archive_entry_ino(e), 8593); -#else - skipping("archive_entry_ino()"); -#endif - - /* link */ - archive_entry_set_hardlink(e, "hardlinkname"); - archive_entry_set_symlink(e, NULL); - archive_entry_set_link(e, "link"); - assertEqualString(archive_entry_hardlink(e), "link"); - assertEqualString(archive_entry_symlink(e), NULL); - archive_entry_copy_link(e, "link2"); - assertEqualString(archive_entry_hardlink(e), "link2"); - assertEqualString(archive_entry_symlink(e), NULL); - archive_entry_copy_link_w(e, L"link3"); - assertEqualString(archive_entry_hardlink(e), "link3"); - assertEqualString(archive_entry_symlink(e), NULL); - archive_entry_set_hardlink(e, NULL); - archive_entry_set_symlink(e, "symlink"); - archive_entry_set_link(e, "link"); - assertEqualString(archive_entry_hardlink(e), NULL); - assertEqualString(archive_entry_symlink(e), "link"); - archive_entry_copy_link(e, "link2"); - assertEqualString(archive_entry_hardlink(e), NULL); - assertEqualString(archive_entry_symlink(e), "link2"); - archive_entry_copy_link_w(e, L"link3"); - assertEqualString(archive_entry_hardlink(e), NULL); - assertEqualString(archive_entry_symlink(e), "link3"); - /* Arbitrarily override symlink if both hardlink and symlink set. */ - archive_entry_set_hardlink(e, "hardlink"); - archive_entry_set_symlink(e, "symlink"); - archive_entry_set_link(e, "link"); - assertEqualString(archive_entry_hardlink(e), "hardlink"); - assertEqualString(archive_entry_symlink(e), "link"); - - /* mode */ - archive_entry_set_mode(e, 0123456); - assertEqualInt(archive_entry_mode(e), 0123456); - - /* mtime */ - archive_entry_set_mtime(e, 13581, 24682); - assertEqualInt(archive_entry_mtime(e), 13581); - assertEqualInt(archive_entry_mtime_nsec(e), 24682); - archive_entry_unset_mtime(e); - assertEqualInt(archive_entry_mtime(e), 0); - assertEqualInt(archive_entry_mtime_nsec(e), 0); - assert(!archive_entry_mtime_is_set(e)); - -#if ARCHIVE_VERSION_NUMBER >= 1009000 - /* nlink */ - archive_entry_set_nlink(e, 736); - assertEqualInt(archive_entry_nlink(e), 736); -#else - skipping("archive_entry_nlink()"); -#endif - - /* pathname */ - archive_entry_set_pathname(e, "path"); - assertEqualString(archive_entry_pathname(e), "path"); - archive_entry_set_pathname(e, "path"); - assertEqualString(archive_entry_pathname(e), "path"); - strcpy(buff, "path2"); - archive_entry_copy_pathname(e, buff); - assertEqualString(archive_entry_pathname(e), "path2"); - memset(buff, 0, sizeof(buff)); - assertEqualString(archive_entry_pathname(e), "path2"); - wcscpy(wbuff, L"wpath"); - archive_entry_copy_pathname_w(e, wbuff); - assertEqualWString(archive_entry_pathname_w(e), L"wpath"); - memset(wbuff, 0, sizeof(wbuff)); - assertEqualWString(archive_entry_pathname_w(e), L"wpath"); - -#if ARCHIVE_VERSION_NUMBER >= 1009000 - /* rdev */ - archive_entry_set_rdev(e, 532); - assertEqualInt(archive_entry_rdev(e), 532); -#else - skipping("archive_entry_rdev()"); -#endif - /* rdevmajor/rdevminor are tested specially below. */ - - /* size */ - archive_entry_set_size(e, 987654321); - assertEqualInt(archive_entry_size(e), 987654321); - archive_entry_unset_size(e); - assertEqualInt(archive_entry_size(e), 0); - assert(!archive_entry_size_is_set(e)); - - /* sourcepath */ - archive_entry_copy_sourcepath(e, "path1"); - assertEqualString(archive_entry_sourcepath(e), "path1"); - - /* symlink */ - archive_entry_set_symlink(e, "symlinkname"); - assertEqualString(archive_entry_symlink(e), "symlinkname"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - strcpy(buff, "symlinkname2"); - archive_entry_copy_symlink(e, buff); - assertEqualString(archive_entry_symlink(e), "symlinkname2"); - memset(buff, 0, sizeof(buff)); - assertEqualString(archive_entry_symlink(e), "symlinkname2"); -#endif - archive_entry_copy_symlink_w(e, NULL); - assertEqualWString(archive_entry_symlink_w(e), NULL); - assertEqualString(archive_entry_symlink(e), NULL); - archive_entry_copy_symlink_w(e, L"wsymlink"); - assertEqualWString(archive_entry_symlink_w(e), L"wsymlink"); - archive_entry_copy_symlink(e, NULL); - assertEqualWString(archive_entry_symlink_w(e), NULL); - assertEqualString(archive_entry_symlink(e), NULL); - - /* uid */ - archive_entry_set_uid(e, 83); - assertEqualInt(archive_entry_uid(e), 83); - - /* uname */ - archive_entry_set_uname(e, "user"); - assertEqualString(archive_entry_uname(e), "user"); - wcscpy(wbuff, L"wuser"); - archive_entry_copy_gname_w(e, wbuff); - assertEqualWString(archive_entry_gname_w(e), L"wuser"); - memset(wbuff, 0, sizeof(wbuff)); - assertEqualWString(archive_entry_gname_w(e), L"wuser"); - - /* Test fflags interface. */ - archive_entry_set_fflags(e, 0x55, 0xAA); - archive_entry_fflags(e, &set, &clear); - failure("Testing set/get of fflags data."); - assertEqualInt(set, 0x55); - failure("Testing set/get of fflags data."); - assertEqualInt(clear, 0xAA); -#ifdef __FreeBSD__ - /* Converting fflags bitmap to string is currently system-dependent. */ - /* TODO: Make this system-independent. */ - assertEqualString(archive_entry_fflags_text(e), - "uappnd,nouchg,nodump,noopaque,uunlnk"); - /* Test archive_entry_copy_fflags_text_w() */ - archive_entry_copy_fflags_text_w(e, L" ,nouappnd, nouchg, dump,uunlnk"); - archive_entry_fflags(e, &set, &clear); - assertEqualInt(16, set); - assertEqualInt(7, clear); - /* Test archive_entry_copy_fflags_text() */ - archive_entry_copy_fflags_text(e, " ,nouappnd, nouchg, dump,uunlnk"); - archive_entry_fflags(e, &set, &clear); - assertEqualInt(16, set); - assertEqualInt(7, clear); -#endif - - /* See test_acl_basic.c for tests of ACL set/get consistency. */ - - /* Test xattrs set/get consistency. */ - archive_entry_xattr_add_entry(e, "xattr1", "xattrvalue1", 12); - assertEqualInt(1, archive_entry_xattr_reset(e)); - assertEqualInt(0, archive_entry_xattr_next(e, &xname, &xval, &xsize)); - assertEqualString(xname, "xattr1"); - assertEqualString(xval, "xattrvalue1"); - 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((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((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); - assertEqualInt(2, archive_entry_xattr_reset(e)); - assertEqualInt(0, archive_entry_xattr_next(e, &xname, &xval, &xsize)); - assertEqualInt(0, archive_entry_xattr_next(e, &xname, &xval, &xsize)); - assertEqualInt(ARCHIVE_WARN, - archive_entry_xattr_next(e, &xname, &xval, &xsize)); - assertEqualString(xname, NULL); - assertEqualString(xval, NULL); - assertEqualInt((int)xsize, 0); - - - /* - * Test clone() implementation. - */ - - /* Set values in 'e' */ - archive_entry_clear(e); - archive_entry_set_atime(e, 13579, 24680); - archive_entry_set_birthtime(e, 13779, 24990); - archive_entry_set_ctime(e, 13580, 24681); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_dev(e, 235); -#endif - archive_entry_set_fflags(e, 0x55, 0xAA); - archive_entry_set_gid(e, 204); - archive_entry_set_gname(e, "group"); - archive_entry_set_hardlink(e, "hardlinkname"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_ino(e, 8593); -#endif - archive_entry_set_mode(e, 0123456); - archive_entry_set_mtime(e, 13581, 24682); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_nlink(e, 736); -#endif - archive_entry_set_pathname(e, "path"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_rdev(e, 532); -#endif - archive_entry_set_size(e, 987654321); - archive_entry_copy_sourcepath(e, "source"); - archive_entry_set_symlink(e, "symlinkname"); - archive_entry_set_uid(e, 83); - archive_entry_set_uname(e, "user"); - /* Add an ACL entry. */ - archive_entry_acl_add_entry(e, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - ARCHIVE_ENTRY_ACL_READ, ARCHIVE_ENTRY_ACL_USER, 77, "user77"); - /* Add an extended attribute. */ - archive_entry_xattr_add_entry(e, "xattr1", "xattrvalue", 11); - - /* Make a clone. */ - e2 = archive_entry_clone(e); - - /* Clone should have same contents. */ - assertEqualInt(archive_entry_atime(e2), 13579); - assertEqualInt(archive_entry_atime_nsec(e2), 24680); - assertEqualInt(archive_entry_birthtime(e2), 13779); - assertEqualInt(archive_entry_birthtime_nsec(e2), 24990); - assertEqualInt(archive_entry_ctime(e2), 13580); - assertEqualInt(archive_entry_ctime_nsec(e2), 24681); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_dev(e2), 235); -#endif - archive_entry_fflags(e, &set, &clear); - assertEqualInt(clear, 0xAA); - assertEqualInt(set, 0x55); - assertEqualInt(archive_entry_gid(e2), 204); - assertEqualString(archive_entry_gname(e2), "group"); - assertEqualString(archive_entry_hardlink(e2), "hardlinkname"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_ino(e2), 8593); -#endif - assertEqualInt(archive_entry_mode(e2), 0123456); - assertEqualInt(archive_entry_mtime(e2), 13581); - assertEqualInt(archive_entry_mtime_nsec(e2), 24682); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_nlink(e2), 736); -#endif - assertEqualString(archive_entry_pathname(e2), "path"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_rdev(e2), 532); -#endif - assertEqualInt(archive_entry_size(e2), 987654321); - assertEqualString(archive_entry_sourcepath(e2), "source"); - assertEqualString(archive_entry_symlink(e2), "symlinkname"); - assertEqualInt(archive_entry_uid(e2), 83); - assertEqualString(archive_entry_uname(e2), "user"); -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("ACL preserved by archive_entry_clone()"); -#else - /* Verify ACL was copied. */ - assertEqualInt(4, archive_entry_acl_reset(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - /* First three are standard permission bits. */ - assertEqualInt(0, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - assertEqualInt(permset, 4); - assertEqualInt(tag, ARCHIVE_ENTRY_ACL_USER_OBJ); - assertEqualInt(qual, -1); - assertEqualString(name, NULL); - assertEqualInt(0, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - assertEqualInt(permset, 5); - assertEqualInt(tag, ARCHIVE_ENTRY_ACL_GROUP_OBJ); - assertEqualInt(qual, -1); - assertEqualString(name, NULL); - assertEqualInt(0, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - assertEqualInt(permset, 6); - assertEqualInt(tag, ARCHIVE_ENTRY_ACL_OTHER); - assertEqualInt(qual, -1); - assertEqualString(name, NULL); - /* Fourth is custom one. */ - assertEqualInt(0, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - assertEqualInt(permset, ARCHIVE_ENTRY_ACL_READ); - assertEqualInt(tag, ARCHIVE_ENTRY_ACL_USER); - assertEqualInt(qual, 77); - assertEqualString(name, "user77"); -#endif -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("xattr data preserved by archive_entry_clone"); -#else - /* Verify xattr was copied. */ - assertEqualInt(1, archive_entry_xattr_reset(e2)); - assertEqualInt(0, archive_entry_xattr_next(e2, &xname, &xval, &xsize)); - assertEqualString(xname, "xattr1"); - assertEqualString(xval, "xattrvalue"); - assertEqualInt((int)xsize, 11); - assertEqualInt(ARCHIVE_WARN, - archive_entry_xattr_next(e2, &xname, &xval, &xsize)); - assertEqualString(xname, NULL); - assertEqualString(xval, NULL); - assertEqualInt((int)xsize, 0); -#endif - - /* Change the original */ - archive_entry_set_atime(e, 13580, 24690); - archive_entry_set_birthtime(e, 13980, 24999); - archive_entry_set_ctime(e, 13590, 24691); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_dev(e, 245); -#endif - archive_entry_set_fflags(e, 0x85, 0xDA); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_filetype(e, AE_IFLNK); -#endif - archive_entry_set_gid(e, 214); - archive_entry_set_gname(e, "grouper"); - archive_entry_set_hardlink(e, "hardlinkpath"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_ino(e, 8763); -#endif - archive_entry_set_mode(e, 0123654); - archive_entry_set_mtime(e, 18351, 28642); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_nlink(e, 73); -#endif - archive_entry_set_pathname(e, "pathest"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_rdev(e, 132); -#endif - archive_entry_set_size(e, 987456321); - archive_entry_copy_sourcepath(e, "source2"); - archive_entry_set_symlink(e, "symlinkpath"); - archive_entry_set_uid(e, 93); - archive_entry_set_uname(e, "username"); - archive_entry_acl_clear(e); - archive_entry_xattr_clear(e); - - /* Clone should still have same contents. */ - assertEqualInt(archive_entry_atime(e2), 13579); - assertEqualInt(archive_entry_atime_nsec(e2), 24680); - assertEqualInt(archive_entry_birthtime(e2), 13779); - assertEqualInt(archive_entry_birthtime_nsec(e2), 24990); - assertEqualInt(archive_entry_ctime(e2), 13580); - assertEqualInt(archive_entry_ctime_nsec(e2), 24681); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_dev(e2), 235); -#endif - archive_entry_fflags(e2, &set, &clear); - assertEqualInt(clear, 0xAA); - assertEqualInt(set, 0x55); - assertEqualInt(archive_entry_gid(e2), 204); - assertEqualString(archive_entry_gname(e2), "group"); - assertEqualString(archive_entry_hardlink(e2), "hardlinkname"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_ino(e2), 8593); -#endif - assertEqualInt(archive_entry_mode(e2), 0123456); - assertEqualInt(archive_entry_mtime(e2), 13581); - assertEqualInt(archive_entry_mtime_nsec(e2), 24682); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_nlink(e2), 736); -#endif - assertEqualString(archive_entry_pathname(e2), "path"); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_rdev(e2), 532); -#endif - assertEqualInt(archive_entry_size(e2), 987654321); - assertEqualString(archive_entry_sourcepath(e2), "source"); - assertEqualString(archive_entry_symlink(e2), "symlinkname"); - assertEqualInt(archive_entry_uid(e2), 83); - assertEqualString(archive_entry_uname(e2), "user"); -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("ACL held by clone of archive_entry"); -#else - /* Verify ACL was unchanged. */ - assertEqualInt(4, archive_entry_acl_reset(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); - /* First three are standard permission bits. */ - assertEqualInt(0, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - assertEqualInt(permset, 4); - assertEqualInt(tag, ARCHIVE_ENTRY_ACL_USER_OBJ); - assertEqualInt(qual, -1); - assertEqualString(name, NULL); - assertEqualInt(0, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - assertEqualInt(permset, 5); - assertEqualInt(tag, ARCHIVE_ENTRY_ACL_GROUP_OBJ); - assertEqualInt(qual, -1); - assertEqualString(name, NULL); - assertEqualInt(0, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - assertEqualInt(permset, 6); - assertEqualInt(tag, ARCHIVE_ENTRY_ACL_OTHER); - assertEqualInt(qual, -1); - assertEqualString(name, NULL); - /* Fourth is custom one. */ - assertEqualInt(0, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); - assertEqualInt(permset, ARCHIVE_ENTRY_ACL_READ); - assertEqualInt(tag, ARCHIVE_ENTRY_ACL_USER); - assertEqualInt(qual, 77); - assertEqualString(name, "user77"); - assertEqualInt(1, archive_entry_acl_next(e2, - ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - &type, &permset, &tag, &qual, &name)); - assertEqualInt(type, 0); - assertEqualInt(permset, 0); - assertEqualInt(tag, 0); - assertEqualInt(qual, -1); - assertEqualString(name, NULL); -#endif -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("xattr preserved in archive_entry copy"); -#else - /* Verify xattr was unchanged. */ - assertEqualInt(1, archive_entry_xattr_reset(e2)); -#endif - - /* Release clone. */ - archive_entry_free(e2); - - /* - * Test clear() implementation. - */ - archive_entry_clear(e); - assertEqualInt(archive_entry_atime(e), 0); - assertEqualInt(archive_entry_atime_nsec(e), 0); - assertEqualInt(archive_entry_birthtime(e), 0); - assertEqualInt(archive_entry_birthtime_nsec(e), 0); - assertEqualInt(archive_entry_ctime(e), 0); - assertEqualInt(archive_entry_ctime_nsec(e), 0); - assertEqualInt(archive_entry_dev(e), 0); - archive_entry_fflags(e, &set, &clear); - assertEqualInt(clear, 0); - assertEqualInt(set, 0); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_filetype(e), 0); -#endif - assertEqualInt(archive_entry_gid(e), 0); - assertEqualString(archive_entry_gname(e), NULL); - assertEqualString(archive_entry_hardlink(e), NULL); - assertEqualInt(archive_entry_ino(e), 0); - assertEqualInt(archive_entry_mode(e), 0); - assertEqualInt(archive_entry_mtime(e), 0); - assertEqualInt(archive_entry_mtime_nsec(e), 0); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_nlink(e), 0); -#endif - assertEqualString(archive_entry_pathname(e), NULL); - assertEqualInt(archive_entry_rdev(e), 0); - assertEqualInt(archive_entry_size(e), 0); - assertEqualString(archive_entry_symlink(e), NULL); - assertEqualInt(archive_entry_uid(e), 0); - assertEqualString(archive_entry_uname(e), NULL); - /* ACLs should be cleared. */ - assertEqualInt(archive_entry_acl_count(e, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), 0); - assertEqualInt(archive_entry_acl_count(e, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT), 0); - /* Extended attributes should be cleared. */ - assertEqualInt(archive_entry_xattr_count(e), 0); - - /* - * Test archive_entry_copy_stat(). - */ - memset(&st, 0, sizeof(st)); - /* Set all of the standard 'struct stat' fields. */ - st.st_atime = 456789; - st.st_ctime = 345678; - st.st_dev = 123; - st.st_gid = 34; - st.st_ino = 234; - st.st_mode = 077777; - st.st_mtime = 234567; - st.st_nlink = 345; - st.st_size = 123456789; - st.st_uid = 23; -#ifdef __FreeBSD__ - /* On FreeBSD, high-res timestamp data should come through. */ - st.st_atimespec.tv_nsec = 6543210; - st.st_ctimespec.tv_nsec = 5432109; - st.st_mtimespec.tv_nsec = 3210987; - st.st_birthtimespec.tv_nsec = 7459386; -#endif - /* Copy them into the entry. */ - archive_entry_copy_stat(e, &st); - /* Read each one back separately and compare. */ - assertEqualInt(archive_entry_atime(e), 456789); - assertEqualInt(archive_entry_ctime(e), 345678); - assertEqualInt(archive_entry_dev(e), 123); - assertEqualInt(archive_entry_gid(e), 34); - assertEqualInt(archive_entry_ino(e), 234); - assertEqualInt(archive_entry_mode(e), 077777); - assertEqualInt(archive_entry_mtime(e), 234567); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(archive_entry_nlink(e), 345); -#endif - assertEqualInt(archive_entry_size(e), 123456789); - assertEqualInt(archive_entry_uid(e), 23); -#if __FreeBSD__ - /* On FreeBSD, high-res timestamp data should come through. */ - assertEqualInt(archive_entry_atime_nsec(e), 6543210); - assertEqualInt(archive_entry_ctime_nsec(e), 5432109); - assertEqualInt(archive_entry_mtime_nsec(e), 3210987); - assertEqualInt(archive_entry_birthtime_nsec(e), 7459386); -#endif - - /* - * Test archive_entry_stat(). - */ - /* First, clear out any existing stat data. */ - memset(&st, 0, sizeof(st)); - archive_entry_copy_stat(e, &st); - /* Set a bunch of fields individually. */ - archive_entry_set_atime(e, 456789, 321); - archive_entry_set_ctime(e, 345678, 432); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_dev(e, 123); -#endif - archive_entry_set_gid(e, 34); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_ino(e, 234); -#endif - archive_entry_set_mode(e, 012345); - archive_entry_set_mode(e, 012345); - archive_entry_set_mtime(e, 234567, 543); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_nlink(e, 345); -#endif - archive_entry_set_size(e, 123456789); - archive_entry_set_uid(e, 23); - /* Retrieve a stat structure. */ - assert((pst = archive_entry_stat(e)) != NULL); - /* Check that the values match. */ - assertEqualInt(pst->st_atime, 456789); - assertEqualInt(pst->st_ctime, 345678); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(pst->st_dev, 123); -#endif - assertEqualInt(pst->st_gid, 34); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(pst->st_ino, 234); -#endif - assertEqualInt(pst->st_mode, 012345); - assertEqualInt(pst->st_mtime, 234567); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - assertEqualInt(pst->st_nlink, 345); -#endif - assertEqualInt(pst->st_size, 123456789); - assertEqualInt(pst->st_uid, 23); -#ifdef __FreeBSD__ - /* On FreeBSD, high-res timestamp data should come through. */ - assertEqualInt(pst->st_atimespec.tv_nsec, 321); - assertEqualInt(pst->st_ctimespec.tv_nsec, 432); - assertEqualInt(pst->st_mtimespec.tv_nsec, 543); -#endif - - /* Changing any one value should update struct stat. */ - archive_entry_set_atime(e, 456788, 0); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_atime, 456788); - archive_entry_set_ctime(e, 345677, 431); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_ctime, 345677); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_dev(e, 122); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_dev, 122); -#endif - archive_entry_set_gid(e, 33); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_gid, 33); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_ino(e, 233); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_ino, 233); -#endif - archive_entry_set_mode(e, 012344); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_mode, 012344); - archive_entry_set_mtime(e, 234566, 542); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_mtime, 234566); -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_nlink(e, 344); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_nlink, 344); -#endif - archive_entry_set_size(e, 123456788); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_size, 123456788); - archive_entry_set_uid(e, 22); - assert((pst = archive_entry_stat(e)) != NULL); - assertEqualInt(pst->st_uid, 22); - /* We don't need to check high-res fields here. */ - - /* - * Test dev/major/minor interfaces. Setting 'dev' or 'rdev' - * should change the corresponding major/minor values, and - * vice versa. - * - * The test here is system-specific because it assumes that - * makedev(), major(), and minor() are defined in sys/stat.h. - * I'm not too worried about it, though, because the code is - * simple. If it works on FreeBSD, it's unlikely to be broken - * anywhere else. Note: The functionality is present on every - * platform even if these tests only run some places; - * libarchive's more extensive configuration logic should find - * the necessary definitions on every platform. - */ -#if __FreeBSD__ -#if ARCHIVE_VERSION_NUMBER >= 1009000 - archive_entry_set_dev(e, 0x12345678); - assertEqualInt(archive_entry_devmajor(e), major(0x12345678)); - assertEqualInt(archive_entry_devminor(e), minor(0x12345678)); - assertEqualInt(archive_entry_dev(e), 0x12345678); - archive_entry_set_devmajor(e, 0xfe); - archive_entry_set_devminor(e, 0xdcba98); - assertEqualInt(archive_entry_devmajor(e), 0xfe); - assertEqualInt(archive_entry_devminor(e), 0xdcba98); - assertEqualInt(archive_entry_dev(e), makedev(0xfe, 0xdcba98)); - archive_entry_set_rdev(e, 0x12345678); - assertEqualInt(archive_entry_rdevmajor(e), major(0x12345678)); - assertEqualInt(archive_entry_rdevminor(e), minor(0x12345678)); - assertEqualInt(archive_entry_rdev(e), 0x12345678); - archive_entry_set_rdevmajor(e, 0xfe); - archive_entry_set_rdevminor(e, 0xdcba98); - assertEqualInt(archive_entry_rdevmajor(e), 0xfe); - assertEqualInt(archive_entry_rdevminor(e), 0xdcba98); - assertEqualInt(archive_entry_rdev(e), makedev(0xfe, 0xdcba98)); -#endif -#endif - - /* - * Exercise the character-conversion logic, if we can. - */ - if (NULL == LOCALE_UTF8 || NULL == setlocale(LC_ALL, LOCALE_UTF8)) { - skipping("Can't exercise charset-conversion logic without" - " a suitable locale."); - } else { - /* A filename that cannot be converted to wide characters. */ - archive_entry_copy_pathname(e, "abc\314\214mno\374xyz"); - failure("Converting invalid chars to Unicode should fail."); - assert(NULL == archive_entry_pathname_w(e)); - //failure("Converting invalid chars to UTF-8 should fail."); - //assert(NULL == archive_entry_pathname_utf8(e)); - - /* A group name that cannot be converted. */ - archive_entry_copy_gname(e, "abc\314\214mno\374xyz"); - failure("Converting invalid chars to Unicode should fail."); - assert(NULL == archive_entry_gname_w(e)); - - /* A user name that cannot be converted. */ - archive_entry_copy_uname(e, "abc\314\214mno\374xyz"); - failure("Converting invalid chars to Unicode should fail."); - assert(NULL == archive_entry_uname_w(e)); - - /* A hardlink target that cannot be converted. */ - archive_entry_copy_hardlink(e, "abc\314\214mno\374xyz"); - failure("Converting invalid chars to Unicode should fail."); - assert(NULL == archive_entry_hardlink_w(e)); - - /* A symlink target that cannot be converted. */ - archive_entry_copy_symlink(e, "abc\314\214mno\374xyz"); - failure("Converting invalid chars to Unicode should fail."); - assert(NULL == archive_entry_symlink_w(e)); - } - - l = 0x12345678L; - wc = (wchar_t)l; /* Wide character too big for UTF-8. */ - if (NULL == setlocale(LC_ALL, "C") || (long)wc != l) { - skipping("Testing charset conversion failure requires 32-bit wchar_t and support for \"C\" locale."); - } else { - /* - * Build the string L"xxx\U12345678yyy\u5678zzz" without - * using C99 \u#### syntax, which isn't uniformly - * supported. (GCC 3.4.6, for instance, defaults to - * "c89 plus GNU extensions.") - */ - wcscpy(wbuff, L"xxxAyyyBzzz"); - 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."); - assertEqualString(NULL, archive_entry_pathname(e)); - } - - /* Release the experimental entry. */ - archive_entry_free(e); -} diff --git a/archivers/libarchive/files/libarchive/test/test_entry_strmode.c b/archivers/libarchive/files/libarchive/test/test_entry_strmode.c deleted file mode 100644 index ba183db025a..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_entry_strmode.c +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_entry_strmode.c 201247 2009-12-30 05:59:21Z kientzle $"); - -DEFINE_TEST(test_entry_strmode) -{ - struct archive_entry *entry; - - assert((entry = archive_entry_new()) != NULL); - - archive_entry_set_mode(entry, AE_IFREG | 0642); - assertEqualString(archive_entry_strmode(entry), "-rw-r---w- "); - - /* Regular file + hardlink still shows as regular file. */ - archive_entry_set_mode(entry, AE_IFREG | 0644); - archive_entry_set_hardlink(entry, "link"); - assertEqualString(archive_entry_strmode(entry), "-rw-r--r-- "); - - archive_entry_set_mode(entry, 0640); - archive_entry_set_hardlink(entry, "link"); - assertEqualString(archive_entry_strmode(entry), "hrw-r----- "); - archive_entry_set_hardlink(entry, NULL); - - archive_entry_set_mode(entry, AE_IFDIR | 0777); - assertEqualString(archive_entry_strmode(entry), "drwxrwxrwx "); - - archive_entry_set_mode(entry, AE_IFBLK | 03642); - assertEqualString(archive_entry_strmode(entry), "brw-r-S-wT "); - - archive_entry_set_mode(entry, AE_IFCHR | 05777); - assertEqualString(archive_entry_strmode(entry), "crwsrwxrwt "); - - archive_entry_set_mode(entry, AE_IFSOCK | 0222); - assertEqualString(archive_entry_strmode(entry), "s-w--w--w- "); - - archive_entry_set_mode(entry, AE_IFIFO | 0444); - assertEqualString(archive_entry_strmode(entry), "pr--r--r-- "); - - archive_entry_set_mode(entry, AE_IFLNK | 04000); - assertEqualString(archive_entry_strmode(entry), "l--S------ "); - - archive_entry_acl_add_entry(entry, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, - 0007, ARCHIVE_ENTRY_ACL_GROUP, 78, "group78"); - assertEqualString(archive_entry_strmode(entry), "l--S------+"); - - /* Release the experimental entry. */ - archive_entry_free(entry); -} diff --git a/archivers/libarchive/files/libarchive/test/test_link_resolver.c b/archivers/libarchive/files/libarchive/test/test_link_resolver.c deleted file mode 100644 index 8332c4f985b..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_link_resolver.c +++ /dev/null @@ -1,205 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_link_resolver.c,v 1.2 2008/06/15 04:31:43 kientzle Exp $"); - -static void test_linkify_tar(void) -{ - struct archive_entry *entry, *e2; - struct archive_entry_linkresolver *resolver; - - /* Initialize the resolver. */ - assert(NULL != (resolver = archive_entry_linkresolver_new())); - archive_entry_linkresolver_set_strategy(resolver, - ARCHIVE_FORMAT_TAR_USTAR); - - /* Create an entry with only 1 link and try to linkify it. */ - assert(NULL != (entry = archive_entry_new())); - archive_entry_set_pathname(entry, "test1"); - archive_entry_set_ino(entry, 1); - archive_entry_set_dev(entry, 2); - archive_entry_set_nlink(entry, 1); - archive_entry_set_size(entry, 10); - archive_entry_linkify(resolver, &entry, &e2); - - /* Shouldn't have been changed. */ - assert(e2 == NULL); - assertEqualInt(10, archive_entry_size(entry)); - assertEqualString("test1", archive_entry_pathname(entry)); - - /* Now, try again with an entry that has 2 links. */ - archive_entry_set_pathname(entry, "test2"); - archive_entry_set_nlink(entry, 2); - archive_entry_set_ino(entry, 2); - archive_entry_linkify(resolver, &entry, &e2); - /* Shouldn't be altered, since it wasn't seen before. */ - assert(e2 == NULL); - assertEqualString("test2", archive_entry_pathname(entry)); - assertEqualString(NULL, archive_entry_hardlink(entry)); - assertEqualInt(10, archive_entry_size(entry)); - - /* Match again and make sure it does get altered. */ - archive_entry_linkify(resolver, &entry, &e2); - assert(e2 == NULL); - assertEqualString("test2", archive_entry_pathname(entry)); - assertEqualString("test2", archive_entry_hardlink(entry)); - assertEqualInt(0, archive_entry_size(entry)); - - - /* Dirs should never be matched as hardlinks, regardless. */ - archive_entry_set_pathname(entry, "test3"); - archive_entry_set_nlink(entry, 2); - archive_entry_set_filetype(entry, AE_IFDIR); - archive_entry_set_ino(entry, 3); - archive_entry_set_hardlink(entry, NULL); - archive_entry_linkify(resolver, &entry, &e2); - /* Shouldn't be altered, since it wasn't seen before. */ - assert(e2 == NULL); - assertEqualString("test3", archive_entry_pathname(entry)); - assertEqualString(NULL, archive_entry_hardlink(entry)); - - /* Dir, so it shouldn't get matched. */ - archive_entry_linkify(resolver, &entry, &e2); - assert(e2 == NULL); - assertEqualString("test3", archive_entry_pathname(entry)); - assertEqualString(NULL, archive_entry_hardlink(entry)); - - archive_entry_free(entry); - archive_entry_linkresolver_free(resolver); -} - -static void test_linkify_old_cpio(void) -{ - struct archive_entry *entry, *e2; - struct archive_entry_linkresolver *resolver; - - /* Initialize the resolver. */ - assert(NULL != (resolver = archive_entry_linkresolver_new())); - archive_entry_linkresolver_set_strategy(resolver, - ARCHIVE_FORMAT_CPIO_POSIX); - - /* Create an entry with 2 link and try to linkify it. */ - assert(NULL != (entry = archive_entry_new())); - archive_entry_set_pathname(entry, "test1"); - archive_entry_set_ino(entry, 1); - archive_entry_set_dev(entry, 2); - archive_entry_set_nlink(entry, 2); - archive_entry_set_size(entry, 10); - archive_entry_linkify(resolver, &entry, &e2); - - /* Shouldn't have been changed. */ - assert(e2 == NULL); - assertEqualInt(10, archive_entry_size(entry)); - assertEqualString("test1", archive_entry_pathname(entry)); - - /* Still shouldn't be matched. */ - archive_entry_linkify(resolver, &entry, &e2); - assert(e2 == NULL); - assertEqualString("test1", archive_entry_pathname(entry)); - assertEqualString(NULL, archive_entry_hardlink(entry)); - assertEqualInt(10, archive_entry_size(entry)); - - archive_entry_free(entry); - archive_entry_linkresolver_free(resolver); -} - -static void test_linkify_new_cpio(void) -{ - struct archive_entry *entry, *e2; - struct archive_entry_linkresolver *resolver; - - /* Initialize the resolver. */ - assert(NULL != (resolver = archive_entry_linkresolver_new())); - archive_entry_linkresolver_set_strategy(resolver, - ARCHIVE_FORMAT_CPIO_SVR4_NOCRC); - - /* Create an entry with only 1 link and try to linkify it. */ - assert(NULL != (entry = archive_entry_new())); - archive_entry_set_pathname(entry, "test1"); - archive_entry_set_ino(entry, 1); - archive_entry_set_dev(entry, 2); - archive_entry_set_nlink(entry, 1); - archive_entry_set_size(entry, 10); - archive_entry_linkify(resolver, &entry, &e2); - - /* Shouldn't have been changed. */ - assert(e2 == NULL); - assertEqualInt(10, archive_entry_size(entry)); - assertEqualString("test1", archive_entry_pathname(entry)); - - /* Now, try again with an entry that has 3 links. */ - archive_entry_set_pathname(entry, "test2"); - archive_entry_set_nlink(entry, 3); - archive_entry_set_ino(entry, 2); - archive_entry_linkify(resolver, &entry, &e2); - - /* First time, it just gets swallowed. */ - assert(entry == NULL); - assert(e2 == NULL); - - /* Match again. */ - assert(NULL != (entry = archive_entry_new())); - archive_entry_set_pathname(entry, "test3"); - archive_entry_set_ino(entry, 2); - archive_entry_set_dev(entry, 2); - archive_entry_set_nlink(entry, 2); - archive_entry_set_size(entry, 10); - archive_entry_linkify(resolver, &entry, &e2); - - /* Should get back "test2" and nothing else. */ - assertEqualString("test2", archive_entry_pathname(entry)); - assertEqualInt(0, archive_entry_size(entry)); - archive_entry_free(entry); - assert(NULL == e2); - archive_entry_free(e2); /* This should be a no-op. */ - - /* Match a third time. */ - assert(NULL != (entry = archive_entry_new())); - archive_entry_set_pathname(entry, "test4"); - archive_entry_set_ino(entry, 2); - archive_entry_set_dev(entry, 2); - archive_entry_set_nlink(entry, 3); - archive_entry_set_size(entry, 10); - archive_entry_linkify(resolver, &entry, &e2); - - /* Should get back "test3". */ - assertEqualString("test3", archive_entry_pathname(entry)); - assertEqualInt(0, archive_entry_size(entry)); - - /* Since "test4" was the last link, should get it back also. */ - assertEqualString("test4", archive_entry_pathname(e2)); - assertEqualInt(10, archive_entry_size(e2)); - - archive_entry_free(entry); - archive_entry_free(e2); - archive_entry_linkresolver_free(resolver); -} - -DEFINE_TEST(test_link_resolver) -{ - test_linkify_tar(); - test_linkify_old_cpio(); - test_linkify_new_cpio(); -} diff --git a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c deleted file mode 100644 index 5f1ac935c1e..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c +++ /dev/null @@ -1,333 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_pax_filename_encoding.c 201247 2009-12-30 05:59:21Z kientzle $"); - -#include <locale.h> - -/* - * Pax interchange is supposed to encode filenames into - * UTF-8. Of course, that's not always possible. This - * test is intended to verify that filenames always get - * stored and restored correctly, regardless of the encodings. - */ - -/* - * Read a manually-created archive that has filenames that are - * stored in binary instead of UTF-8 and verify that we get - * the right filename returned and that we get a warning only - * if the header isn't marked as binary. - */ -static void -test_pax_filename_encoding_1(void) -{ - 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. - */ - char filename[] = "abc\314\214mno\374xyz"; - struct archive *a; - struct archive_entry *entry; - - /* - * Read an archive that has non-UTF8 pax filenames in it. - */ - extract_reference_file(testname); - a = archive_read_new(); - assertEqualInt(ARCHIVE_OK, archive_read_support_format_tar(a)); - assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualInt(ARCHIVE_OK, - archive_read_open_filename(a, testname, 10240)); - /* - * First entry in this test archive has an invalid UTF-8 sequence - * in it, but the header is not marked as hdrcharset=BINARY, so that - * requires a warning. - */ - failure("Invalid UTF8 in a pax archive pathname should cause a warning"); - assertEqualInt(ARCHIVE_WARN, archive_read_next_header(a, &entry)); - assertEqualString(filename, archive_entry_pathname(entry)); - /* - * Second entry is identical except that it does have - * hdrcharset=BINARY, so no warning should be generated. - */ - failure("A pathname with hdrcharset=BINARY can have invalid UTF8\n" - " characters in it without generating a warning"); - assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry)); - assertEqualString(filename, archive_entry_pathname(entry)); - archive_read_finish(a); -} - -/* - * Set the locale and write a pathname containing invalid characters. - * This should work; the underlying implementation should automatically - * fall back to storing the pathname in binary. - */ -static void -test_pax_filename_encoding_2(void) -{ - char filename[] = "abc\314\214mno\374xyz"; - struct archive *a; - struct archive_entry *entry; - char buff[65536]; - char longname[] = "abc\314\214mno\374xyz" - "/abc\314\214mno\374xyz/abcdefghijklmnopqrstuvwxyz" - "/abc\314\214mno\374xyz/abcdefghijklmnopqrstuvwxyz" - "/abc\314\214mno\374xyz/abcdefghijklmnopqrstuvwxyz" - "/abc\314\214mno\374xyz/abcdefghijklmnopqrstuvwxyz" - "/abc\314\214mno\374xyz/abcdefghijklmnopqrstuvwxyz" - "/abc\314\214mno\374xyz/abcdefghijklmnopqrstuvwxyz" - ; - size_t used; - - /* - * We need a starting locale which has invalid sequences. - * de_DE.UTF-8 seems to be commonly supported. - */ - /* If it doesn't exist, just warn and return. */ - if (LOCALE_UTF8 == NULL - || NULL == setlocale(LC_ALL, LOCALE_UTF8)) { - skipping("invalid encoding tests require a suitable locale;" - " %s not available on this system", LOCALE_UTF8); - return; - } - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, 0, archive_write_set_format_pax(a)); - assertEqualIntA(a, 0, archive_write_set_compression_none(a)); - assertEqualIntA(a, 0, archive_write_set_bytes_per_block(a, 0)); - assertEqualInt(0, - archive_write_open_memory(a, buff, sizeof(buff), &used)); - - assert((entry = archive_entry_new()) != NULL); - /* Set pathname, gname, uname, hardlink to nonconvertible values. */ - archive_entry_copy_pathname(entry, filename); - archive_entry_copy_gname(entry, filename); - archive_entry_copy_uname(entry, filename); - archive_entry_copy_hardlink(entry, filename); - archive_entry_set_filetype(entry, AE_IFREG); - failure("This should generate a warning for nonconvertible names."); - assertEqualInt(ARCHIVE_WARN, archive_write_header(a, entry)); - archive_entry_free(entry); - - assert((entry = archive_entry_new()) != NULL); - /* Set path, gname, uname, and symlink to nonconvertible values. */ - archive_entry_copy_pathname(entry, filename); - archive_entry_copy_gname(entry, filename); - archive_entry_copy_uname(entry, filename); - archive_entry_copy_symlink(entry, filename); - archive_entry_set_filetype(entry, AE_IFLNK); - failure("This should generate a warning for nonconvertible names."); - assertEqualInt(ARCHIVE_WARN, archive_write_header(a, entry)); - archive_entry_free(entry); - - assert((entry = archive_entry_new()) != NULL); - /* Set pathname to a very long nonconvertible value. */ - archive_entry_copy_pathname(entry, longname); - archive_entry_set_filetype(entry, AE_IFREG); - failure("This should generate a warning for nonconvertible names."); - assertEqualInt(ARCHIVE_WARN, archive_write_header(a, entry)); - archive_entry_free(entry); - - assertEqualInt(0, archive_write_close(a)); - assertEqualInt(0, archive_write_finish(a)); - - /* - * Now read the entries back. - */ - - assert((a = archive_read_new()) != NULL); - assertEqualInt(0, archive_read_support_format_tar(a)); - assertEqualInt(0, archive_read_open_memory(a, buff, used)); - - assertEqualInt(0, archive_read_next_header(a, &entry)); - assertEqualString(filename, archive_entry_pathname(entry)); - assertEqualString(filename, archive_entry_gname(entry)); - assertEqualString(filename, archive_entry_uname(entry)); - assertEqualString(filename, archive_entry_hardlink(entry)); - - assertEqualInt(0, archive_read_next_header(a, &entry)); - assertEqualString(filename, archive_entry_pathname(entry)); - assertEqualString(filename, archive_entry_gname(entry)); - assertEqualString(filename, archive_entry_uname(entry)); - assertEqualString(filename, archive_entry_symlink(entry)); - - assertEqualInt(0, archive_read_next_header(a, &entry)); - assertEqualString(longname, archive_entry_pathname(entry)); - - assertEqualInt(0, archive_read_close(a)); - assertEqualInt(0, archive_read_finish(a)); -} - -/* - * Create an entry starting from a wide-character Unicode pathname, - * read it back into "C" locale, which doesn't support the name. - * TODO: Figure out the "right" behavior here. - */ -static void -test_pax_filename_encoding_3(void) -{ - wchar_t badname[] = L"xxxAyyyBzzz"; - const char badname_utf8[] = "xxx\xE1\x88\xB4yyy\xE5\x99\xB8zzz"; - struct archive *a; - struct archive_entry *entry; - char buff[65536]; - size_t used; - - badname[3] = 0x1234; - badname[7] = 0x5678; - - /* If it doesn't exist, just warn and return. */ - if (NULL == setlocale(LC_ALL, "C")) { - skipping("Can't set \"C\" locale, so can't exercise " - "certain character-conversion failures"); - return; - } - - /* If wctomb is broken, warn and return. */ - if (wctomb(buff, 0x1234) > 0) { - skipping("Cannot test conversion failures because \"C\" " - "locale on this system has no invalid characters."); - return; - } - - /* If wctomb is broken, warn and return. */ - if (wctomb(buff, 0x1234) > 0) { - skipping("Cannot test conversion failures because \"C\" " - "locale on this system has no invalid characters."); - return; - } - - /* Skip test if archive_entry_update_pathname_utf8() is broken. */ - /* In particular, this is currently broken on Win32 because - * setlocale() does not set the default encoding for CP_ACP. */ - entry = archive_entry_new(); - if (archive_entry_update_pathname_utf8(entry, badname_utf8)) { - archive_entry_free(entry); - skipping("Cannot test conversion failures."); - return; - } - archive_entry_free(entry); - - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, 0, archive_write_set_format_pax(a)); - assertEqualIntA(a, 0, archive_write_set_compression_none(a)); - assertEqualIntA(a, 0, archive_write_set_bytes_per_block(a, 0)); - assertEqualInt(0, - archive_write_open_memory(a, buff, sizeof(buff), &used)); - - assert((entry = archive_entry_new()) != NULL); - /* Set pathname to non-convertible wide value. */ - archive_entry_copy_pathname_w(entry, badname); - archive_entry_set_filetype(entry, AE_IFREG); - assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry)); - archive_entry_free(entry); - - assert((entry = archive_entry_new()) != NULL); - archive_entry_copy_pathname_w(entry, L"abc"); - /* Set gname to non-convertible wide value. */ - archive_entry_copy_gname_w(entry, badname); - archive_entry_set_filetype(entry, AE_IFREG); - assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry)); - archive_entry_free(entry); - - assert((entry = archive_entry_new()) != NULL); - archive_entry_copy_pathname_w(entry, L"abc"); - /* Set uname to non-convertible wide value. */ - archive_entry_copy_uname_w(entry, badname); - archive_entry_set_filetype(entry, AE_IFREG); - assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry)); - archive_entry_free(entry); - - assert((entry = archive_entry_new()) != NULL); - archive_entry_copy_pathname_w(entry, L"abc"); - /* Set hardlink to non-convertible wide value. */ - archive_entry_copy_hardlink_w(entry, badname); - archive_entry_set_filetype(entry, AE_IFREG); - assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry)); - archive_entry_free(entry); - - assert((entry = archive_entry_new()) != NULL); - archive_entry_copy_pathname_w(entry, L"abc"); - /* Set symlink to non-convertible wide value. */ - archive_entry_copy_symlink_w(entry, badname); - archive_entry_set_filetype(entry, AE_IFLNK); - assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry)); - archive_entry_free(entry); - - assertEqualInt(0, archive_write_close(a)); - assertEqualInt(0, archive_write_finish(a)); - - /* - * Now read the entries back. - */ - - assert((a = archive_read_new()) != NULL); - assertEqualInt(0, archive_read_support_format_tar(a)); - assertEqualInt(0, archive_read_open_memory(a, buff, used)); - - failure("A non-convertible pathname should cause a warning."); - assertEqualInt(ARCHIVE_WARN, archive_read_next_header(a, &entry)); - assertEqualWString(badname, archive_entry_pathname_w(entry)); - failure("If native locale can't convert, we should get UTF-8 back."); - assertEqualString(badname_utf8, archive_entry_pathname(entry)); - - failure("A non-convertible gname should cause a warning."); - assertEqualInt(ARCHIVE_WARN, archive_read_next_header(a, &entry)); - assertEqualWString(badname, archive_entry_gname_w(entry)); - failure("If native locale can't convert, we should get UTF-8 back."); - assertEqualString(badname_utf8, archive_entry_gname(entry)); - - failure("A non-convertible uname should cause a warning."); - assertEqualInt(ARCHIVE_WARN, archive_read_next_header(a, &entry)); - assertEqualWString(badname, archive_entry_uname_w(entry)); - failure("If native locale can't convert, we should get UTF-8 back."); - assertEqualString(badname_utf8, archive_entry_uname(entry)); - - failure("A non-convertible hardlink should cause a warning."); - assertEqualInt(ARCHIVE_WARN, archive_read_next_header(a, &entry)); - assertEqualWString(badname, archive_entry_hardlink_w(entry)); - failure("If native locale can't convert, we should get UTF-8 back."); - assertEqualString(badname_utf8, archive_entry_hardlink(entry)); - - failure("A non-convertible symlink should cause a warning."); - assertEqualInt(ARCHIVE_WARN, archive_read_next_header(a, &entry)); - assertEqualWString(badname, archive_entry_symlink_w(entry)); - assertEqualWString(NULL, archive_entry_hardlink_w(entry)); - failure("If native locale can't convert, we should get UTF-8 back."); - assertEqualString(badname_utf8, archive_entry_symlink(entry)); - - assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &entry)); - - assertEqualInt(0, archive_read_close(a)); - assertEqualInt(0, archive_read_finish(a)); -} - -DEFINE_TEST(test_pax_filename_encoding) -{ - test_pax_filename_encoding_1(); - test_pax_filename_encoding_2(); - test_pax_filename_encoding_3(); -} diff --git a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.gz.uu b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.gz.uu deleted file mode 100644 index 7191aac5849..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.gz.uu +++ /dev/null @@ -1,10 +0,0 @@ -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-"<H>#\S,>@[>99FC]H](>>VM'2G>M7[/(_@-CP/V-4>`2Z$K3. -MD?L_M%E6#"W",1CC;_D_[SW_*;+-_!><N?SO@R;_D[B,$E/.;*4O1M?G-Q/_ -L%T<!1\7V/@IP\<T=!7^![ER_8H_\%PI=_O>!RW^'P^$X3CX`98.>C@`4```` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_compress_program.c b/archivers/libarchive/files/libarchive/test/test_read_compress_program.c deleted file mode 100644 index 4e6c610de25..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_compress_program.c +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_compress_program.c 201247 2009-12-30 05:59:21Z kientzle $"); - -static unsigned char archive[] = { -31,139,8,0,222,'C','p','C',0,3,211,'c',160,'=','0','0','0','0','7','5','U', -0,210,134,230,166,6,200,'4',28,'(',24,26,24,27,155,24,152,24,154,27,155,')', -24,24,26,152,154,25,'2','(',152,210,193,'m',12,165,197,'%',137,'E','@',167, -148,'d',230,226,'U','G','H',30,234,15,'8','=',10,'F',193,'(',24,5,131,28, -0,0,29,172,5,240,0,6,0,0}; - -DEFINE_TEST(test_read_compress_program) -{ - int r; - struct archive_entry *ae; - struct archive *a; - - /* - * First, test handling when a non-existent compression - * program is requested. - */ - assert((a = archive_read_new()) != NULL); - r = archive_read_support_compression_program(a, "nonexistent"); - if (r == ARCHIVE_FATAL) { - skipping("archive_read_support_compression_program() " - "unsupported on this platform"); - return; - } - assertEqualIntA(a, ARCHIVE_OK, r); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_FATAL, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - - /* - * If we have "gzip -d", try using that. - */ - if (!canGunzip()) { - skipping("Can't run gunzip program on this platform"); - return; - } - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_none(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_program(a, "gunzip")); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_PROGRAM); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_data_large.c b/archivers/libarchive/files/libarchive/test/test_read_data_large.c deleted file mode 100644 index fe9120b5954..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_data_large.c +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_data_large.c 201247 2009-12-30 05:59:21Z kientzle $"); - -/* - * Test read/write of a 10M block of data in a single operation. - * Uses an in-memory archive with a single 10M entry. Exercises - * archive_read_data() to ensure it can handle large blocks like - * this and also exercises archive_read_data_into_fd() (which - * had a bug relating to this, fixed in Nov 2006). - */ - -#if defined(_WIN32) && !defined(__CYGWIN__) -#define open _open -#define close _close -#endif - -char buff1[11000000]; -char buff2[10000000]; -char buff3[10000000]; - -DEFINE_TEST(test_read_data_large) -{ - struct archive_entry *ae; - struct archive *a; - char tmpfilename[] = "largefile"; - int tmpfilefd; - FILE *f; - unsigned int i; - size_t used; - - /* 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_none(a)); - assertA(0 == archive_write_open_memory(a, buff1, sizeof(buff1), &used)); - - /* - * Write a file (with random contents) to it. - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0755); - for (i = 0; i < sizeof(buff2); i++) - buff2[i] = (unsigned char)rand(); - archive_entry_set_size(ae, sizeof(buff2)); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA((int)sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2))); - - /* 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 - - /* Check that archive_read_data can handle 10*10^6 at a pop. */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff1, sizeof(buff1))); - assertA(0 == archive_read_next_header(a, &ae)); - failure("Wrote 10MB, but didn't read the same amount"); - assertEqualIntA(a, sizeof(buff2),archive_read_data(a, buff3, sizeof(buff3))); - failure("Read expected 10MB, but data read didn't match what was written"); - assert(0 == memcmp(buff2, buff3, sizeof(buff3))); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - /* Check archive_read_data_into_fd */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff1, sizeof(buff1))); - assertA(0 == archive_read_next_header(a, &ae)); -#if defined(__BORLANDC__) - tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY); -#else - tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY, 0777); -#endif - assert(tmpfilefd != 0); - assertEqualIntA(a, 0, archive_read_data_into_fd(a, tmpfilefd)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - close(tmpfilefd); - - f = fopen(tmpfilename, "rb"); - assert(f != NULL); - assertEqualInt(sizeof(buff3), fread(buff3, 1, sizeof(buff3), f)); - fclose(f); - assert(0 == memcmp(buff2, buff3, sizeof(buff3))); -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_extract.c b/archivers/libarchive/files/libarchive/test/test_read_extract.c deleted file mode 100644 index 5696e0d356f..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_extract.c +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_extract.c 201247 2009-12-30 05:59:21Z kientzle $"); - -#define BUFF_SIZE 1000000 -#define FILE_BUFF_SIZE 100000 - -DEFINE_TEST(test_read_extract) -{ - struct archive_entry *ae; - struct archive *a; - size_t used; - int i, numEntries = 0; - char *buff, *file_buff; - - buff = malloc(BUFF_SIZE); - file_buff = malloc(FILE_BUFF_SIZE); - - /* Force the umask to something predictable. */ - assertUmask(022); - - /* Create a new archive in memory containing various types of entries. */ - 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_open_memory(a, buff, BUFF_SIZE, &used)); - /* A directory to be restored with EXTRACT_PERM. */ - ++numEntries; - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir_0775"); - archive_entry_set_mode(ae, S_IFDIR | 0775); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - /* A regular file. */ - ++numEntries; - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0755); - for (i = 0; i < FILE_BUFF_SIZE; i++) - file_buff[i] = (unsigned char)rand(); - archive_entry_set_size(ae, FILE_BUFF_SIZE); - assertA(0 == archive_write_header(a, ae)); - assertA(FILE_BUFF_SIZE == archive_write_data(a, file_buff, FILE_BUFF_SIZE)); - archive_entry_free(ae); - /* A directory that should obey umask when restored. */ - ++numEntries; - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir"); - archive_entry_set_mode(ae, S_IFDIR | 0777); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - /* A file in the directory. */ - ++numEntries; - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir/file"); - archive_entry_set_mode(ae, S_IFREG | 0700); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - /* A file in a dir that is not already in the archive. */ - ++numEntries; - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir2/file"); - archive_entry_set_mode(ae, S_IFREG | 0000); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - /* A dir with a trailing /. */ - ++numEntries; - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir3/."); - archive_entry_set_mode(ae, S_IFDIR | 0710); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - /* Multiple dirs with a single entry. */ - ++numEntries; - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir4/a/../b/../c/"); - archive_entry_set_mode(ae, S_IFDIR | 0711); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - /* A symlink. */ - if (canSymlink()) { - ++numEntries; - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "symlink"); - archive_entry_set_mode(ae, AE_IFLNK | 0755); - archive_entry_set_symlink(ae, "file"); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - } - /* Close out the archive. */ - assertA(0 == archive_write_close(a)); - assertA(0 == archive_write_finish(a)); - - /* Extract the entries to disk. */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, BUFF_SIZE)); - /* Restore first entry with _EXTRACT_PERM. */ - failure("Error reading first entry", i); - assertA(0 == archive_read_next_header(a, &ae)); - assertA(0 == archive_read_extract(a, ae, ARCHIVE_EXTRACT_PERM)); - /* Rest of entries get restored with no flags. */ - for (i = 1; i < numEntries; i++) { - failure("Error reading entry %d", i); - assertA(0 == archive_read_next_header(a, &ae)); - failure("Failed to extract entry %d: %s", i, - archive_entry_pathname(ae)); - assertA(0 == archive_read_extract(a, ae, 0)); - } - assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); - assert(0 == archive_read_finish(a)); - - /* Test the entries on disk. */ - /* This first entry was extracted with ARCHIVE_EXTRACT_PERM, - * so the permissions should have been restored exactly, - * including resetting the gid bit on those platforms - * where gid is inherited by subdirs. */ - failure("This was 0775 in archive, and should be 0775 on disk"); - assertIsDir("dir_0775", 0775); - /* Everything else was extracted without ARCHIVE_EXTRACT_PERM, - * so there may be some sloppiness about gid bits on directories. */ - assertIsReg("file", 0755); - assertFileSize("file", FILE_BUFF_SIZE); - assertFileContents(file_buff, FILE_BUFF_SIZE, "file"); - /* If EXTRACT_PERM wasn't used, be careful to ignore sgid bit - * when checking dir modes, as some systems inherit sgid bit - * from the parent dir. */ - failure("This was 0777 in archive, but umask should make it 0755"); - assertIsDir("dir", 0755); - assertIsReg("dir/file", 0700); - assertIsDir("dir2", 0755); - assertIsReg("dir2/file", 0000); - assertIsDir("dir3", 0710); - assertIsDir("dir4", 0755); - assertIsDir("dir4/a", 0755); - assertIsDir("dir4/b", 0755); - assertIsDir("dir4/c", 0711); - if (canSymlink()) - assertIsSymlink("symlink", "file"); - - free(buff); - free(file_buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_ar.c b/archivers/libarchive/files/libarchive/test/test_read_format_ar.c deleted file mode 100644 index efea38d2c53..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_ar.c +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 2007 Kai Wang - * Copyright (c) 2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_ar.c 201247 2009-12-30 05:59:21Z kientzle $"); - - -DEFINE_TEST(test_read_format_ar) -{ - char buff[64]; - const char reffile[] = "test_read_format_ar.ar"; - struct archive_entry *ae; - struct archive *a; - - extract_reference_file(reffile); - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_file(a, reffile, 7)); - - /* Filename table. */ - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualString("//", archive_entry_pathname(ae)); - assertEqualInt(0, archive_entry_mtime(ae)); - assertEqualInt(0, archive_entry_uid(ae)); - assertEqualInt(0, archive_entry_gid(ae)); - assertEqualInt(0, archive_entry_size(ae)); - - /* First Entry */ - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualString("yyytttsssaaafff.o", archive_entry_pathname(ae)); - assertEqualInt(1175465652, archive_entry_mtime(ae)); - assertEqualInt(1001, archive_entry_uid(ae)); - assertEqualInt(0, archive_entry_gid(ae)); - assert(8 == archive_entry_size(ae)); - assertA(8 == archive_read_data(a, buff, 10)); - assert(0 == memcmp(buff, "55667788", 8)); - - /* Second Entry */ - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualString("gghh.o", archive_entry_pathname(ae)); - assertEqualInt(1175465668, archive_entry_mtime(ae)); - assertEqualInt(1001, archive_entry_uid(ae)); - assertEqualInt(0, archive_entry_gid(ae)); - assert(4 == archive_entry_size(ae)); - assertA(4 == archive_read_data(a, buff, 10)); - assert(0 == memcmp(buff, "3333", 4)); - - /* Third Entry */ - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualString("hhhhjjjjkkkkllll.o", archive_entry_pathname(ae)); - assertEqualInt(1175465713, archive_entry_mtime(ae)); - assertEqualInt(1001, archive_entry_uid(ae)); - assertEqualInt(0, archive_entry_gid(ae)); - assert(9 == archive_entry_size(ae)); - assertA(9 == archive_read_data(a, buff, 9)); - assert(0 == memcmp(buff, "987654321", 9)); - - /* Test EOF */ - assertA(1 == archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); - assert(0 == archive_read_finish(a)); -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin.c deleted file mode 100644 index fecc0ab4834..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin.c +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_bin.c,v 1.2 2008/09/01 05:38:33 kientzle Exp $"); - -static unsigned char archive[] = { -199,'q',21,4,177,'y',237,'A',232,3,232,3,2,0,0,0,'p','C',244,'M',2,0,0,0, -0,0,'.',0,199,'q',0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,11,0,0,0,0,0,'T','R', -'A','I','L','E','R','!','!','!',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - -DEFINE_TEST(test_read_format_cpio_bin) -{ - struct archive_entry *ae; - struct archive *a; - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_memory(a, archive, sizeof(archive))); - assertA(0 == archive_read_next_header(a, &ae)); - assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE); - assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_Z.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_Z.c deleted file mode 100644 index bae370b1717..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_Z.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_Z.c 189464 2009-03-07 00:25:33Z kientzle $"); - -static unsigned char archive[] = { -31,157,144,199,226,'T',' ',16,'+','O',187,' ',232,6,'$',20,0,160,'!',156, -'!',244,154,'0','l',216,208,5,128,128,20,'3','R',12,160,177,225,2,141,'T', -164,4,'I',194,164,136,148,16,'(',';',170,'\\',201,178,165,203,151,'0','c', -202,156,'I',179,166,205,155,'8','s',234,220,201,179,167,207,159,'@',127,2}; - -DEFINE_TEST(test_read_format_cpio_bin_Z) -{ - struct archive_entry *ae; - struct archive *a; - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - failure("archive_compression_name(a)=\"%s\"", - archive_compression_name(a)); - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS); - assertEqualString(archive_compression_name(a), "compress (.Z)"); - failure("archive_format_name(a)=\"%s\"", - archive_format_name(a)); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_bz2.c deleted file mode 100644 index 598c6256ad1..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_bz2.c +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_bz2.c 201247 2009-12-30 05:59:21Z kientzle $"); - -static unsigned char archive[] = { -'B','Z','h','9','1','A','Y','&','S','Y',134,'J',208,'4',0,0,30,246,141,253, -8,2,0,' ',1,'*','&',20,0,'`',' ',' ',2,0,128,0,'B',4,8,' ',0,'T','P',0,'4', -0,13,6,137,168,245,27,'Q',160,'a',25,169,5,'I',187,'(',10,'d','E',177,177, -142,218,232,'r',130,'4','D',247,'<','Z',190,'U',237,236,'d',227,31,' ','z', -192,'E','_',23,'r','E','8','P',144,134,'J',208,'4'}; - -DEFINE_TEST(test_read_format_cpio_bin_bz2) -{ - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - r = archive_read_support_compression_bzip2(a); - if (r != ARCHIVE_OK) { - skipping("bzip2 support unavailable"); - archive_read_close(a); - return; - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2); - assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE); - assert(0 == archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_gz.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_gz.c deleted file mode 100644 index 4457fb3c6ff..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_gz.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_gz.c 191183 2009-04-17 01:06:31Z kientzle $"); - -static unsigned char archive[] = { -31,139,8,0,244,'M','p','C',0,3,';','^','(',202,178,177,242,173,227,11,230, -23,204,'L',12,12,12,5,206,'_','|','A','4',3,131,30,195,241,'B',6,'8','`', -132,210,220,'`','2','$',200,209,211,199,'5','H','Q','Q',145,'a',20,12,'i', -0,0,170,199,228,195,0,2,0,0}; - -DEFINE_TEST(test_read_format_cpio_bin_gz) -{ - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a)); - r = archive_read_support_compression_gzip(a); - if (r == ARCHIVE_WARN) { - skipping("gzip reading not fully supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - return; - } - failure("archive_read_support_compression_gzip"); - assertEqualInt(ARCHIVE_OK, r); - assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualInt(ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), - ARCHIVE_COMPRESSION_GZIP); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE); - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_odc.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_odc.c deleted file mode 100644 index 6563fcd7e9e..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_odc.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_odc.c,v 1.3 2008/09/01 05:38:33 kientzle Exp $"); - -static unsigned char archive[] = { -'0','7','0','7','0','7','0','0','2','0','2','5','0','7','4','6','6','1','0', -'4','0','7','5','5','0','0','1','7','5','0','0','0','1','7','5','0','0','0', -'0','0','0','2','0','0','0','0','0','0','1','0','3','3','4','0','5','0','0', -'5','3','0','0','0','0','0','2','0','0','0','0','0','0','0','0','0','0','0', -'.',0,'0','7','0','7','0','7','0','0','0','0','0','0','0','0','0','0','0', -'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0', -'0','0','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0', -'0','0','0','0','0','0','0','0','1','3','0','0','0','0','0','0','0','0','0', -'0','0','T','R','A','I','L','E','R','!','!','!',0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0}; - -DEFINE_TEST(test_read_format_cpio_odc) -{ - struct archive_entry *ae; - struct archive *a; - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); - assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE); - assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_POSIX); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip.c deleted file mode 100644 index 8b19a021b0d..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_svr4_gzip.c 191183 2009-04-17 01:06:31Z kientzle $"); - -static unsigned char archive[] = { -31,139,8,0,236,'c',217,'D',0,3,'3','0','7','0','7','0','4','0','0',181,'0', -183,'L',2,210,6,6,'&',134,169,')',' ',218,192,'8',213,2,133,'6','0','0','2', -'1','6','7','0','5','0','N','6','@',5,'&',16,202,208,212,0,';','0',130,'1', -244,24,12,160,246,17,5,136,'U',135,14,146,'`',140,144,' ','G','O',31,215, -' ','E','E','E',134,'Q',128,21,0,0,'%',215,202,221,0,2,0,0}; - -DEFINE_TEST(test_read_format_cpio_svr4_gzip) -{ - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a)); - r = archive_read_support_compression_gzip(a); - if (r == ARCHIVE_WARN) { - skipping("gzip reading not fully supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - return; - } - assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualInt(ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), - ARCHIVE_COMPRESSION_GZIP); - assertEqualInt(archive_format(a), - ARCHIVE_FORMAT_CPIO_SVR4_NOCRC); - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4c_Z.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4c_Z.c deleted file mode 100644 index d3f086bbd51..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4c_Z.c +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_svr4c_Z.c 189381 2009-03-05 00:31:48Z kientzle $"); - -static unsigned char archive[] = { -31,157,144,'0','n',4,132,'!',3,6,140,26,'8','n',228,16,19,195,160,'A',26, -'1',202,144,'q','h','p','F',25,28,20,'a','X',196,152,145,' ',141,25,2,'k', -192,160,'A',163,163,201,135,29,'c',136,'<',201,'2','c','A',147,'.',0,12,20, -248,178,165,205,155,20,27,226,220,201,243,166,152,147,'T',164,4,'I',194,164, -136,148,16,'H',1,'(',']',202,180,169,211,167,'P',163,'J',157,'J',181,170, -213,171,'X',179,'j',221,202,181,171,215,175,'L',1}; - -DEFINE_TEST(test_read_format_cpio_svr4c_Z) -{ - struct archive_entry *ae; - struct archive *a; -/* printf("Archive address: start=%X, end=%X\n", archive, archive+sizeof(archive)); */ - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - failure("archive_compression_name(a)=\"%s\"", - archive_compression_name(a)); - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS); - failure("archive_format_name(a)=\"%s\"", archive_format_name(a)); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_CRC); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_empty.c b/archivers/libarchive/files/libarchive/test/test_read_format_empty.c deleted file mode 100644 index 98cfdfa26f5..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_empty.c +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_empty.c 189308 2009-03-03 17:02:51Z kientzle $"); - -static unsigned char archive[] = { 0 }; - -DEFINE_TEST(test_read_format_empty) -{ - struct archive_entry *ae; - struct archive *a; - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_memory(a, archive, 0)); - assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae)); - assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE); - assertA(archive_format(a) == ARCHIVE_FORMAT_EMPTY); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_gz.c b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_gz.c deleted file mode 100644 index 3071b1d0b49..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_gz.c +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_gz.c 191183 2009-04-17 01:06:31Z kientzle $"); - -static unsigned char archive[] = { -31,139,8,0,'+','e',217,'D',0,3,211,211,'g',160,'9','0',0,2,'s','S','S',16, -'m','h','n','j',128,'L',195,0,131,161,129,177,177,137,129,137,185,185,161, -'!',131,129,161,129,153,161,'9',131,130,')',237,157,198,192,'P','Z','\\', -146,'X',164,160,192,'P',146,153,139,'W',29,'!','y',152,'G','`',244,'(',24, -5,163,'`',20,12,'r',0,0,226,234,'6',162,0,6,0,0}; - -DEFINE_TEST(test_read_format_gtar_gz) -{ - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a)); - r = archive_read_support_compression_gzip(a); - if (r == ARCHIVE_WARN) { - skipping("gzip reading not fully supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - return; - } - assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualInt(ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), - ARCHIVE_COMPRESSION_GZIP); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR); - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c deleted file mode 100644 index d055fc249a7..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c +++ /dev/null @@ -1,318 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_sparse.c 189308 2009-03-03 17:02:51Z kientzle $"); - - -struct contents { - off_t o; - size_t s; - const char *d; -}; - -struct contents archive_contents_sparse[] = { - { 1000000, 1, "a" }, - { 2000000, 1, "a" }, - { 3145728, 0, NULL } -}; - -struct contents archive_contents_sparse2[] = { - { 1000000, 1, "a" }, - { 2000000, 1, "a" }, - { 3000000, 1, "a" }, - { 4000000, 1, "a" }, - { 5000000, 1, "a" }, - { 6000000, 1, "a" }, - { 7000000, 1, "a" }, - { 8000000, 1, "a" }, - { 9000000, 1, "a" }, - { 10000000, 1, "a" }, - { 11000000, 1, "a" }, - { 12000000, 1, "a" }, - { 13000000, 1, "a" }, - { 14000000, 1, "a" }, - { 15000000, 1, "a" }, - { 16000000, 1, "a" }, - { 17000000, 1, "a" }, - { 18000000, 1, "a" }, - { 19000000, 1, "a" }, - { 20000000, 1, "a" }, - { 21000000, 1, "a" }, - { 22000000, 1, "a" }, - { 23000000, 1, "a" }, - { 24000000, 1, "a" }, - { 25000000, 1, "a" }, - { 26000000, 1, "a" }, - { 27000000, 1, "a" }, - { 28000000, 1, "a" }, - { 29000000, 1, "a" }, - { 30000000, 1, "a" }, - { 31000000, 1, "a" }, - { 32000000, 1, "a" }, - { 33000000, 1, "a" }, - { 34000000, 1, "a" }, - { 35000000, 1, "a" }, - { 36000000, 1, "a" }, - { 37000000, 1, "a" }, - { 38000000, 1, "a" }, - { 39000000, 1, "a" }, - { 40000000, 1, "a" }, - { 41000000, 1, "a" }, - { 42000000, 1, "a" }, - { 43000000, 1, "a" }, - { 44000000, 1, "a" }, - { 45000000, 1, "a" }, - { 46000000, 1, "a" }, - { 47000000, 1, "a" }, - { 48000000, 1, "a" }, - { 49000000, 1, "a" }, - { 50000000, 1, "a" }, - { 51000000, 1, "a" }, - { 52000000, 1, "a" }, - { 53000000, 1, "a" }, - { 54000000, 1, "a" }, - { 55000000, 1, "a" }, - { 56000000, 1, "a" }, - { 57000000, 1, "a" }, - { 58000000, 1, "a" }, - { 59000000, 1, "a" }, - { 60000000, 1, "a" }, - { 61000000, 1, "a" }, - { 62000000, 1, "a" }, - { 63000000, 1, "a" }, - { 64000000, 1, "a" }, - { 65000000, 1, "a" }, - { 66000000, 1, "a" }, - { 67000000, 1, "a" }, - { 68000000, 1, "a" }, - { 69000000, 1, "a" }, - { 70000000, 1, "a" }, - { 71000000, 1, "a" }, - { 72000000, 1, "a" }, - { 73000000, 1, "a" }, - { 74000000, 1, "a" }, - { 75000000, 1, "a" }, - { 76000000, 1, "a" }, - { 77000000, 1, "a" }, - { 78000000, 1, "a" }, - { 79000000, 1, "a" }, - { 80000000, 1, "a" }, - { 81000000, 1, "a" }, - { 82000000, 1, "a" }, - { 83000000, 1, "a" }, - { 84000000, 1, "a" }, - { 85000000, 1, "a" }, - { 86000000, 1, "a" }, - { 87000000, 1, "a" }, - { 88000000, 1, "a" }, - { 89000000, 1, "a" }, - { 90000000, 1, "a" }, - { 91000000, 1, "a" }, - { 92000000, 1, "a" }, - { 93000000, 1, "a" }, - { 94000000, 1, "a" }, - { 95000000, 1, "a" }, - { 96000000, 1, "a" }, - { 97000000, 1, "a" }, - { 98000000, 1, "a" }, - { 99000000, 1, "a" }, - { 99000001, 0, NULL } -}; - -struct contents archive_contents_nonsparse[] = { - { 0, 1, "a" }, - { 1, 0, NULL } -}; - -/* - * Describe an archive with three entries: - * - * File 1: named "sparse" - * * a length of 3145728 bytes (3MiB) - * * a single 'a' byte at offset 1000000 - * * a single 'a' byte at offset 2000000 - * File 2: named "sparse2" - * * a single 'a' byte at offset 1,000,000, 2,000,000, ..., 99,000,000 - * * length of 99,000,001 - * File 3: named 'non-sparse' - * * length of 1 byte - * * contains a single byte 'a' - */ - -struct archive_contents { - const char *filename; - struct contents *contents; -} files[] = { - { "sparse", archive_contents_sparse }, - { "sparse2", archive_contents_sparse2 }, - { "non-sparse", archive_contents_nonsparse }, - { NULL, NULL } -}; - -static void -verify_archive_file(const char *name, struct archive_contents *ac) -{ - struct archive_entry *ae; - int err; - /* data, size, offset of next expected block. */ - struct contents expect; - /* data, size, offset of block read from archive. */ - struct contents actual; - const void *p; - struct archive *a; - - extract_reference_file(name); - - assert((a = archive_read_new()) != NULL); - assert(0 == archive_read_support_compression_all(a)); - assert(0 == archive_read_support_format_tar(a)); - failure("Can't open %s", name); - assert(0 == archive_read_open_filename(a, name, 3)); - - while (ac->filename != NULL) { - struct contents *cts = ac->contents; - - if (!assertEqualIntA(a, 0, archive_read_next_header(a, &ae))) { - assert(0 == archive_read_finish(a)); - return; - } - failure("Name mismatch in archive %s", name); - assertEqualString(ac->filename, archive_entry_pathname(ae)); - - expect = *cts++; - while (0 == (err = archive_read_data_block(a, - &p, &actual.s, &actual.o))) { - actual.d = p; - while (actual.s > 0) { - char c = *actual.d; - if(actual.o < expect.o) { - /* - * Any byte before the expected - * data must be NULL. - */ - failure("%s: pad at offset %d " - "should be zero", name, actual.o); - assertEqualInt(c, 0); - } else if (actual.o == expect.o) { - /* - * Data at matching offsets must match. - */ - assertEqualInt(c, *expect.d); - expect.d++; - expect.o++; - expect.s--; - /* End of expected? step to next expected. */ - if (expect.s <= 0) - expect = *cts++; - } else { - /* - * We found data beyond that expected. - */ - failure("%s: Unexpected trailing data", - name); - assert(actual.o <= expect.o); - archive_read_finish(a); - return; - } - actual.d++; - actual.o++; - actual.s--; - } - } - failure("%s: should be end of entry", name); - assertEqualIntA(a, err, ARCHIVE_EOF); - failure("%s: Size returned at EOF must be zero", name); - assertEqualInt((int)actual.s, 0); -#if ARCHIVE_VERSION_NUMBER < 1009000 - /* libarchive < 1.9 doesn't get this right */ - skipping("offset of final sparse chunk"); -#else - failure("%s: Offset of final empty chunk must be same as file size", name); - assertEqualInt(actual.o, expect.o); -#endif - /* Step to next file description. */ - ++ac; - } - - err = archive_read_next_header(a, &ae); - assertEqualIntA(a, ARCHIVE_EOF, err); - - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif -} - - -DEFINE_TEST(test_read_format_gtar_sparse) -{ - /* Two archives that use the "GNU tar sparse format". */ - verify_archive_file("test_read_format_gtar_sparse_1_13.tar", files); - verify_archive_file("test_read_format_gtar_sparse_1_17.tar", files); - - /* - * libarchive < 1.9 doesn't support the newer --posix sparse formats - * from GNU tar 1.15 and later. - */ -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("read support for GNUtar --posix sparse formats"); -#else - /* - * An archive created by GNU tar 1.17 using --posix --sparse-format=0.1 - */ - verify_archive_file( - "test_read_format_gtar_sparse_1_17_posix00.tar", - files); - /* - * An archive created by GNU tar 1.17 using --posix --sparse-format=0.1 - */ - verify_archive_file( - "test_read_format_gtar_sparse_1_17_posix01.tar", - files); - /* - * An archive created by GNU tar 1.17 using --posix --sparse-format=1.0 - */ - verify_archive_file( - "test_read_format_gtar_sparse_1_17_posix10.tar", - files); - /* - * The last test archive here is a little odd. First, it's - * uncompressed, because that exercises some of the block - * reassembly code a little harder. Second, it includes some - * leading comments prior to the sparse block description. - * GNU tar doesn't do this, but I think it should, so I want - * to ensure that libarchive correctly ignores such comments. - * Dump the file, looking for "#!gnu-sparse-format" starting - * at byte 0x600. - */ - verify_archive_file( - "test_read_format_gtar_sparse_1_17_posix10_modified.tar", - files); -#endif -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_13.tgz.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_13.tgz.uu deleted file mode 100644 index a298e59fa08..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_13.tgz.uu +++ /dev/null @@ -1,26 +0,0 @@ -begin 644 test_read_format_gtar_sparse_1_13.tgz -M'XL(`&&";$<``^W72VX;1Q2%X<Y.N($`=>NYD*Q``P\\L&.(\OYSNP/)LGE` -M!SDF.D#^SP,G94&\7?VS']<O3\_7#]M#E2AE]KZ54F*-\O[O7<W_W:*LUJ)$ -M]%R/M>;:+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+./=XIYHS<M2KF -MS#UH4\R9:=<JYHS\S"GFC-I6$W-&77D^Q?H>A9JSK;INJW@[_]%;-#5OG_D8 -M+M9'G4W-.XZCOEV?M:FZ8\ZJZCXB5ON:AUW$G#4_N8LY:\F*Q)PUH@XQ9\WO -MB.HWFUBJWUHS8+'?Q]=)S9FG)]2</0]`S9F;4-6<?<VIYAQMJ'[K6.VVWV_G -M/\]F51T?7W\U[]K_J/5Y',:/ZRTG;F+>5F;^(K$>^]5?K8]UV_%^.8JI^CTN -M4V+.O,VTKN;,[2MJSHRWJSE[7@75G"/#4W/NJVK.F1LD]OGU<GJ[OM90<^9I -M#C5G[MJX<_[[OB-BWOSRA.JX9_2JXYY?:-7Q<?D7\_8,;XIY>^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'^$]W<XZ`<.^H&#?N"@'SCH -M!PZW'_J#@W[@H!\XZ`<.^H&#?N"@'SAX_\>9Z`<.^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^<B7[@H!\X -MZ`<.^H&#?N"@'SAX_\>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]</C/J-$*;/WK902:Y3W?[_:HJS6 -MHD3TR)^/&F6[E,>-],W7Z\O3\^6RO7S\=/?G?O;O`````````/`?\Q>.)E`. -$`/`````` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17.tgz.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17.tgz.uu deleted file mode 100644 index 3f3127124a1..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17.tgz.uu +++ /dev/null @@ -1,26 +0,0 @@ -begin 644 test_read_format_gtar_sparse_1_17.tgz -M'XL(`&&";$<``^W776X3611%83,33Z"E>^[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<M1Q<Q3;^IBAYIS1AYISCA9JSA4QBUK/S19SYL.<8L[(7:MBSMR# -M-L6<F7:M8L[(YYQBSJAM-3%GU)7G4ZQO4:@YVZKKMHK7\Q^]15/S]KF6FG?4 -MV=2\8S_JV_59FZH[YJRJ[CUBM:]YV$7,6?.9NYBSEJQ(S%DCZA!SUGR-J'ZS -MB:7ZK34#%ON]OYS4G'EZ0LW9\P#4G+D)5<W9UYQJSM&&ZK>.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^<T-6^&J3X7C#S1JN.\:'?5 -M<9Z&ICK>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^<HJS6HD3T -M..7?M:S3N3QNI.^^7)\O3^?SZ?G#Q[L_][/O`P````````#P/_(W91GI)`#P -"```` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tgz.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tgz.uu deleted file mode 100644 index 41038960bc9..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tgz.uu +++ /dev/null @@ -1,29 +0,0 @@ -begin 644 test_read_format_gtar_sparse_1_17_posix00.tgz -M'XL(`&*";$<``^W9S6[;1A2&8:UU%;Z!RO/#^5MHW:R*;'H!K,,`06L[$&7` -M[=5W%#FN'(Q-Z1S5K-#W642!E&/3/M\$'\'5]<?^\</0?QHVX\KG&,KU^+7? -MC,/B?$P5NV[W:E,PAZ_?=,8MK$G>6V-MYQ;&^BZ9Q=7C&:_A50_CMM_42]%^ -MG:>?Y?GU0KAT]?,OOZ[V.U^-7_X:UMYV(;F\=/'PH[N'V]_^N+_Y?5S[I<N' -MG]Q__CP.VW6I?%R^_(*[J3^WP[@.UBU=:8S9.I:3.WGN^2I#<\XLG;GJMU]N -MA[6U);MZ:<;NWKMY^9Y9SKV!>9W]L#=,G'^W.R[_G/_ZOK7)U?/_+H?H^_FO -ML7CSWTU]?J'G7ZN?^P)PT<C/O%:O]3]WON_Q]O__UEN??NQ_(7KZWWMX6>6^ -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<LW6,1[M$9X1Z=%>[1.>$>72?<H^N$>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': -M<X*TYP1ISPG2GA.D/2=(>TZ0]IP@[3E1VG.BM.=$:<^)TIX3I3TG2GM.E/:< -M*.TY4=ISHK3G)&G/2=*>DZ0])TE[3I+VG"3M.4G:<Y*TYR1IS\G2GI.E/2=+ -M>TZ6]IPL[3E9VG.RM.=D:<_)TIZ3I3TG2WM.D?:<(NTY1=ISBK3G%&G/*=*> -M4Z0]ITA[3IGH.;;XQL-UUWBX;O_G#]<OP'ZY9WS8T_#F\Q_;.6_LP?,?NS#6 -MU;=Y_G\)>'X+#?(##?(##?(##?(##?(##6U^R!\TR`\TR`\TR`\TR`\TR`\T -MR`\TN/_'G,@/-,@/-,@/-,@/-,@/-,@/-+C_QYS(#S3(#S3(#S3(#S3(#S3( -M#S2X_\><R`\TR`\TR`\TR`\TR`\TR`\TN/_'G,@/-,@/-,@/-,@/-,@/-,@/ -M-+C_QYS(#S3(#S3(#S3(#S3(#S3(#S2X_\><R`\TR`\TR`\TR`\TR`\TR`\T -MN/_'G,@/-,@/-,@/-,@/-,@/-,@/-+C_QYS(#S3(#S3(#S3(#S3(#S3(#S2X -M_\><R`\TR`\TR`\TR`\TR`\TR`\TN/_'G,@/-,@/-,@/-,@/-,@/-,@/-+C_ -MQYS(#S3(#S3(C\[J^F/_^&'H/PV;<>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/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tgz.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tgz.uu deleted file mode 100644 index 6d7963ed4f9..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tgz.uu +++ /dev/null @@ -1,27 +0,0 @@ -begin 644 test_read_format_gtar_sparse_1_17_posix01.tgz -M'XL(`&*";$<``^W7WVX:1QB&<8ZY"B[`Q?/-OYT]X+3-416IZ@5L'0ZLQHX% -MMF3UZKN`';]V&SO21[PB>GXG;,#F`_,,F5F>?QSN/ZR'3^O-=IE:K7:^O1DV -MV_7L>,*HYKR[M:X$O=V+)<XL="E9,,MQ%BSEFF>+^R.^AF^ZV]X.F_&E>)_G -MX;U\O3T1L5O\]ON?R\-GOMQ>_K->)<NEBVT>JSYT?7?UU^<O%W]O5^GE(\/5 -M>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,YO<R)0>9$DSDQRIR894[,,B<6_7M5F1,[G=-T3B]S4I`Y*<J<%&5.2KHY -MS_K!%)F3JLQ)G<YI,N?A[82'?\B<K)]_U@#RLP(T@:P-9(T@:P59,\C:0=$. -MBG90M(.B'13MH&@'13LHVD'1#HIV4+6#JAU4[:!J!U4[J-I!U0ZJ=E"U@ZH= -M=-I!IQUTVD&G'73:0:<==-I!IQUTVD'3#IIVT+2#IATT[:!I!TT[:,^^#)Y] -M&V@'33OHM8->.^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<?W'$KK9XET6T>/Z'X-_ -9]>?>>OQ$US\``````/CY_0O4#S!&`/`````` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tgz.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tgz.uu deleted file mode 100644 index c74c08fb3ed..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tgz.uu +++ /dev/null @@ -1,27 +0,0 @@ -begin 644 test_read_format_gtar_sparse_1_17_posix10.tgz -M'XL(`&.";$<``^W7RV[;5A1&88WU%'J!RN=^&7B:9E0$*/H`1,*!B]@))`<P -M\O2A)#O];=@RBJV8$+*^"1G*T=9E'8%G??%AN'L_#I_&S78=6RGQ8OMUV&S' -MQ>FX24EI=_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-^_.'M<NJQ!'#W"\`9XU^YK5^Z?X_G&[&Z_?_]>G]?\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/\^[<'_YOF<ZGG^W]>3M\ -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<??_D#E)O_^D`:1'!6@"21M(&D'2"I)FD+2#K!UD[2!K!UD[R-I!U@ZR=I"U -M@ZP=9.V@:`=%.RC:0=$.BG90M(.B'13MH&@'13NHVD'5#JIV4+6#JAU4[:!J -M!U4[J-I!TPZ:=M"T@Z8=-.V@:0=-.VB/?@P>_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_\><Z`<6]`,+^H$%_<""?F!!/[!@_X\YT0\LZ`<6]`,+^H$%_<""?F#! -M_A]SHA]8T`\LZ`<6]`,+^H$%_<""_3_F1#^PH!]8T`\LZ`<6]`,+^H$%^W_, -MB7Y@03^PH!^;]<6'X>[].'P:-]MU;*7$BYLO-W]LOPZ;[7BB&6Y24MH=?<U. -MCP?3N7<U1N^\3W'A?`HY+E9W)YI_U+?M[;"97HKU>>[?RL_CF0AN-=Q>78^7 -MWO<6>BS.+Z=K'Y]>F_MUXM<X^6)_QJOKW^GZ]]/Z#]G5Q>I-%M'#^I^"/_IW -5KSU^INL?````P._C!\JB`&$`\``` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu deleted file mode 100644 index a9120a21af2..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu +++ /dev/null @@ -1,1370 +0,0 @@ -$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu,v 1.2 2008/07/03 03:26:30 peter Exp $ -begin 644 test_read_format_gtar_sparse_1_17_posix10_modified.tar -M+B]087A(96%D97)S+C,X-C8S+W-P87)S90`````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,C$U -M`#$P-S,S,3`Q,30S`#`Q,S0V-@`@>``````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````!U<W1A<@`P,``````` -M```````````````````````````````````````````````````````````` -M```````````````````P,#`P,#`P`#`P,#`P,#`````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````R,B!'3E4N<W!A<G-E+FUA:F]R/3$*,C(@1TY5 -M+G-P87)S92YM:6YO<CTP"C(V($=.52YS<&%R<V4N;F%M93US<&%R<V4*,S$@ -M1TY5+G-P87)S92YR96%L<VEZ93TS,30U-S(X"C(P(&%T:6UE/3$Q.3@R.3,V -M,#(*,C`@8W1I;64],3$Y.#(Y,S8P,`H````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````````"XO1TY54W!A<G-E -M1FEL92XS.#8V,R]S<&%R<V4````````````````````````````````````` -M```````````````````````````````````````````````````````````P -M,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,S`P,``Q,#<S,S$P,3$T -M,``P,34Q-34`(#`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````=7-T87(`,#!T:6T````````````````` -M`````````````````````'1I;0`````````````````````````````````` -M````,#`P,#`P,``P,#`P,#`P```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````(R%G;G4M<W!A<G-E+69O<FUA=`HC9F]R;6%T.C$N,`HS"CDY.3DS -M-@HU,3(*,3DY.3@W,@HU,3(*,S$T-3<R.`HP"@`````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````80`` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````80`````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````+B]087A(96%D97)S+C,X-C8S+W-P87)S93(````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P -M`#`P,#`P,#`P,C$W`#$P-S,S,3`Q,30S`#`Q,S4U,@`@>``````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````````!U -M<W1A<@`P,``````````````````````````````````````````````````` -M```````````````````````````````````P,#`P,#`P`#`P,#`P,#`````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````R,B!'3E4N<W!A<G-E+FUA -M:F]R/3$*,C(@1TY5+G-P87)S92YM:6YO<CTP"C(W($=.52YS<&%R<V4N;F%M -M93US<&%R<V4R"C,R($=.52YS<&%R<V4N<F5A;'-I>F4].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<G-E1FEL92XS.#8V,R]S<&%R<V4R```````````````````` -M```````````````````````````````````````````````````````````` -M```````````````P,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#$T-3,P -M,0`Q,#<S,S$P,3$T,0`P,34R-3,`(#`````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````=7-T87(`,#!T:6T` -M`````````````````````````````````````'1I;0`````````````````` -M````````````````````,#`P,#`P,``P,#`P,#`P```````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````.3D*.3DY.3,V"C4Q,@HQ.3DY.#<R"C4Q,@HR -M.3DY.#`X"C4Q,@HS.3DY-S0T"C4Q,@HT.3DY-C@P"C4Q,@HU.3DY-C$V"C4Q -M,@HV.3DY-34R"C4Q,@HX,#`P,#`P"C4Q,@HX.3DY.3,V"C4Q,@HY.3DY.#<R -M"C4Q,@HQ,#DY.3@P.`HU,3(*,3$Y.3DW-#0*-3$R"C$R.3DY-C@P"C4Q,@HQ -M,SDY.38Q-@HU,3(*,30Y.3DU-3(*-3$R"C$V,#`P,#`P"C4Q,@HQ-CDY.3DS -M-@HU,3(*,3<Y.3DX-S(*-3$R"C$X.3DY.#`X"C4Q,@HQ.3DY.3<T-`HU,3(* -M,C`Y.3DV.#`*-3$R"C(Q.3DY-C$V"C4Q,@HR,CDY.34U,@HU,3(*,C0P,#`P -M,#`*-3$R"C(T.3DY.3,V"C4Q,@HR-3DY.3@W,@HU,3(*,C8Y.3DX,#@*-3$R -M"C(W.3DY-S0T"C4Q,@HR.#DY.38X,`HU,3(*,CDY.3DV,38*-3$R"C,P.3DY -M-34R"C4Q,@HS,C`P,#`P,`HU,3(*,S(Y.3DY,S8*-3$R"C,S.3DY.#<R"C4Q -M,@HS-#DY.3@P.`HU,3(*,S4Y.3DW-#0*-3$R"C,V.3DY-C@P"C4Q,@HS-SDY -M.38Q-@HU,3(*,S@Y.3DU-3(*-3$R"C0P,#`P,#`P"C4Q,@HT,#DY.3DS-@HU -M,3(*-#$Y.3DX-S(*-3$R"C0R.3DY.#`X"C4Q,@HT,SDY.3<T-`HU,3(*-#0Y -M.3DV.#`*-3$R"C0U.3DY-C$V"C4Q,@HT-CDY.34U,@HU,3(*-#@P,#`P,#`* -M-3$R"C0X.3DY.3,V"C4Q,@HT.3DY.3@W,@HU,3(*-3`Y.3DX,#@*-3$R"C4Q -M.3DY-S0T"C4Q,@HU,CDY.38X,`HU,3(*-3,Y.3DV,38*-3$R"C4T.3DY-34R -M"C4Q,@HU-C`P,#`P,`HU,3(*-38Y.3DY,S8*-3$R"C4W.3DY.#<R"C4Q,@HU -M.#DY.3@P.`HU,3(*-3DY.3DW-#0*-3$R"C8P.3DY-C@P"C4Q,@HV,3DY.38Q -M-@HU,3(*-C(Y.3DU-3(*-3$R"C8T,#`P,#`P"C4Q,@HV-#DY.3DS-@HU,3(* -M-C4Y.3DX-S(*-3$R"C8V.3DY.#`X"C4Q,@HV-SDY.3<T-`HU,3(*-C@Y.3DV -M.#`*-3$R"C8Y.3DY-C$V"C4Q,@HW,#DY.34U,@HU,3(*-S(P,#`P,#`*-3$R -M"C<R.3DY.3,V"C4Q,@HW,SDY.3@W,@HU,3(*-S0Y.3DX,#@*-3$R"C<U.3DY -M-S0T"C4Q,@HW-CDY.38X,`HU,3(*-S<Y.3DV,38*-3$R"C<X.3DY-34R"C4Q -M,@HX,#`P,#`P,`HU,3(*.#`Y.3DY,S8*-3$R"C@Q.3DY.#<R"C4Q,@HX,CDY -M.3@P.`HU,3(*.#,Y.3DW-#0*-3$R"C@T.3DY-C@P"C4Q,@HX-3DY.38Q-@HU -M,3(*.#8Y.3DU-3(*-3$R"C@X,#`P,#`P"C4Q,@HX.#DY.3DS-@HU,3(*.#DY -M.3DX-S(*-3$R"CDP.3DY.#`X"C4Q,@HY,3DY.3<T-`HU,3(*.3(Y.3DV.#`* -M-3$R"CDS.3DY-C$V"C4Q,@HY-#DY.34U,@HU,3(*.38P,#`P,#`*-3$R"CDV -M.3DY.3,V"C4Q,@HY-SDY.3@W,@HU,3(*.3@Y.3DX,#@*,3DS"@`````````` -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``````````!A```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````````!A -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````!A```````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````!A```````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````!A```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````!A```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````````!A -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````!A```````````` -M```````````````````````````````````````````````````````````` -M````````````80`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M80`````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````80`````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````80`````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````80`````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````80`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M80`````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````80`````````` -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``````````````!A```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``!A```````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````!A```````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````!A```````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````!A```````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````!A```````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``!A```````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````!A```````` -M```````````````````````````````````````````````````````````` -M````````````````80`````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````80`````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````80`````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````80`````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````80`````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````80`````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````80`````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````80`````` -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``````````````````!A```````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````!A```````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````!A```` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````!A```````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````!A```````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````!A```````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````!A```````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````!A```` -M```````````````````````````````````````````````````````````` -M````````````````````80`````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````80`````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````80`` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````80`````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````80`````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````80`````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````80`````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````````````80`` -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``````````````````````!A```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````!A```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````````!A -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````!A```````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````!A```````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````!A```````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````!A```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````````````````````!A -M```````````````````````````````````````````````````````````` -M````````````````````````80`````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````80`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M80`````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````````````````80`````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````````````````80`````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````80`````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````80`````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M80`````````````````````````````````````````````````````````` -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````````````````````````````````````````````````````````+B]0 -M87A(96%D97)S+C,X-C8S+VYO;BUS<&%R<V4````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#4P`#$P -M-S,S,3`Q,30S`#`Q-#(U,P`@>``````````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````!U<W1A<@`P,``````````` -M```````````````````````````````````````````````````````````` -M```````````````P,#`P,#`P`#`P,#`P,#`````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````R,"!A=&EM93TQ,3DX,CDS-C`Q"C(P(&-T:6UE/3$Q -M.3@R.3,V,#$*```````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````````````````````````````````&YO;BUS<&%R<V4````` -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````P,#`P -M-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,#`P,``Q,#<S,S$P,3$T,0`P -M,3(U,#<`(#`````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M````````````````````````=7-T87(`,#!T:6T````````````````````` -M`````````````````'1I;0`````````````````````````````````````` -M,#`P,#`P,``P,#`P,#`P```````````````````````````````````````` -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```````````````````````````````````````````````````````````` -/```````````````````` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c b/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c deleted file mode 100644 index 822b969e335..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_iso_gz.c 201247 2009-12-30 05:59:21Z kientzle $"); - -DEFINE_TEST(test_read_format_iso_gz) -{ - struct archive_entry *ae; - struct archive *a; - const char *name = "test_read_format_iso.iso.Z"; - - extract_reference_file(name); - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_filename(a, name, 512)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), - ARCHIVE_COMPRESSION_COMPRESS); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c deleted file mode 100644 index cb5a969d621..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c +++ /dev/null @@ -1,203 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_isorr_bz2.c 201247 2009-12-30 05:59:21Z kientzle $"); - -/* -PLEASE use old cdrtools; mkisofs verion is 2.01. -This version mkisofs made wrong "SL" System Use Entry of RRIP. - -Execute the following command to rebuild the data for this program: - tail -n +34 test_read_format_isorr_bz2.c | /bin/sh - -rm -rf /tmp/iso -mkdir /tmp/iso -mkdir /tmp/iso/dir -echo "hello" >/tmp/iso/file -dd if=/dev/zero count=1 bs=12345678 >>/tmp/iso/file -ln /tmp/iso/file /tmp/iso/hardlink -(cd /tmp/iso; ln -s file symlink) -(cd /tmp/iso; ln -s /tmp/ symlink2) -(cd /tmp/iso; ln -s /tmp/../ symlink3) -(cd /tmp/iso; ln -s .././../tmp/ symlink4) -(cd /tmp/iso; ln -s .///file symlink5) -(cd /tmp/iso; ln -s /tmp//../ symlink6) -TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir -TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink /tmp/iso/symlink5 -F=test_read_format_iso_rockridge.iso.Z -mkhybrid -R -uid 1 -gid 2 /tmp/iso | compress > $F -uuencode $F $F > $F.uu -exit 1 - */ - -DEFINE_TEST(test_read_format_isorr_bz2) -{ - const char *refname = "test_read_format_iso_rockridge.iso.Z"; - struct archive_entry *ae; - struct archive *a; - const void *p; - size_t size; - off_t offset; - int i; - - extract_reference_file(refname); - assert((a = archive_read_new()) != NULL); - assertEqualInt(0, archive_read_support_compression_all(a)); - assertEqualInt(0, archive_read_support_format_all(a)); - assertEqualInt(ARCHIVE_OK, - archive_read_open_filename(a, refname, 10240)); - - /* Retrieve each of the 8 files on the ISO image and - * verify that each one is what we expect. */ - for (i = 0; i < 10; ++i) { - assertEqualInt(0, archive_read_next_header(a, &ae)); - - if (strcmp(".", archive_entry_pathname(ae)) == 0) { - /* '.' root directory. */ - assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); - assertEqualInt(2048, archive_entry_size(ae)); - /* Now, we read timestamp recorded by RRIP "TF". */ - assertEqualInt(86401, archive_entry_mtime(ae)); - assertEqualInt(0, archive_entry_mtime_nsec(ae)); - /* Now, we read links recorded by RRIP "PX". */ - assertEqualInt(3, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualIntA(a, ARCHIVE_EOF, - archive_read_data_block(a, &p, &size, &offset)); - assertEqualInt((int)size, 0); - } else if (strcmp("dir", archive_entry_pathname(ae)) == 0) { - /* A directory. */ - assertEqualString("dir", archive_entry_pathname(ae)); - assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); - assertEqualInt(2048, archive_entry_size(ae)); - assertEqualInt(86401, archive_entry_mtime(ae)); - assertEqualInt(86401, archive_entry_atime(ae)); - assertEqualInt(2, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else if (strcmp("hardlink", archive_entry_pathname(ae)) == 0) { - /* A regular file. */ - assertEqualString("hardlink", archive_entry_pathname(ae)); - assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); - assertEqualInt(12345684, archive_entry_size(ae)); - assertEqualInt(0, - archive_read_data_block(a, &p, &size, &offset)); - assertEqualInt(0, offset); - assertEqualMem(p, "hello\n", 6); - assertEqualInt(86401, archive_entry_mtime(ae)); - assertEqualInt(86401, archive_entry_atime(ae)); - assertEqualInt(2, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else if (strcmp("file", archive_entry_pathname(ae)) == 0) { - /* A hardlink to the regular file. */ - /* Note: If "hardlink" gets returned before "file", - * then "hardlink" will get returned as a regular file - * and "file" will get returned as the hardlink. - * This test should tolerate that, since it's a - * perfectly permissible thing for libarchive to do. */ - assertEqualString("file", archive_entry_pathname(ae)); - assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); - assertEqualString("hardlink", archive_entry_hardlink(ae)); - assertEqualInt(0, archive_entry_size_is_set(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualInt(86401, archive_entry_mtime(ae)); - assertEqualInt(86401, archive_entry_atime(ae)); - assertEqualInt(2, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else if (strcmp("symlink", archive_entry_pathname(ae)) == 0) { - /* A symlink to the regular file. */ - assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); - assertEqualString("file", archive_entry_symlink(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualInt(172802, archive_entry_mtime(ae)); - assertEqualInt(172802, archive_entry_atime(ae)); - assertEqualInt(1, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else if (strcmp("symlink2", archive_entry_pathname(ae)) == 0) { - /* A symlink to /tmp (an absolute path) */ - assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); - assertEqualString("/tmp", archive_entry_symlink(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualInt(1, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else if (strcmp("symlink3", archive_entry_pathname(ae)) == 0) { - /* A symlink to /tmp/.. (with a ".." component) */ - assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); - assertEqualString("/tmp/..", archive_entry_symlink(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualInt(1, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else if (strcmp("symlink4", archive_entry_pathname(ae)) == 0) { - /* A symlink to a path with ".." and "." components */ - assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); - assertEqualString(".././../tmp", - archive_entry_symlink(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualInt(1, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else if (strcmp("symlink5", archive_entry_pathname(ae)) == 0) { - /* A symlink to the regular file with "/" components. */ - assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); - assertEqualString(".///file", archive_entry_symlink(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualInt(172802, archive_entry_mtime(ae)); - assertEqualInt(172802, archive_entry_atime(ae)); - assertEqualInt(1, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else if (strcmp("symlink6", archive_entry_pathname(ae)) == 0) { - /* A symlink to /tmp//.. - * (with "/" and ".." components) */ - assertEqualInt(AE_IFLNK, archive_entry_filetype(ae)); - assertEqualString("/tmp//..", archive_entry_symlink(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualInt(1, archive_entry_stat(ae)->st_nlink); - assertEqualInt(1, archive_entry_uid(ae)); - assertEqualInt(2, archive_entry_gid(ae)); - } else { - failure("Saw a file that shouldn't have been there"); - assertEqualString(archive_entry_pathname(ae), ""); - } - } - - /* End of archive. */ - assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); - - /* Verify archive format. */ - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE); - - /* Close the archive. */ - assertEqualInt(0, archive_read_close(a)); - assertEqualInt(0, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu deleted file mode 100644 index 3f0cfca5021..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu +++ /dev/null @@ -1,22 +0,0 @@ -begin 644 test_read_format_isorr_bz2.iso.bz2 -M0EIH.3%!629361M#:2D``,?_W?__6_Y58_GX/__?X*?OWB8AZB0`,`$@`$0" -M@0C``QP`U:!,&J>FJ>2:CR)^I'ZB#3U/4-`!H:#(:``]0P@`!H9!D!II-$,A -M&BGFJ>34]0T!IHT&AHT:#0:``!ZC$`#0T.`!H&@&AH``!IB&C30```!H9``! -MA(D0DTQ3T3$TVA-!IIZAA-'J:!H!H#0:#30:#30T;1*PHGAZ"/F;E""L"I6" -M8W&#'./D%S=_T4T96&+@94X&AL;:`Y+0C?:%=B#:8`:PP`2WF"20!EXL)6=] -M8=A)!0Q)($C&$U#8AI(&QL2!"10P4^8D$"0,8$I-.!3R8YWZ]Q1./IDR^VYN -MRJ&76*,$3PG?U(,=C;I20`D<&9/%5ILJIGI0(SWP3KRID6=#1MV*A>)(*B0$ -M$E:><!0D%K$G(WM("\:="00+`OCJ`Y0K(4B%(:1`#1-.%*`S0+)N`I4'MID+ -M$8MAN[,\.QJ`I=ZDA(5<O`KS[(+3L4-$,@&#*7!<`@AO7Y8*E9S#7L>B944( -MO-&.8&:1K;>[K$?O7R-FWA;%5+E]WBV<T&*%[O-6_,_/]:YC;<A-%^UFF09U -MP`*D@;&4KUHN&1:F_D1:YM:J-EG8L%<+BF4W%"6TU:I68MIJ6"FVH>T9PR7J -MNU2C2G2>5**"XH4HD`PF+(*DTT&47'A+)B";NS-UH>(]7G^\/G_343KU\17< -M<*""-SM"%>BVIJL8SF]7L-1.-LSRP2%=KX&C56*FC&#C$XNMGL)]3X&^$V4Z -MY`()G`%`KUR!HU8Z'"HWNE&P6MI:KZ<F%H/X3DN/F&%#`.%8#!HTK295C.#[ -M+^4C&90I^(::@`Y$=<OX=S3?,A#ZU'\'^+PYHV2PK?Q-,&8/Q$A3@$*X*=$A -MK;I2)&A^MSZ`*](@"[>^Q"H0L7.OV8ZJW409[QO=`&&D%=5&@RP`MO%R/J#Q -M-KJ*6D;EH7:DK0.48@8HF*IP(>*YMR$>!+A,)X+;`$94@@?U]B/=2T0CY-2= -M*_1FPF<-G\\@Z-_,Q>06='5:(B#3`W$8Y!:C-CE22SM9*S$00,XXJTIZ!GA( -LGTMN:F\J-,D9>?.38*!I7T>--*B_=T44HJ?#@``"1;7#_Q=R13A0D!M#:2D` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c b/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c deleted file mode 100644 index ce6e92086dc..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_mtree.c 201247 2009-12-30 05:59:21Z kientzle $"); - -static void -test_read_format_mtree1(void) -{ - const char reffile[] = "test_read_format_mtree.mtree"; - char buff[16]; - struct archive_entry *ae; - struct archive *a; - FILE *f; - - extract_reference_file(reffile); - - /* - * An access error occurred on some platform when mtree - * format handling open a directory. It is for through - * the routine which open a directory that we create - * "dir" and "dir2" directories. - */ - assertMakeDir("dir", 0775); - assertMakeDir("dir2", 0775); - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_file(a, reffile, 11)); - - /* - * Read "file", whose data is available on disk. - */ - f = fopen("file", "wb"); - assert(f != NULL); - assertEqualInt(3, fwrite("hi\n", 1, 3, f)); - fclose(f); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE); - assertEqualString(archive_entry_pathname(ae), "file"); - assertEqualInt(archive_entry_uid(ae), 18); - assertEqualInt(AE_IFREG, archive_entry_filetype(ae)); - assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0123); - assertEqualInt(archive_entry_size(ae), 3); - assertEqualInt(3, archive_read_data(a, buff, 3)); - assertEqualMem(buff, "hi\n", 3); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir"); - assertEqualInt(AE_IFDIR, archive_entry_filetype(ae)); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir/file with space"); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "file with space"); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir2"); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir2/dir3a"); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir2/dir3a/indir3a"); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir2/fullindir2"); - assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir2/indir2"); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir2/dir3b"); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "dir2/dir3b/indir3b"); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString(archive_entry_pathname(ae), "notindir"); - - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - -static void -test_read_format_mtree2(void) -{ - static char archive[] = - "#mtree\n" - "d type=dir content=.\n"; - struct archive_entry *ae; - struct archive *a; - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE); - assertEqualString(archive_entry_pathname(ae), "d"); - assertEqualInt(archive_entry_filetype(ae), AE_IFDIR); - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - - -DEFINE_TEST(test_read_format_mtree) -{ - test_read_format_mtree1(); - test_read_format_mtree2(); -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_pax_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_pax_bz2.c deleted file mode 100644 index af70b366308..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_pax_bz2.c +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_pax_bz2.c 201247 2009-12-30 05:59:21Z kientzle $"); - -static unsigned char archive[] = { -'B','Z','h','9','1','A','Y','&','S','Y',152,180,30,185,0,0,140,127,176,212, -144,0,' ','@',1,255,226,8,'d','H',' ',238,'/',159,'@',0,16,4,'@',0,8,'0', -0,216,'A',164,167,147,'Q',147,'!',180,'#',0,'L',153,162,'i',181,'?','P',192, -26,'h','h',209,136,200,6,128,13,12,18,132,202,'5','O',209,'5','=',26,'2', -154,7,168,12,2,'d',252,13,254,29,'4',247,181,'l','T','i',130,5,195,1,'2', -'@',146,18,251,245,'c','J',130,224,172,'$','l','4',235,170,186,'c','1',255, -179,'K',188,136,18,208,152,192,149,153,10,'{','|','0','8',166,3,6,9,128,172, -'(',164,220,244,149,6,' ',243,212,'B',25,17,'6',237,13,'I',152,'L',129,209, -'G','J','<',137,'Y',16,'b',21,18,'a','Y','l','t','r',160,128,147,'l','f', -'~',219,206,'=','?','S',233,'3',251,'L','~',17,176,169,'%',23,'_',225,'M', -'C','u','k',218,8,'q',216,'(',22,235,'K',131,136,146,136,147,202,0,158,134, -'F',23,160,184,'s','0','a',246,'*','P',7,2,238,'H',167,10,18,19,22,131,215, -' '}; - -DEFINE_TEST(test_read_format_pax_bz2) -{ - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - r = archive_read_support_compression_bzip2(a); - if (r != ARCHIVE_OK) { - archive_read_close(a); - skipping("Bzip2 unavailable"); - return; - } - assertEqualIntA(a,ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a,ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a,ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE); - assertEqualIntA(a,ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tar.c b/archivers/libarchive/files/libarchive/test/test_read_format_tar.c deleted file mode 100644 index 9c197df0946..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_tar.c +++ /dev/null @@ -1,480 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tar.c 201247 2009-12-30 05:59:21Z kientzle $"); - -/* - * Each of these archives is a short archive with a single entry. The - * corresponding verify function verifies the entry structure returned - * from libarchive is what it should be. The support functions pad with - * lots of zeros, so we can trim trailing zero bytes from each hardcoded - * archive to save space. - * - * The naming here follows the tar file type flags. E.g. '1' is a hardlink, - * '2' is a symlink, '5' is a dir, etc. - */ - -/* Empty archive. */ -static unsigned char archiveEmpty[] = { - /* 512 zero bytes */ - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 -}; - -static void verifyEmpty(void) -{ - struct archive_entry *ae; - struct archive *a; - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_memory(a, archiveEmpty, 512)); - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE); - assertEqualString(archive_compression_name(a), "none"); - failure("512 zero bytes should be recognized as a tar archive."); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR); - - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif -} - -/* Single entry with a hardlink. */ -static unsigned char archive1[] = { -'h','a','r','d','l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0', -'0','6','4','4',' ',0,'0','0','1','7','5','0',' ',0,'0','0','1','7','5','0', -' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4','6', -'0','5','2','6','6','2',' ','0','1','3','0','5','7',0,' ','1','f','i','l', -'e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,'0', -'0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', -'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' '}; - -static void verify1(struct archive_entry *ae) -{ - /* A hardlink is not a symlink. */ - assert(archive_entry_filetype(ae) != AE_IFLNK); - /* Nor is it a directory. */ - assert(archive_entry_filetype(ae) != AE_IFDIR); - assertEqualInt(archive_entry_mode(ae) & 0777, 0644); - assertEqualInt(archive_entry_uid(ae), 1000); - assertEqualInt(archive_entry_gid(ae), 1000); - assertEqualString(archive_entry_uname(ae), "tim"); - assertEqualString(archive_entry_gname(ae), "tim"); - assertEqualString(archive_entry_pathname(ae), "hardlink"); - assertEqualString(archive_entry_hardlink(ae), "file"); - assert(archive_entry_symlink(ae) == NULL); - assertEqualInt(archive_entry_mtime(ae), 1184388530); -} - -/* Verify that symlinks are read correctly. */ -static unsigned char archive2[] = { -'s','y','m','l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0', -'0','0','7','5','5',' ','0','0','0','1','7','5','0',' ','0','0','0','1','7', -'5','0',' ','0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4', -'6','0','5','4','1','0','1',' ','0','0','1','3','3','2','3',' ','2','f','i', -'l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0, -'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -'0','0','0','0','0','0','0',' ','0','0','0','0','0','0','0',' '}; - -static void verify2(struct archive_entry *ae) -{ - assertEqualInt(archive_entry_filetype(ae), AE_IFLNK); - assertEqualInt(archive_entry_mode(ae) & 0777, 0755); - assertEqualInt(archive_entry_uid(ae), 1000); - assertEqualInt(archive_entry_gid(ae), 1000); - assertEqualString(archive_entry_uname(ae), "tim"); - assertEqualString(archive_entry_gname(ae), "tim"); - assertEqualString(archive_entry_pathname(ae), "symlink"); - assertEqualString(archive_entry_symlink(ae), "file"); - assert(archive_entry_hardlink(ae) == NULL); - assertEqualInt(archive_entry_mtime(ae), 1184389185); -} - -/* Character device node. */ -static unsigned char archive3[] = { -'d','e','v','c','h','a','r',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0', -'0','0','7','5','5',' ','0','0','0','1','7','5','0',' ','0','0','0','1','7', -'5','0',' ','0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4', -'6','0','5','4','1','0','1',' ','0','0','1','2','4','1','2',' ','3',0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0, -'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -'0','0','0','0','0','0','0',' ','0','0','0','0','0','0','0',' '}; - -static void verify3(struct archive_entry *ae) -{ - assertEqualInt(archive_entry_filetype(ae), AE_IFCHR); - assertEqualInt(archive_entry_mode(ae) & 0777, 0755); - assertEqualInt(archive_entry_uid(ae), 1000); - assertEqualInt(archive_entry_gid(ae), 1000); - assertEqualString(archive_entry_uname(ae), "tim"); - assertEqualString(archive_entry_gname(ae), "tim"); - assertEqualString(archive_entry_pathname(ae), "devchar"); - assert(archive_entry_symlink(ae) == NULL); - assert(archive_entry_hardlink(ae) == NULL); - assertEqualInt(archive_entry_mtime(ae), 1184389185); -} - -/* Block device node. */ -static unsigned char archive4[] = { -'d','e','v','b','l','o','c','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0', -'0','0','7','5','5',' ','0','0','0','1','7','5','0',' ','0','0','0','1','7', -'5','0',' ','0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4', -'6','0','5','4','1','0','1',' ','0','0','1','2','5','7','0',' ','4',0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0, -'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -'0','0','0','0','0','0','0',' ','0','0','0','0','0','0','0',' '}; - -static void verify4(struct archive_entry *ae) -{ - assertEqualInt(archive_entry_filetype(ae), AE_IFBLK); - assertEqualInt(archive_entry_mode(ae) & 0777, 0755); - assertEqualInt(archive_entry_uid(ae), 1000); - assertEqualInt(archive_entry_gid(ae), 1000); - assertEqualString(archive_entry_uname(ae), "tim"); - assertEqualString(archive_entry_gname(ae), "tim"); - assertEqualString(archive_entry_pathname(ae), "devblock"); - assert(archive_entry_symlink(ae) == NULL); - assert(archive_entry_hardlink(ae) == NULL); - assertEqualInt(archive_entry_mtime(ae), 1184389185); -} - -/* Directory. */ -static unsigned char archive5[] = { -'.',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', -'7','5','5',' ',0,'0','0','1','7','5','0',' ',0,'0','0','1','7','5','0', -' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','1','0','3','3', -'4','0','4','1','7','3','6',' ','0','1','0','5','6','1',0,' ','5',0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0, -'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0',' '}; - -static void verify5(struct archive_entry *ae) -{ - assertEqualInt(archive_entry_filetype(ae), AE_IFDIR); - assertEqualInt(archive_entry_mtime(ae), 1131430878); - assertEqualInt(archive_entry_mode(ae) & 0777, 0755); - assertEqualInt(archive_entry_uid(ae), 1000); - assertEqualInt(archive_entry_gid(ae), 1000); - assertEqualString(archive_entry_uname(ae), "tim"); - assertEqualString(archive_entry_gname(ae), "tim"); -} - -/* fifo */ -static unsigned char archive6[] = { -'f','i','f','o',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0', -'0','0','7','5','5',' ','0','0','0','1','7','5','0',' ','0','0','0','1','7', -'5','0',' ','0','0','0','0','0','0','0','0','0','0','0',' ','1','0','6','4', -'6','0','5','4','1','0','1',' ','0','0','1','1','7','2','4',' ','6',0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0, -'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -'0','0','0','0','0','0','0',' ','0','0','0','0','0','0','0',' '}; - -static void verify6(struct archive_entry *ae) -{ - assertEqualInt(archive_entry_filetype(ae), AE_IFIFO); - assertEqualInt(archive_entry_mode(ae) & 0777, 0755); - assertEqualInt(archive_entry_uid(ae), 1000); - assertEqualInt(archive_entry_gid(ae), 1000); - assertEqualString(archive_entry_uname(ae), "tim"); - assertEqualString(archive_entry_gname(ae), "tim"); - assertEqualString(archive_entry_pathname(ae), "fifo"); - assert(archive_entry_symlink(ae) == NULL); - assert(archive_entry_hardlink(ae) == NULL); - assertEqualInt(archive_entry_mtime(ae), 1184389185); -} - -/* GNU long link name */ -static unsigned char archiveK[] = { -'.','/','.','/','@','L','o','n','g','L','i','n','k',0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,'0','0','0','0','0','0','0',0,'0','0','0','0','0','0','0',0,'0','0','0', -'0','0','0','0',0,'0','0','0','0','0','0','0','0','6','6','6',0,'0','0','0', -'0','0','0','0','0','0','0','0',0,'0','1','1','7','1','5',0,' ','K',0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',' ',' ', -0,'r','o','o','t',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -'w','h','e','e','l',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'t', -'h','i','s','_','i','s','_','a','_','v','e','r','y','_','l','o','n','g','_', -'s','y','m','l','i','n','k','_','b','o','d','y','_','a','b','c','d','e','f', -'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y', -'z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q', -'r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i', -'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a', -'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t', -'u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l', -'m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d', -'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w', -'x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o', -'p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g', -'h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', -'_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', -'s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j', -'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b', -'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u', -'v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m', -'n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e', -'f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x', -'y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p', -'q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h', -'i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -'s','y','m','l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','1', -'2','0','7','5','5',0,'0','0','0','1','7','5','0',0,'0','0','0','1','7','5', -'0',0,'0','0','0','0','0','0','0','0','0','0','0',0,'1','0','6','4','6','0', -'5','6','7','7','0',0,'0','3','5','4','4','7',0,' ','2','t','h','i','s','_', -'i','s','_','a','_','v','e','r','y','_','l','o','n','g','_','s','y','m','l', -'i','n','k','_','b','o','d','y','_','a','b','c','d','e','f','g','h','i','j', -'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b', -'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u', -'v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l',0, -'u','s','t','a','r',' ',' ',0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,'t','i','m'}; - -static void verifyK(struct archive_entry *ae) -{ - assertEqualInt(archive_entry_filetype(ae), AE_IFLNK); - assertEqualInt(archive_entry_mode(ae) & 0777, 0755); - assertEqualInt(archive_entry_uid(ae), 1000); - assertEqualInt(archive_entry_gid(ae), 1000); - assertEqualString(archive_entry_uname(ae), "tim"); - assertEqualString(archive_entry_gname(ae), "tim"); - assertEqualString(archive_entry_pathname(ae), "symlink"); - assertEqualString(archive_entry_symlink(ae), - "this_is_a_very_long_symlink_body_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz"); - assert(archive_entry_hardlink(ae) == NULL); - assertEqualInt(archive_entry_mtime(ae), 1184390648); -} - -/* TODO: GNU long name */ - -/* TODO: Solaris ACL */ - -/* Pax extended long link name */ -static unsigned char archivexL[] = { -'.','/','P','a','x','H','e','a','d','e','r','s','.','8','6','9','7','5','/', -'s','y','m','l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0','0','6','4','4',0,'0','0','0','1', -'7','5','0',0,'0','0','0','1','7','5','0',0,'0','0','0','0','0','0','0','0', -'7','5','3',0,'1','0','6','4','6','0','5','7','6','1','1',0,'0','1','3','7', -'1','4',0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u', -'s','t','a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,'0','0','0','0','0','0','0',0,'0','0','0','0','0','0','0',0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'4','5','1',' ','l','i','n','k','p','a','t', -'h','=','t','h','i','s','_','i','s','_','a','_','v','e','r','y','_','l','o', -'n','g','_','s','y','m','l','i','n','k','_','b','o','d','y','_','a','b','c', -'d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', -'w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n', -'o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f', -'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y', -'z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q', -'r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i', -'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a', -'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t', -'u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l', -'m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d', -'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w', -'x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o', -'p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g', -'h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', -'_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', -'s','t','u','v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j', -'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b', -'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u', -'v','w','x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m', -'n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d','e', -'f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x', -'y','z',10,'2','0',' ','a','t','i','m','e','=','1','1','8','4','3','9','1', -'0','2','5',10,'2','0',' ','c','t','i','m','e','=','1','1','8','4','3','9', -'0','6','4','8',10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'s','y','m', -'l','i','n','k',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0','0','7', -'5','5',0,'0','0','0','1','7','5','0',0,'0','0','0','1','7','5','0',0,'0', -'0','0','0','0','0','0','0','0','0','0',0,'1','0','6','4','6','0','5','6', -'7','7','0',0,'0','3','7','1','2','1',0,' ','2','t','h','i','s','_','i','s', -'_','a','_','v','e','r','y','_','l','o','n','g','_','s','y','m','l','i','n', -'k','_','b','o','d','y','_','a','b','c','d','e','f','g','h','i','j','k','l', -'m','n','o','p','q','r','s','t','u','v','w','x','y','z','_','a','b','c','d', -'e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w', -'x','y','z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','u','s', -'t','a','r',0,'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,'0','0','0','0','0','0','0',0,'0','0','0','0','0','0','0'}; - -static void verifyxL(struct archive_entry *ae) -{ - assertEqualInt(archive_entry_filetype(ae), AE_IFLNK); - assertEqualInt(archive_entry_mode(ae) & 0777, 0755); - assertEqualInt(archive_entry_uid(ae), 1000); - assertEqualInt(archive_entry_gid(ae), 1000); - assertEqualString(archive_entry_uname(ae), "tim"); - assertEqualString(archive_entry_gname(ae), "tim"); - assertEqualString(archive_entry_pathname(ae), "symlink"); - assertEqualString(archive_entry_symlink(ae), - "this_is_a_very_long_symlink_body_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_" - "abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz"); - assert(archive_entry_hardlink(ae) == NULL); - assertEqualInt(archive_entry_mtime(ae), 1184390648); -} - - -/* TODO: Any other types of headers? */ - -static void verify(unsigned char *d, size_t s, - void (*f)(struct archive_entry *), - int compression, int format) -{ - struct archive_entry *ae; - struct archive *a; - unsigned char *buff = malloc(100000); - - memcpy(buff, d, s); - memset(buff + s, 0, 2048); - - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_memory(a, buff, s + 1024)); - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), compression); - assertEqualInt(archive_format(a), format); - - /* Verify the only entry. */ - f(ae); - - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - free(buff); -} - -DEFINE_TEST(test_read_format_tar) -{ - verifyEmpty(); - verify(archive1, sizeof(archive1), verify1, - ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR); - verify(archive2, sizeof(archive2), verify2, - ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR); - verify(archive3, sizeof(archive3), verify3, - ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR); - verify(archive4, sizeof(archive4), verify4, - ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR); - verify(archive5, sizeof(archive5), verify5, - ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR); - verify(archive6, sizeof(archive6), verify6, - ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_USTAR); - verify(archiveK, sizeof(archiveK), verifyK, - ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_GNUTAR); - verify(archivexL, sizeof(archivexL), verifyxL, - ARCHIVE_COMPRESSION_NONE, ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.c b/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.c deleted file mode 100644 index 8d917144448..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.c +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_tar_empty_filename.c,v 1.2 2008/09/01 05:38:33 kientzle Exp $"); - -/* - * Tar entries with empty filenames are unusual, but shouldn't crash us. - */ -DEFINE_TEST(test_read_format_tar_empty_filename) -{ - char name[] = "test_read_format_tar_empty_filename.tar"; - struct archive_entry *ae; - struct archive *a; - - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - extract_reference_file(name); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240)); - - /* Read first entry. */ - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("", archive_entry_pathname(ae)); - assertEqualInt(1208628157, archive_entry_mtime(ae)); - assertEqualInt(1000, archive_entry_uid(ae)); - assertEqualString("tim", archive_entry_uname(ae)); - assertEqualInt(0, archive_entry_gid(ae)); - assertEqualString("wheel", archive_entry_gname(ae)); - assertEqualInt(040775, archive_entry_mode(ae)); - - /* Verify the end-of-archive. */ - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - - /* Verify that the format detection worked. */ - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); - - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.tar.uu deleted file mode 100644 index f8a4f4f2f1b..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.tar.uu +++ /dev/null @@ -1,39 +0,0 @@ -$FreeBSD: src/lib/libarchive/test/test_read_format_tar_empty_filename.tar.uu,v 1.2 2008/07/03 03:26:30 peter Exp $ -begin 644 test_compat_tar_1.tar -M```````````````````````````````````````````````````````````` -M```````````````````````````````````````````````````````````` -M`````````````#`P,#<W-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P,#`P,#`P -M(#$Q,#`R-#,Q-C<U(#`Q,3`P,0`@-0`````````````````````````````` -M```````````````````````````````````````````````````````````` -M``````````````````````````````````````````!U<W1A<@`P,'1I;0`` -M````````````````````````````````````=VAE96P````````````````` -M```````````````````P,#`P,#`@`#`P,#`P,"`````````````````````` -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```````````````````````````````````````````````````````````` -&```````` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tbz.c b/archivers/libarchive/files/libarchive/test/test_read_format_tbz.c deleted file mode 100644 index 06d8cad4798..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_tbz.c +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tbz.c 201247 2009-12-30 05:59:21Z kientzle $"); - -static unsigned char archive[] = { -'B','Z','h','9','1','A','Y','&','S','Y',237,7,140,'W',0,0,27,251,144,208, -128,0,' ','@',1,'o',128,0,0,224,'"',30,0,0,'@',0,8,' ',0,'T','2',26,163,'&', -129,160,211,212,18,'I',169,234,13,168,26,6,150,'1',155,134,'p',8,173,3,183, -'J','S',26,20,'2',222,'b',240,160,'a','>',205,'f',29,170,227,'[',179,139, -'\'','L','o',211,':',178,'0',162,134,'*','>','8',24,153,230,147,'R','?',23, -'r','E','8','P',144,237,7,140,'W'}; - -DEFINE_TEST(test_read_format_tbz) -{ - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - r = archive_read_support_compression_bzip2(a); - if (r != ARCHIVE_OK) { - skipping("Bzip2 support"); - archive_read_finish(a); - return; - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tgz.c b/archivers/libarchive/files/libarchive/test/test_read_format_tgz.c deleted file mode 100644 index f411b433802..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_tgz.c +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tgz.c 191183 2009-04-17 01:06:31Z kientzle $"); - -static unsigned char archive[] = { -31,139,8,0,222,'C','p','C',0,3,211,'c',160,'=','0','0','0','0','7','5','U', -0,210,134,230,166,6,200,'4',28,'(',24,26,24,27,155,24,152,24,154,27,155,')', -24,24,26,152,154,25,'2','(',152,210,193,'m',12,165,197,'%',137,'E','@',167, -148,'d',230,226,'U','G','H',30,234,15,'8','=',10,'F',193,'(',24,5,131,28, -0,0,29,172,5,240,0,6,0,0}; - -DEFINE_TEST(test_read_format_tgz) -{ - struct archive_entry *ae; - struct archive *a; - int r; - - assert((a = archive_read_new()) != NULL); - assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a)); - r = archive_read_support_compression_gzip(a); - if (r == ARCHIVE_WARN) { - skipping("gzip reading not fully supported on this platform"); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - return; - } - assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualInt(ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(archive_compression(a), - ARCHIVE_COMPRESSION_GZIP); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); - assertEqualInt(ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK,archive_read_finish(a)); -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tz.c b/archivers/libarchive/files/libarchive/test/test_read_format_tz.c deleted file mode 100644 index eb066013842..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_tz.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tz.c 189381 2009-03-05 00:31:48Z kientzle $"); - -static unsigned char archive[] = { -31,157,144,'.',0,8,28,'H',176,160,193,131,8,19,'*','\\',200,176,'!','B',24, -16,'o',212,168,1,2,0,196,24,18,'a','T',188,152,'q','#',196,143,' ','5',198, -128,'1','c',6,13,24,'4','0',206,176,1,2,198,200,26,'6','b',0,0,'Q',195,161, -205,155,'8','s',234,4,'P','g',14,157,'0','r',',',194,160,147,166,205,206, -132,'D',141,30,'=',24,'R',163,'P',144,21,151,'J',157,'J',181,170,213,171, -'X',179,'j',221,202,181,171,215,175,'`',195,138,29,'K',182,172,217,179,'h', -211,170,']',203,182,173,219,183,'g',1}; - -DEFINE_TEST(test_read_format_tz) -{ - struct archive_entry *ae; - struct archive *a; - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_read_open_memory(a, archive, sizeof(archive))); - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - failure("archive_compression_name(a)=\"%s\"", - archive_compression_name(a)); - assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS); - failure("archive_format_name(a)=\"%s\"", archive_format_name(a)); - assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_zip.c b/archivers/libarchive/files/libarchive/test/test_read_format_zip.c deleted file mode 100644 index 680e7ede360..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_zip.c +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_zip.c 189482 2009-03-07 03:30:35Z kientzle $"); - -/* - * The reference file for this has been manually tweaked so that: - * * file2 has length-at-end but file1 does not - * * file2 has an invalid CRC - */ - -DEFINE_TEST(test_read_format_zip) -{ - const char *refname = "test_read_format_zip.zip"; - struct archive_entry *ae; - struct archive *a; - char *buff[128]; - const void *pv; - size_t s; - off_t o; - int r; - - extract_reference_file(refname); - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_filename(a, refname, 10240)); - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualString("dir/", archive_entry_pathname(ae)); - assertEqualInt(1179604249, archive_entry_mtime(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualIntA(a, ARCHIVE_EOF, - archive_read_data_block(a, &pv, &s, &o)); - assertEqualInt((int)s, 0); - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualString("file1", archive_entry_pathname(ae)); - assertEqualInt(1179604289, archive_entry_mtime(ae)); - assertEqualInt(18, archive_entry_size(ae)); - failure("archive_read_data() returns number of bytes read"); - r = archive_read_data(a, buff, 19); - if (r < ARCHIVE_OK) { - if (strcmp(archive_error_string(a), - "libarchive compiled without deflate support (no libz)") == 0) { - skipping("Skipping ZIP compression check: %s", - archive_error_string(a)); - goto finish; - } - } - assertEqualInt(18, r); - assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18)); - assertA(0 == archive_read_next_header(a, &ae)); - assertEqualString("file2", archive_entry_pathname(ae)); - assertEqualInt(1179605932, archive_entry_mtime(ae)); - failure("file2 has length-at-end, so we shouldn't see a valid size"); - assertEqualInt(0, archive_entry_size_is_set(ae)); - failure("file2 has a bad CRC, so reading to end should fail"); - assertEqualInt(ARCHIVE_WARN, archive_read_data(a, buff, 19)); - assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18)); - assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE); - assertA(archive_format(a) == ARCHIVE_FORMAT_ZIP); - assert(0 == archive_read_close(a)); -finish: -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif -} - - diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu b/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu deleted file mode 100644 index b1f04c4fea0..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu +++ /dev/null @@ -1,14 +0,0 @@ -$FreeBSD: src/lib/libarchive/test/test_read_format_zip.zip.uu,v 1.3 2008/10/21 05:08:35 kientzle Exp $ -begin 644 test_read_format_zip.zip -M4$L#!`H`"````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1M19 -M_4A5>`0`Z`/H`U!+!P@```````````````!02P,$%`````@`;V:S-CHW9CT* -M````$@````4`%0!F:6QE,554"0`#055/1L!9_4A5>`0`Z`/H`\M(S<G)Y\I` -M(@%02P,$%``(``@`6FJS-@``````````$@````4`%0!F:6QE,E54"0`#K%M/ -M1L!9_4A5>`0`Z`/H`\M(S<G)Y\I`(@%02P<(.C=F$@H````2````4$L!`A<# -M"@`(````66:S-@````````````````0`#0`````````0`.U!`````&1I<B]5 -M5`4``QE53T95>```4$L!`A<#%``(``@`;V:S-CHW9CT*````$@````4`#0`` -M`````0```.V!1P```&9I;&4Q550%``-!54]&57@``%!+`0(7`Q0`"``(`%IJ -MLS8Z-V8]"@```!(````%``T```````$```#M@8D```!F:6QE,E54!0`#K%M/ -;1E5X``!02P4&``````,``P"_````VP`````` -` -end diff --git a/archivers/libarchive/files/libarchive/test/test_read_large.c b/archivers/libarchive/files/libarchive/test/test_read_large.c deleted file mode 100644 index a2be6017865..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_large.c +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_large.c 201247 2009-12-30 05:59:21Z kientzle $"); - -static unsigned char testdata[10 * 1024 * 1024]; -static unsigned char testdatacopy[10 * 1024 * 1024]; -static unsigned char buff[11 * 1024 * 1024]; - -#if defined(_WIN32) && !defined(__CYGWIN__) -#define open _open -#define close _close -#endif - -/* Check correct behavior on large reads. */ -DEFINE_TEST(test_read_large) -{ - unsigned int i; - int tmpfilefd; - char tmpfilename[] = "test-read_large.XXXXXX"; - size_t used; - struct archive *a; - struct archive_entry *entry; - FILE *f; - - for (i = 0; i < sizeof(testdata); i++) - testdata[i] = (unsigned char)(rand()); - - assert(NULL != (a = archive_write_new())); - assertA(0 == archive_write_set_format_ustar(a)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - assert(NULL != (entry = archive_entry_new())); - archive_entry_set_size(entry, sizeof(testdata)); - archive_entry_set_mode(entry, S_IFREG | 0777); - archive_entry_set_pathname(entry, "test"); - assertA(0 == archive_write_header(a, entry)); - archive_entry_free(entry); - assertA((int)sizeof(testdata) == archive_write_data(a, testdata, sizeof(testdata))); - assertA(0 == archive_write_finish(a)); - - assert(NULL != (a = archive_read_new())); - assertA(0 == archive_read_support_format_all(a)); - 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)); - assertA(0 == archive_read_data_into_buffer(a, testdatacopy, sizeof(testdatacopy))); - assertA(0 == archive_read_finish(a)); - assert(0 == memcmp(testdata, testdatacopy, sizeof(testdata))); - - - assert(NULL != (a = archive_read_new())); - assertA(0 == archive_read_support_format_all(a)); - 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)); -#if defined(__BORLANDC__) - tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY); -#else - tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY, 0755); -#endif - assert(0 < tmpfilefd); - assertA(0 == archive_read_data_into_fd(a, tmpfilefd)); - close(tmpfilefd); - assertA(0 == archive_read_finish(a)); - - f = fopen(tmpfilename, "rb"); - assertEqualInt(sizeof(testdatacopy), - fread(testdatacopy, 1, sizeof(testdatacopy), f)); - fclose(f); - assert(0 == memcmp(testdata, testdatacopy, sizeof(testdata))); -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_pax_truncated.c b/archivers/libarchive/files/libarchive/test/test_read_pax_truncated.c deleted file mode 100644 index 4e2a8134ec2..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_pax_truncated.c +++ /dev/null @@ -1,288 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_pax_truncated.c 189483 2009-03-07 03:34:34Z kientzle $"); - -DEFINE_TEST(test_read_pax_truncated) -{ - struct archive_entry *ae; - struct archive *a; - size_t used, i, buff_size = 1000000; - size_t filedata_size = 100000; - char *buff = malloc(buff_size); - char *buff2 = malloc(buff_size); - char *filedata = malloc(filedata_size); - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_pax(a)); - assertA(0 == archive_write_set_compression_none(a)); - assertEqualIntA(a, ARCHIVE_OK, - archive_write_open_memory(a, buff, buff_size, &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); - for (i = 0; i < filedata_size; i++) - filedata[i] = (unsigned char)rand(); - archive_entry_set_atime(ae, 1, 2); - archive_entry_set_ctime(ae, 3, 4); - archive_entry_set_mtime(ae, 5, 6); - archive_entry_set_size(ae, filedata_size); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA((ssize_t)filedata_size - == archive_write_data(a, filedata, filedata_size)); - - /* 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 - - /* Now, read back a truncated version of the archive and - * verify that we get an appropriate error. */ - for (i = 1; i < used + 100; i += 100) { - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == read_open_memory2(a, buff, i, 13)); - - if (i < 1536) { - assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); - goto wrap_up; - } else { - failure("Archive truncated to %d bytes", i); - assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); - } - - if (i < 1536 + filedata_size) { - assertA(ARCHIVE_FATAL == archive_read_data(a, filedata, filedata_size)); - goto wrap_up; - } else { - failure("Archive truncated to %d bytes", i); - assertEqualIntA(a, filedata_size, - archive_read_data(a, filedata, filedata_size)); - } - - /* Verify the end of the archive. */ - /* Archive must be long enough to capture a 512-byte - * block of zeroes after the entry. (POSIX requires a - * second block of zeros to be written but libarchive - * does not return an error if it can't consume - * it.) */ - if (i < 1536 + 512*((filedata_size + 511)/512) + 512) { - failure("i=%d minsize=%d", i, - 1536 + 512*((filedata_size + 511)/512) + 512); - assertEqualIntA(a, ARCHIVE_FATAL, - archive_read_next_header(a, &ae)); - } else { - assertEqualIntA(a, ARCHIVE_EOF, - archive_read_next_header(a, &ae)); - } - wrap_up: - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - } - - - - /* Same as above, except skip the body instead of reading it. */ - for (i = 1; i < used + 100; i += 100) { - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == read_open_memory(a, buff, i, 7)); - - if (i < 1536) { - assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae)); - goto wrap_up2; - } else { - assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); - } - - if (i < 1536 + 512*((filedata_size+511)/512)) { - assertA(ARCHIVE_FATAL == archive_read_data_skip(a)); - goto wrap_up2; - } else { - assertA(ARCHIVE_OK == archive_read_data_skip(a)); - } - - /* Verify the end of the archive. */ - /* Archive must be long enough to capture a 512-byte - * block of zeroes after the entry. (POSIX requires a - * second block of zeros to be written but libarchive - * does not return an error if it can't consume - * it.) */ - if (i < 1536 + 512*((filedata_size + 511)/512) + 512) { - assertEqualIntA(a, ARCHIVE_FATAL, - archive_read_next_header(a, &ae)); - } else { - assertEqualIntA(a, ARCHIVE_EOF, - archive_read_next_header(a, &ae)); - } - wrap_up2: - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - } - - /* Now, damage the archive in various ways and test the responses. */ - - /* Damage the first size field in the pax attributes. */ - memcpy(buff2, buff, buff_size); - buff2[512] = '9'; - buff2[513] = '9'; - buff2[514] = 'A'; /* Non-digit in size. */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff2, used)); - assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - /* Damage the size field in the pax attributes. */ - memcpy(buff2, buff, buff_size); - buff2[512] = 'A'; /* First character not a digit. */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff2, used)); - assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - /* Damage the size field in the pax attributes. */ - memcpy(buff2, buff, buff_size); - for (i = 512; i < 520; i++) /* Size over 999999. */ - buff2[i] = '9'; - buff2[i] = ' '; - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff2, used)); - assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - /* Damage the size field in the pax attributes. */ - memcpy(buff2, buff, buff_size); - buff2[512] = '9'; /* Valid format, but larger than attribute area. */ - buff2[513] = '9'; - buff2[514] = '9'; - buff2[515] = ' '; - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff2, used)); - assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - /* Damage the size field in the pax attributes. */ - memcpy(buff2, buff, buff_size); - buff2[512] = '1'; /* Too small. */ - buff2[513] = ' '; - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff2, used)); - assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - /* Damage the size field in the pax attributes. */ - memcpy(buff2, buff, buff_size); - buff2[512] = ' '; /* No size given. */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff2, used)); - assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - /* Damage the ustar header. */ - memcpy(buff2, buff, buff_size); - buff2[1024]++; /* Break the checksum. */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff2, used)); - assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - /* - * TODO: Damage the ustar header in various ways and fixup the - * checksum in order to test boundary cases in the innermost - * ustar header parsing. - */ - - free(buff); - free(buff2); - free(filedata); -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_position.c b/archivers/libarchive/files/libarchive/test/test_read_position.c deleted file mode 100644 index 85b79672142..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_position.c +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_position.c 189389 2009-03-05 02:19:42Z kientzle $"); - -static unsigned char nulls[10000]; -static unsigned char buff[10000000]; - -/* Check that header_position tracks correctly on read. */ -DEFINE_TEST(test_read_position) -{ - struct archive *a; - struct archive_entry *ae; - size_t write_pos; - intmax_t read_position; - size_t i, j; - size_t data_sizes[] = {0, 5, 511, 512, 513}; - - /* Sanity test */ - assert(sizeof(nulls) + 512 + 1024 <= sizeof(buff)); - - /* Create an archive. */ - assert(NULL != (a = archive_write_new())); - assertA(0 == archive_write_set_format_pax_restricted(a)); - assertA(0 == archive_write_set_bytes_per_block(a, 512)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &write_pos)); - - for (i = 0; i < sizeof(data_sizes)/sizeof(data_sizes[0]); ++i) { - /* Create a simple archive_entry. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_pathname(ae, "testfile"); - archive_entry_set_mode(ae, S_IFREG); - archive_entry_set_size(ae, data_sizes[i]); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA(data_sizes[i] - == (size_t)archive_write_data(a, nulls, sizeof(nulls))); - } - assertA(0 == archive_write_close(a)); - assertA(0 == archive_write_finish(a)); - - /* Read the archive back. */ - assert(NULL != (a = archive_read_new())); - assertA(0 == archive_read_support_format_tar(a)); - assertA(0 == archive_read_open_memory2(a, buff, sizeof(buff), 512)); - - read_position = 0; - /* Initial header position is zero. */ - assert(read_position == (intmax_t)archive_read_header_position(a)); - for (j = 0; j < i; ++j) { - assertA(0 == archive_read_next_header(a, &ae)); - assert(read_position - == (intmax_t)archive_read_header_position(a)); - /* Every other entry: read, then skip */ - if (j & 1) - assertEqualInt(ARCHIVE_OK, - archive_read_data_into_buffer(a, buff, 1)); - assertA(0 == archive_read_data_skip(a)); - /* read_data_skip() doesn't change header_position */ - assert(read_position - == (intmax_t)archive_read_header_position(a)); - - read_position += 512; /* Size of header. */ - read_position += (data_sizes[j] + 511) & ~511; - } - - assertA(1 == archive_read_next_header(a, &ae)); - assert(read_position == (intmax_t)archive_read_header_position(a)); - assertA(0 == archive_read_close(a)); - assert(read_position == (intmax_t)archive_read_header_position(a)); - archive_read_finish(a); -} diff --git a/archivers/libarchive/files/libarchive/test/test_read_truncated.c b/archivers/libarchive/files/libarchive/test/test_read_truncated.c deleted file mode 100644 index 9b26b59818a..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_read_truncated.c +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_truncated.c,v 1.4 2008/09/01 05:38:33 kientzle Exp $"); - -char buff[1000000]; -char buff2[100000]; - -DEFINE_TEST(test_read_truncated) -{ - struct archive_entry *ae; - struct archive *a; - unsigned int i; - size_t used; - - /* 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_none(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); - for (i = 0; i < sizeof(buff2); i++) - buff2[i] = (unsigned char)rand(); - archive_entry_set_size(ae, sizeof(buff2)); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA((int)sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2))); - - /* 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 - - /* Now, read back a truncated version of the archive and - * verify that we get an appropriate error. */ - for (i = 1; i < used + 100; i += 100) { - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, i)); - - if (i < 512) { - assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae)); - goto wrap_up; - } else { - assertA(0 == archive_read_next_header(a, &ae)); - } - - if (i < 512 + sizeof(buff2)) { - assertA(ARCHIVE_FATAL == archive_read_data(a, buff2, sizeof(buff2))); - goto wrap_up; - } else { - assertA((int)sizeof(buff2) == archive_read_data(a, buff2, sizeof(buff2))); - } - - /* Verify the end of the archive. */ - /* Archive must be long enough to capture a 512-byte - * block of zeroes after the entry. (POSIX requires a - * second block of zeros to be written but libarchive - * does not return an error if it can't consume - * it.) */ - if (i < 512 + 512*((sizeof(buff2) + 511)/512) + 512) { - assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae)); - } else { - assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae)); - } - wrap_up: - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - } - - - - /* Same as above, except skip the body instead of reading it. */ - for (i = 1; i < used + 100; i += 100) { - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, i)); - - if (i < 512) { - assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae)); - goto wrap_up2; - } else { - assertA(0 == archive_read_next_header(a, &ae)); - } - - if (i < 512 + 512*((sizeof(buff2)+511)/512)) { - assertA(ARCHIVE_FATAL == archive_read_data_skip(a)); - goto wrap_up2; - } else { - assertA(ARCHIVE_OK == archive_read_data_skip(a)); - } - - /* Verify the end of the archive. */ - /* Archive must be long enough to capture a 512-byte - * block of zeroes after the entry. (POSIX requires a - * second block of zeros to be written but libarchive - * does not return an error if it can't consume - * it.) */ - if (i < 512 + 512*((sizeof(buff2) + 511)/512) + 512) { - assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae)); - } else { - assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae)); - } - wrap_up2: - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - } -} diff --git a/archivers/libarchive/files/libarchive/test/test_tar_filenames.c b/archivers/libarchive/files/libarchive/test/test_tar_filenames.c deleted file mode 100644 index b08373819df..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_tar_filenames.c +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_filenames.c,v 1.10 2008/09/01 05:38:33 kientzle Exp $"); - -/* - * Exercise various lengths of filenames in tar archives, - * especially around the magic sizes where ustar breaks - * filenames into prefix/suffix. - */ - -static void -test_filename(const char *prefix, int dlen, int flen) -{ - char buff[8192]; - char filename[400]; - char dirname[400]; - struct archive_entry *ae; - struct archive *a; - size_t used; - char *p; - int i; - - p = filename; - if (prefix) { - strcpy(filename, prefix); - p += strlen(p); - } - if (dlen > 0) { - for (i = 0; i < dlen; i++) - *p++ = 'a'; - *p++ = '/'; - } - for (i = 0; i < flen; i++) - *p++ = 'b'; - *p = '\0'; - - strcpy(dirname, filename); - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_pax_restricted(a)); - assertA(0 == archive_write_set_compression_none(a)); - assertA(0 == archive_write_set_bytes_per_block(a,0)); - 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, filename); - archive_entry_set_mode(ae, S_IFREG | 0755); - failure("Pathname %d/%d", dlen, flen); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - - /* - * Write a dir to it (without trailing '/'). - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, dirname); - archive_entry_set_mode(ae, S_IFDIR | 0755); - failure("Dirname %d/%d", dlen, flen); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - - /* Tar adds a '/' to directory names. */ - strcat(dirname, "/"); - - /* - * Write a dir to it (with trailing '/'). - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, dirname); - archive_entry_set_mode(ae, S_IFDIR | 0755); - failure("Dirname %d/%d", dlen, flen); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - - /* 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 - - /* - * Now, read the data back. - */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used)); - - /* Read the file and check the filename. */ - assertA(0 == archive_read_next_header(a, &ae)); -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("Leading '/' preserved on long filenames"); -#else - assertEqualString(filename, archive_entry_pathname(ae)); -#endif - assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae)); - - /* - * Read the two dirs and check the names. - * - * Both dirs should read back with the same name, since - * tar should add a trailing '/' to any dir that doesn't - * already have one. We only report the first such failure - * here. - */ - assertA(0 == archive_read_next_header(a, &ae)); -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("Trailing '/' preserved on dirnames"); -#else - assertEqualString(dirname, archive_entry_pathname(ae)); -#endif - assert((S_IFDIR | 0755) == archive_entry_mode(ae)); - - assertA(0 == archive_read_next_header(a, &ae)); -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("Trailing '/' added to dir names"); -#else - assertEqualString(dirname, archive_entry_pathname(ae)); -#endif - assert((S_IFDIR | 0755) == archive_entry_mode(ae)); - - /* Verify the end of the archive. */ - assert(1 == archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif -} - -DEFINE_TEST(test_tar_filenames) -{ - int dlen, flen; - - /* Repeat the following for a variety of dir/file lengths. */ - for (dlen = 45; dlen < 55; dlen++) { - for (flen = 45; flen < 55; flen++) { - test_filename(NULL, dlen, flen); - test_filename("/", dlen, flen); - } - } - - for (dlen = 0; dlen < 140; dlen += 10) { - for (flen = 98; flen < 102; flen++) { - test_filename(NULL, dlen, flen); - test_filename("/", dlen, flen); - } - } - - for (dlen = 140; dlen < 160; dlen++) { - for (flen = 95; flen < 105; flen++) { - test_filename(NULL, dlen, flen); - test_filename("/", dlen, flen); - } - } -} diff --git a/archivers/libarchive/files/libarchive/test/test_tar_large.c b/archivers/libarchive/files/libarchive/test/test_tar_large.c deleted file mode 100644 index adc81551cec..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_tar_large.c +++ /dev/null @@ -1,312 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_tar_large.c 201247 2009-12-30 05:59:21Z kientzle $"); - -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -/* - * This is a somewhat tricky test that verifies the ability to - * write and read very large entries to tar archives. It - * writes entries from 2GB up to 1TB to an archive in memory. - * The memory storage here carefully avoids actually storing - * any part of the file bodies, so it runs very quickly and requires - * very little memory. If you're willing to wait a few minutes, - * you should be able to exercise petabyte entries with this code. - */ - -/* - * Each file is built up by duplicating the following block. - */ -static size_t filedatasize; -static void *filedata; - -/* - * We store the archive as blocks of data generated by libarchive, - * each possibly followed by bytes of file data. - */ -struct memblock { - struct memblock *next; - size_t size; - void *buff; - int64_t filebytes; -}; - -/* - * The total memory store is just a list of memblocks plus - * some accounting overhead. - */ -struct memdata { - int64_t filebytes; - void *buff; - struct memblock *first; - struct memblock *last; -}; - -/* The following size definitions simplify things below. */ -#define KB ((int64_t)1024) -#define MB ((int64_t)1024 * KB) -#define GB ((int64_t)1024 * MB) -#define TB ((int64_t)1024 * GB) - -#if ARCHIVE_VERSION_NUMBER < 2000000 -static ssize_t memory_read_skip(struct archive *, void *, size_t request); -#else -static off_t memory_read_skip(struct archive *, void *, off_t request); -#endif -static ssize_t memory_read(struct archive *, void *, const void **buff); -static ssize_t memory_write(struct archive *, void *, const void *, size_t); - - -static ssize_t -memory_write(struct archive *a, void *_private, const void *buff, size_t size) -{ - struct memdata *private = _private; - struct memblock *block; - - (void)a; - - /* - * Since libarchive tries to behave in a zero-copy manner, if - * you give a pointer to filedata to the library, a pointer - * into that data will (usually) pop out here. This way, we - * can tell the difference between filedata and library header - * and metadata. - */ - 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 += (int64_t)size; - } else { - /* Yes, we're assuming the very first write is metadata. */ - /* It's header or metadata, copy and save it. */ - block = (struct memblock *)malloc(sizeof(*block)); - memset(block, 0, sizeof(*block)); - block->size = size; - block->buff = malloc(size); - memcpy(block->buff, buff, size); - if (private->last == NULL) { - private->first = private->last = block; - } else { - private->last->next = block; - private->last = block; - } - block->next = NULL; - } - return ((long)size); -} - -static ssize_t -memory_read(struct archive *a, void *_private, const void **buff) -{ - struct memdata *private = _private; - struct memblock *block; - ssize_t size; - - (void)a; - - free(private->buff); - private->buff = NULL; - if (private->first == NULL) { - private->last = NULL; - return (ARCHIVE_EOF); - } - if (private->filebytes > 0) { - /* - * We're returning file bytes, simulate it by - * passing blocks from the template data. - */ - if (private->filebytes > (int64_t)filedatasize) - size = (ssize_t)filedatasize; - else - size = (ssize_t)private->filebytes; - private->filebytes -= size; - *buff = filedata; - } else { - /* - * We need to get some real data to return. - */ - block = private->first; - private->first = block->next; - size = (ssize_t)block->size; - if (block->buff != NULL) { - private->buff = block->buff; - *buff = block->buff; - } else { - private->buff = NULL; - *buff = filedata; - } - private->filebytes = block->filebytes; - free(block); - } - return (size); -} - - -#if ARCHIVE_VERSION_NUMBER < 2000000 -static ssize_t -memory_read_skip(struct archive *a, void *private, size_t skip) -{ - (void)a; /* UNUSED */ - (void)private; /* UNUSED */ - (void)skip; /* UNUSED */ - return (0); -} -#else -static off_t -memory_read_skip(struct archive *a, void *_private, off_t skip) -{ - struct memdata *private = _private; - - (void)a; - - if (private->first == NULL) { - private->last = NULL; - return (0); - } - if (private->filebytes > 0) { - if (private->filebytes < skip) - skip = (off_t)private->filebytes; - private->filebytes -= skip; - } else { - skip = 0; - } - return (skip); -} -#endif - -DEFINE_TEST(test_tar_large) -{ - /* The sizes of the entries we're going to generate. */ - static int64_t tests[] = { - /* Test for 32-bit signed overflow. */ - 2 * GB - 1, 2 * GB, 2 * GB + 1, - /* Test for 32-bit unsigned overflow. */ - 4 * GB - 1, 4 * GB, 4 * GB + 1, - /* 8GB is the "official" max for ustar. */ - 8 * GB - 1, 8 * GB, 8 * GB + 1, - /* Bend ustar a tad and you can get 64GB (12 octal digits). */ - 64 * GB - 1, 64 * GB, - /* And larger entries that require non-ustar extensions. */ - 256 * GB, 1 * TB, 0 }; - int i; - char namebuff[64]; - struct memdata memdata; - struct archive_entry *ae; - struct archive *a; - int64_t filesize; - size_t writesize; - - filedatasize = (size_t)(1 * MB); - filedata = malloc(filedatasize); - memset(filedata, 0xAA, filedatasize); - memset(&memdata, 0, sizeof(memdata)); - - /* - * Open an archive for writing. - */ - a = archive_write_new(); - archive_write_set_format_pax_restricted(a); - archive_write_set_bytes_per_block(a, 0); /* No buffering. */ - archive_write_open(a, &memdata, NULL, memory_write, NULL); - - /* - * Write a series of large files to it. - */ - for (i = 0; tests[i] != 0; i++) { - assert((ae = archive_entry_new()) != NULL); - sprintf(namebuff, "file_%d", i); - archive_entry_copy_pathname(ae, namebuff); - archive_entry_set_mode(ae, S_IFREG | 0755); - filesize = tests[i]; - - archive_entry_set_size(ae, filesize); - - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - - /* - * Write the actual data to the archive. - */ - while (filesize > 0) { - writesize = filedatasize; - if ((int64_t)writesize > filesize) - writesize = (size_t)filesize; - assertA((int)writesize - == archive_write_data(a, filedata, writesize)); - filesize -= writesize; - } - } - - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "lastfile"); - archive_entry_set_mode(ae, S_IFREG | 0755); - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - - - /* 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 - - /* - * Open the same archive for reading. - */ - a = archive_read_new(); - archive_read_support_format_tar(a); - archive_read_open2(a, &memdata, NULL, - memory_read, memory_read_skip, NULL); - - /* - * Read entries back. - */ - for (i = 0; tests[i] > 0; i++) { - assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); - sprintf(namebuff, "file_%d", i); - assertEqualString(namebuff, archive_entry_pathname(ae)); - assert(tests[i] == archive_entry_size(ae)); - } - assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); - assertEqualString("lastfile", archive_entry_pathname(ae)); - - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - - /* Close out the archive. */ - assertA(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertA(0 == archive_read_finish(a)); -#endif - - free(memdata.buff); - free(filedata); -} diff --git a/archivers/libarchive/files/libarchive/test/test_ustar_filenames.c b/archivers/libarchive/files/libarchive/test/test_ustar_filenames.c deleted file mode 100644 index e3ebf3c92f0..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_ustar_filenames.c +++ /dev/null @@ -1,191 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_ustar_filenames.c 189308 2009-03-03 17:02:51Z kientzle $"); - -/* - * Exercise various lengths of filenames in ustar archives. - */ - -static void -test_filename(const char *prefix, int dlen, int flen) -{ - char buff[8192]; - char filename[400]; - char dirname[400]; - struct archive_entry *ae; - struct archive *a; - size_t used; - int separator = 0; - int i = 0; - - if (prefix != NULL) { - strcpy(filename, prefix); - i = (int)strlen(prefix); - } - if (dlen > 0) { - for (; i < dlen; i++) - filename[i] = 'a'; - filename[i++] = '/'; - separator = 1; - } - for (; i < dlen + flen + separator; i++) - filename[i] = 'b'; - filename[i] = '\0'; - - strcpy(dirname, filename); - - /* 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_none(a)); - assertA(0 == archive_write_set_bytes_per_block(a,0)); - 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, filename); - archive_entry_set_mode(ae, S_IFREG | 0755); - failure("dlen=%d, flen=%d", dlen, flen); - if (flen > 100) { - assertEqualIntA(a, ARCHIVE_FAILED, archive_write_header(a, ae)); - } else { - assertEqualIntA(a, 0, archive_write_header(a, ae)); - } - archive_entry_free(ae); - - /* - * Write a dir to it (without trailing '/'). - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, dirname); - archive_entry_set_mode(ae, S_IFDIR | 0755); - failure("dlen=%d, flen=%d", dlen, flen); - if (flen >= 100) { - assertEqualIntA(a, ARCHIVE_FAILED, archive_write_header(a, ae)); - } else { - assertEqualIntA(a, 0, archive_write_header(a, ae)); - } - archive_entry_free(ae); - - /* Tar adds a '/' to directory names. */ - strcat(dirname, "/"); - - /* - * Write a dir to it (with trailing '/'). - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, dirname); - archive_entry_set_mode(ae, S_IFDIR | 0755); - failure("dlen=%d, flen=%d", dlen, flen); - if (flen >= 100) { - assertEqualIntA(a, ARCHIVE_FAILED, archive_write_header(a, ae)); - } else { - assertEqualIntA(a, 0, archive_write_header(a, ae)); - } - archive_entry_free(ae); - - /* Close out the archive. */ - assertA(0 == archive_write_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assertEqualInt(0, archive_write_finish(a)); -#endif - - /* - * Now, read the data back. - */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used)); - - if (flen <= 100) { - /* Read the file and check the filename. */ - assertA(0 == archive_read_next_header(a, &ae)); - failure("dlen=%d, flen=%d", dlen, flen); - assertEqualString(filename, archive_entry_pathname(ae)); - assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae)); - } - - /* - * Read the two dirs and check the names. - * - * Both dirs should read back with the same name, since - * tar should add a trailing '/' to any dir that doesn't - * already have one. - */ - if (flen <= 99) { - assertA(0 == archive_read_next_header(a, &ae)); - assert((S_IFDIR | 0755) == archive_entry_mode(ae)); - failure("dlen=%d, flen=%d", dlen, flen); - assertEqualString(dirname, archive_entry_pathname(ae)); - } - - if (flen <= 99) { - assertA(0 == archive_read_next_header(a, &ae)); - assert((S_IFDIR | 0755) == archive_entry_mode(ae)); - assertEqualString(dirname, archive_entry_pathname(ae)); - } - - /* Verify the end of the archive. */ - failure("This fails if entries were written that should not have been written. dlen=%d, flen=%d", dlen, flen); - assertEqualInt(1, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(0, archive_read_finish(a)); -#endif -} - -DEFINE_TEST(test_ustar_filenames) -{ - int dlen, flen; - - /* Try a bunch of different file/dir lengths that add up - * to just a little less or a little more than 100 bytes. - * This exercises the code that splits paths between ustar - * filename and prefix fields. - */ - for (dlen = 5; dlen < 70; dlen += 5) { - for (flen = 100 - dlen - 5; flen < 100 - dlen + 5; flen++) { - test_filename(NULL, dlen, flen); - test_filename("/", dlen, flen); - } - } - - /* Probe the 100-char limit for paths with no '/'. */ - for (flen = 90; flen < 110; flen++) { - test_filename(NULL, 0, flen); - test_filename("/", dlen, flen); - } - - /* XXXX TODO Probe the 100-char limit with a dir prefix. */ - /* XXXX TODO Probe the 255-char total limit. */ -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress.c b/archivers/libarchive/files/libarchive/test/test_write_compress.c deleted file mode 100644 index aa590de8a91..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_compress.c +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * Copyright (c) 2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_compress.c 189308 2009-03-03 17:02:51Z kientzle $"); - -/* - * A basic exercise of compress reading and writing. - * - * TODO: Add a reference file and make sure we can decompress that. - */ - -DEFINE_TEST(test_write_compress) -{ - struct archive_entry *ae; - struct archive* a; - char *buff, *data; - size_t buffsize, datasize; - char path[16]; - size_t used; - int i; - - buffsize = 1000000; - assert(NULL != (buff = (char *)malloc(buffsize))); - - datasize = 10000; - assert(NULL != (data = (char *)malloc(datasize))); - memset(data, 0, datasize); - - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ustar(a)); - assertA(0 == archive_write_set_compression_compress(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used)); - - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, path); - archive_entry_set_size(ae, datasize); - archive_entry_set_filetype(ae, AE_IFREG); - assertA(0 == archive_write_header(a, ae)); - assertA(datasize == (size_t)archive_write_data(a, data, datasize)); - archive_entry_free(ae); - } - - - archive_write_close(a); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assert(0 == archive_write_finish(a)); -#endif - - /* - * Now, read the data back. - */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used)); - - - for (i = 0; i < 100; i++) { - sprintf(path, "file%03d", i); - if (!assertEqualInt(0, archive_read_next_header(a, &ae))) - break; - assertEqualString(path, archive_entry_pathname(ae)); - assertEqualInt((int)datasize, archive_entry_size(ae)); - } - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - free(data); - free(buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_program.c b/archivers/libarchive/files/libarchive/test/test_write_compress_program.c deleted file mode 100644 index bae77e5341b..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_compress_program.c +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_compress_program.c 201247 2009-12-30 05:59:21Z kientzle $"); - -char buff[1000000]; -char buff2[64]; - -DEFINE_TEST(test_write_compress_program) -{ -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("archive_write_set_compress_program()"); -#else - struct archive_entry *ae; - struct archive *a; - size_t used; - int blocksize = 1024; - int r; - - if (!canGzip()) { - skipping("Cannot run 'gzip'"); - return; - } - - /* 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)); - 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)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - assertA(blocksize == archive_write_get_bytes_in_last_block(a)); - - /* - * Write a file to it. - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_mtime(ae, 1, 10); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, 8); - - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA(8 == archive_write_data(a, "12345678", 9)); - - /* Close out the archive. */ - assertA(0 == archive_write_close(a)); - assertA(0 == archive_write_finish(a)); - - /* - * Now, read the data back through the built-in gzip support. - */ - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - r = archive_read_support_compression_gzip(a); - /* The compression_gzip() handler will fall back to gunzip - * automatically, but if we know gunzip isn't available, then - * skip the rest. */ - if (r != ARCHIVE_OK && !canGunzip()) { - skipping("No libz and no gunzip program, " - "unable to verify gzip compression"); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - return; - } - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used)); - - if (!assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae))) { - archive_read_finish(a); - return; - } - - assertEqualInt(1, archive_entry_mtime(ae)); - assertEqualInt(0, archive_entry_atime(ae)); - assertEqualInt(0, archive_entry_ctime(ae)); - assertEqualString("file", archive_entry_pathname(ae)); - assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae)); - assertEqualInt(8, archive_entry_size(ae)); - assertEqualIntA(a, 8, archive_read_data(a, buff2, 10)); - assertEqualMem(buff2, "12345678", 8); - - /* Verify the end of the archive. */ - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); - assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk.c b/archivers/libarchive/files/libarchive/test/test_write_disk.c deleted file mode 100644 index 169f4f23996..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_disk.c +++ /dev/null @@ -1,332 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk.c 201247 2009-12-30 05:59:21Z kientzle $"); - -#if ARCHIVE_VERSION_NUMBER >= 1009000 - -#define UMASK 022 -/* - * When comparing mode values, ignore high-order bits - * that are set on some OSes. This should cover the bits - * we're interested in (standard mode bits + file type bits) - * while ignoring extra markers such as Haiku/BeOS index - * flags. - */ -#define MODE_MASK 0777777 - -static void create(struct archive_entry *ae, const char *msg) -{ - struct archive *ad; - struct stat st; - - /* Write the entry to disk. */ - assert((ad = archive_write_disk_new()) != NULL); - failure("%s", msg); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(ad); -#else - assertEqualInt(0, archive_write_finish(ad)); -#endif - /* Test the entries on disk. */ - assert(0 == stat(archive_entry_pathname(ae), &st)); - failure("%s", msg); - -#if !defined(_WIN32) || defined(__CYGWIN__) - /* When verifying a dir, ignore the S_ISGID bit, as some systems set - * that automatically. */ - if (archive_entry_filetype(ae) == AE_IFDIR) - st.st_mode &= ~S_ISGID; - assertEqualInt(st.st_mode & MODE_MASK, - archive_entry_mode(ae) & ~UMASK & MODE_MASK); -#endif -} - -static void create_reg_file(struct archive_entry *ae, const char *msg) -{ - static const char data[]="abcdefghijklmnopqrstuvwxyz"; - struct archive *ad; - - /* Write the entry to disk. */ - assert((ad = archive_write_disk_new()) != NULL); - archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME); - failure("%s", msg); - /* - * A touchy API design issue: archive_write_data() does (as of - * 2.4.12) enforce the entry size as a limit on the data - * written to the file. This was not enforced prior to - * 2.4.12. The change was prompted by the refined - * hardlink-restore semantics introduced at that time. In - * short, libarchive needs to know whether a "hardlink entry" - * is going to overwrite the contents so that it can know - * whether or not to open the file for writing. This implies - * that there is a fundamental semantic difference between an - * entry with a zero size and one with a non-zero size in the - * case of hardlinks and treating the hardlink case - * differently from the regular file case is just asking for - * trouble. So, a zero size must always mean that no data - * will be accepted, which is consistent with the file size in - * the entry being a maximum size. - */ - archive_entry_set_size(ae, sizeof(data)); - archive_entry_set_mtime(ae, 123456789, 0); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(ad); -#else - assertEqualInt(0, archive_write_finish(ad)); -#endif - /* Test the entries on disk. */ - assertIsReg(archive_entry_pathname(ae), archive_entry_mode(ae) & 0777); - assertFileSize(archive_entry_pathname(ae), sizeof(data)); - /* test_write_disk_times has more detailed tests of this area. */ - assertFileMtime(archive_entry_pathname(ae), 123456789, 0); - failure("No atime given, so atime should get set to current time"); - assertFileAtimeRecent(archive_entry_pathname(ae)); -} - -static void create_reg_file2(struct archive_entry *ae, const char *msg) -{ - const int datasize = 100000; - char *data; - struct archive *ad; - int i; - - data = malloc(datasize); - for (i = 0; i < datasize; i++) - data[i] = (char)(i % 256); - - /* Write the entry to disk. */ - assert((ad = archive_write_disk_new()) != NULL); - failure("%s", msg); - /* - * See above for an explanation why this next call - * is necessary. - */ - archive_entry_set_size(ae, datasize); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - for (i = 0; i < datasize - 999; i += 1000) { - assertEqualIntA(ad, ARCHIVE_OK, - archive_write_data_block(ad, data + i, 1000, i)); - } - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - assertEqualInt(0, archive_write_finish(ad)); - - /* Test the entries on disk. */ - assertIsReg(archive_entry_pathname(ae), archive_entry_mode(ae) & 0777); - assertFileSize(archive_entry_pathname(ae), i); - assertFileContents(data, datasize, archive_entry_pathname(ae)); - free(data); -} - -static void create_reg_file3(struct archive_entry *ae, const char *msg) -{ - static const char data[]="abcdefghijklmnopqrstuvwxyz"; - struct archive *ad; - struct stat st; - - /* Write the entry to disk. */ - assert((ad = archive_write_disk_new()) != NULL); - failure("%s", msg); - /* Set the size smaller than the data and verify the truncation. */ - archive_entry_set_size(ae, 5); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualInt(5, archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(ad); -#else - assertEqualInt(0, archive_write_finish(ad)); -#endif - /* Test the entry on disk. */ - 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)); -#if !defined(_WIN32) || defined(__CYGWIN__) - assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); -#endif - assertEqualInt(st.st_size, 5); -} - - -static void create_reg_file4(struct archive_entry *ae, const char *msg) -{ - static const char data[]="abcdefghijklmnopqrstuvwxyz"; - struct archive *ad; - struct stat st; - - /* Write the entry to disk. */ - assert((ad = archive_write_disk_new()) != NULL); - /* Leave the size unset. The data should not be truncated. */ - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualInt(ARCHIVE_OK, - archive_write_data_block(ad, data, sizeof(data), 0)); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(ad); -#else - assertEqualInt(0, archive_write_finish(ad)); -#endif - /* Test the entry on disk. */ - 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)); -#if !defined(_WIN32) || defined(__CYGWIN__) - assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); -#endif - failure(msg); - assertEqualInt(st.st_size, sizeof(data)); -} - -#if defined(_WIN32) && !defined(__CYGWIN__) -static void create_reg_file_win(struct archive_entry *ae, const char *msg) -{ - static const char data[]="abcdefghijklmnopqrstuvwxyz"; - struct archive *ad; - struct stat st; - char *p, *fname; - size_t l; - - /* Write the entry to disk. */ - assert((ad = archive_write_disk_new()) != NULL); - archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME); - failure("%s", msg); - archive_entry_set_size(ae, sizeof(data)); - archive_entry_set_mtime(ae, 123456789, 0); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(ad); -#else - assertEqualInt(0, archive_write_finish(ad)); -#endif - /* Test the entries on disk. */ - l = strlen(archive_entry_pathname(ae)); - fname = malloc(l + 1); - assert(NULL != fname); - strcpy(fname, archive_entry_pathname(ae)); - /* Replace unusable characters in Windows to '_' */ - for (p = fname; *p != '\0'; p++) - if (*p == ':' || *p == '*' || *p == '?' || - *p == '"' || *p == '<' || *p == '>' || *p == '|') - *p = '_'; - assert(0 == stat(fname, &st)); - failure("st.st_mode=%o archive_entry_mode(ae)=%o", - st.st_mode, archive_entry_mode(ae)); - assertEqualInt(st.st_size, sizeof(data)); -} -#endif /* _WIN32 && !__CYGWIN__ */ -#endif - -DEFINE_TEST(test_write_disk) -{ -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("archive_write_disk interface"); -#else - struct archive_entry *ae; - - /* Force the umask to something predictable. */ - assertUmask(UMASK); - - /* A regular file. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0755); - create_reg_file(ae, "Test creating a regular file"); - archive_entry_free(ae); - - /* Another regular file. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file2"); - archive_entry_set_mode(ae, S_IFREG | 0755); - create_reg_file2(ae, "Test creating another regular file"); - archive_entry_free(ae); - - /* A regular file with a size restriction */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file3"); - archive_entry_set_mode(ae, S_IFREG | 0755); - create_reg_file3(ae, "Regular file with size restriction"); - archive_entry_free(ae); - - /* A regular file with an unspecified size */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file3"); - archive_entry_set_mode(ae, S_IFREG | 0755); - create_reg_file4(ae, "Regular file with unspecified size"); - archive_entry_free(ae); - - /* A regular file over an existing file */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0724); - create(ae, "Test creating a file over an existing file."); - archive_entry_free(ae); - - /* A directory. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir"); - archive_entry_set_mode(ae, S_IFDIR | 0555); - create(ae, "Test creating a regular dir."); - archive_entry_free(ae); - - /* A directory over an existing file. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFDIR | 0742); - create(ae, "Test creating a dir over an existing file."); - archive_entry_free(ae); - - /* A file over an existing dir. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file"); - archive_entry_set_mode(ae, S_IFREG | 0744); - create(ae, "Test creating a file over an existing dir."); - archive_entry_free(ae); - -#if defined(_WIN32) && !defined(__CYGWIN__) - /* A file with unusable characters in its file name. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "f:i*l?e\"f<i>l|e"); - archive_entry_set_mode(ae, S_IFREG | 0755); - create_reg_file_win(ae, "Test creating a regular file" - " with unusable characters in its file name"); - archive_entry_free(ae); - - /* A file with unusable characters in its directory name. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "d:i*r?e\"c<t>o|ry/file1"); - archive_entry_set_mode(ae, S_IFREG | 0755); - create_reg_file_win(ae, "Test creating a regular file" - " with unusable characters in its file name"); - archive_entry_free(ae); -#endif /* _WIN32 && !__CYGWIN__ */ -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c b/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c deleted file mode 100644 index 934aa08d578..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c +++ /dev/null @@ -1,219 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_hardlink.c 201247 2009-12-30 05:59:21Z kientzle $"); - -#if defined(_WIN32) && !defined(__CYGWIN__) -/* Execution bits, Group members bits and others bits do not work. */ -#define UMASK 0177 -#define E_MASK (~0177) -#else -#define UMASK 022 -#define E_MASK (~0) -#endif - -/* - * Exercise hardlink recreation. - * - * File permissions are chosen so that the authoritive entry - * has the correct permission and the non-authoritive versions - * are just writeable files. - */ -DEFINE_TEST(test_write_disk_hardlink) -{ -#if defined(__HAIKU__) - skipping("archive_write_disk_hardlink; hardlinks are not supported on bfs"); -#else - static const char data[]="abcdefghijklmnopqrstuvwxyz"; - struct archive *ad; - struct archive_entry *ae; - int r; - - /* Force the umask to something predictable. */ - assertUmask(UMASK); - - /* Write entries to disk. */ - assert((ad = archive_write_disk_new()) != NULL); - - /* - * First, use a tar-like approach; a regular file, then - * a separate "hardlink" entry. - */ - - /* Regular file. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link1a"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, sizeof(data)); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualInt(sizeof(data), - archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - archive_entry_free(ae); - - /* Link. Size of zero means this doesn't carry data. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link1b"); - archive_entry_set_mode(ae, S_IFREG | 0642); - archive_entry_set_size(ae, 0); - archive_entry_copy_hardlink(ae, "link1a"); - assertEqualIntA(ad, 0, r = archive_write_header(ad, ae)); - if (r >= ARCHIVE_WARN) { - assertEqualInt(ARCHIVE_WARN, - archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - } - archive_entry_free(ae); - - /* - * Repeat tar approach test, but use unset to mark the - * hardlink as having no data. - */ - - /* Regular file. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link2a"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, sizeof(data)); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualInt(sizeof(data), - archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - archive_entry_free(ae); - - /* Link. Unset size means this doesn't carry data. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link2b"); - archive_entry_set_mode(ae, S_IFREG | 0642); - archive_entry_unset_size(ae); - archive_entry_copy_hardlink(ae, "link2a"); - assertEqualIntA(ad, 0, r = archive_write_header(ad, ae)); - if (r >= ARCHIVE_WARN) { - assertEqualInt(ARCHIVE_WARN, - archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - } - archive_entry_free(ae); - - /* - * Second, try an old-cpio-like approach; a regular file, then - * another identical one (which has been marked hardlink). - */ - - /* Regular file. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link3a"); - archive_entry_set_mode(ae, S_IFREG | 0600); - archive_entry_set_size(ae, sizeof(data)); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); - assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - archive_entry_free(ae); - - /* Link. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link3b"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, sizeof(data)); - archive_entry_copy_hardlink(ae, "link3a"); - assertEqualIntA(ad, 0, r = archive_write_header(ad, ae)); - if (r > ARCHIVE_WARN) { - assertEqualInt(sizeof(data), - archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - } - archive_entry_free(ae); - - /* - * Finally, try a new-cpio-like approach, where the initial - * regular file is empty and the hardlink has the data. - */ - - /* Regular file. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link4a"); - archive_entry_set_mode(ae, S_IFREG | 0600); - archive_entry_set_size(ae, 0); - assertEqualIntA(ad, 0, archive_write_header(ad, ae)); -#if ARCHIVE_VERSION_NUMBER < 3000000 - assertEqualInt(ARCHIVE_WARN, archive_write_data(ad, data, 1)); -#else - assertEqualInt(-1, archive_write_data(ad, data, 1)); -#endif - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - archive_entry_free(ae); - - /* Link. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link4b"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, sizeof(data)); - archive_entry_copy_hardlink(ae, "link4a"); - assertEqualIntA(ad, 0, r = archive_write_header(ad, ae)); - if (r > ARCHIVE_FAILED) { - assertEqualInt(sizeof(data), - archive_write_data(ad, data, sizeof(data))); - assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); - } - archive_entry_free(ae); - assertEqualInt(0, archive_write_finish(ad)); - - /* Test the entries on disk. */ - - /* Test #1 */ - /* If the hardlink was successfully created and the archive - * doesn't carry data for it, we consider it to be - * non-authoritive for meta data as well. This is consistent - * with GNU tar and BSD pax. */ - assertIsReg("link1a", 0755 & ~UMASK); - assertFileSize("link1a", sizeof(data)); - assertFileNLinks("link1a", 2); - assertIsHardlink("link1a", "link1b"); - - /* Test #2: Should produce identical results to test #1 */ - /* Note that marking a hardlink with size = 0 is treated the - * same as having an unset size. This is partly for backwards - * compatibility (we used to not have unset tracking, so - * relied on size == 0) and partly to match the model used by - * common file formats that store a size of zero for - * hardlinks. */ - assertIsReg("link2a", 0755 & ~UMASK); - assertFileSize("link2a", sizeof(data)); - assertFileNLinks("link2a", 2); - assertIsHardlink("link2a", "link2b"); - - /* Test #3 */ - assertIsReg("link3a", 0755 & ~UMASK); - assertFileSize("link3a", sizeof(data)); - assertFileNLinks("link3a", 2); - assertIsHardlink("link3a", "link3b"); - - /* Test #4 */ - assertIsReg("link4a", 0755 & ~UMASK); - assertFileNLinks("link4a", 2); - assertFileSize("link4a", sizeof(data)); - assertIsHardlink("link4a", "link4b"); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c b/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c deleted file mode 100644 index 207444833e7..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c +++ /dev/null @@ -1,457 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_perms.c 201247 2009-12-30 05:59:21Z kientzle $"); - -#if ARCHIVE_VERSION_NUMBER >= 1009000 && (!defined(_WIN32) || defined(__CYGWIN__)) - -#define UMASK 022 - -static long _default_gid = -1; -static long _invalid_gid = -1; -static long _alt_gid = -1; - -/* - * To fully test SGID restores, we need three distinct GIDs to work - * with: - * * the GID that files are created with by default (for the - * current user in the current directory) - * * An "alt gid" that this user can create files with - * * An "invalid gid" that this user is not permitted to create - * files with. - * The second fails if this user doesn't belong to at least two groups; - * the third fails if the current user is root. - */ -static void -searchgid(void) -{ - static int _searched = 0; - uid_t uid = getuid(); - gid_t gid = 0; - unsigned int n; - struct stat st; - int fd; - - /* If we've already looked this up, we're done. */ - if (_searched) - return; - _searched = 1; - - /* Create a file on disk in the current default dir. */ - fd = open("test_gid", O_CREAT | O_BINARY, 0664); - failure("Couldn't create a file for gid testing."); - assert(fd > 0); - - /* See what GID it ended up with. This is our "valid" GID. */ - assert(fstat(fd, &st) == 0); - _default_gid = st.st_gid; - - /* Find a GID for which fchown() fails. This is our "invalid" GID. */ - _invalid_gid = -1; - /* This loop stops when we wrap the gid or examine 10,000 gids. */ - for (gid = 1, n = 1; gid == n && n < 10000 ; n++, gid++) { - if (fchown(fd, uid, gid) != 0) { - _invalid_gid = gid; - break; - } - } - - /* - * Find a GID for which fchown() succeeds, but which isn't the - * default. This is the "alternate" gid. - */ - _alt_gid = -1; - for (gid = 0, n = 0; gid == n && n < 10000 ; n++, gid++) { - /* _alt_gid must be different than _default_gid */ - if (gid == (gid_t)_default_gid) - continue; - if (fchown(fd, uid, gid) == 0) { - _alt_gid = gid; - break; - } - } - close(fd); -} - -static int -altgid(void) -{ - searchgid(); - return (_alt_gid); -} - -static int -invalidgid(void) -{ - searchgid(); - return (_invalid_gid); -} - -static int -defaultgid(void) -{ - searchgid(); - return (_default_gid); -} -#endif - -/* - * Exercise permission and ownership restores. - * In particular, try to exercise a bunch of border cases related - * to files/dirs that already exist, SUID/SGID bits, etc. - */ - -DEFINE_TEST(test_write_disk_perms) -{ -#if ARCHIVE_VERSION_NUMBER < 1009000 || (defined(_WIN32) && !defined(__CYGWIN__)) - skipping("archive_write_disk interface"); -#else - struct archive *a; - struct archive_entry *ae; - struct stat st; - - assertUmask(UMASK); - - /* - * Set ownership of the current directory to the group of this - * process. Otherwise, the SGID tests below fail if the - * /tmp directory is owned by a group to which we don't belong - * and we're on a system where group ownership is inherited. - * (Because we're not allowed to SGID files with defaultgid().) - */ - assertEqualInt(0, chown(".", getuid(), getgid())); - - /* Create an archive_write_disk object. */ - assert((a = archive_write_disk_new()) != NULL); - - /* Write a regular file to it. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file_0755"); - archive_entry_set_mode(ae, S_IFREG | 0777); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - archive_entry_free(ae); - - /* Write a regular file, then write over it. */ - /* For files, the perms should get updated. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file_overwrite_0144"); - archive_entry_set_mode(ae, S_IFREG | 0777); - assert(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assert(0 == archive_write_finish_entry(a)); - /* Check that file was created with different perms. */ - assert(0 == stat("file_overwrite_0144", &st)); - failure("file_overwrite_0144: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) != 0144); - /* Overwrite, this should change the perms. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file_overwrite_0144"); - archive_entry_set_mode(ae, S_IFREG | 0144); - assert(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assert(0 == archive_write_finish_entry(a)); - - /* Write a regular dir. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir_0514"); - archive_entry_set_mode(ae, S_IFDIR | 0514); - assert(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assert(0 == archive_write_finish_entry(a)); - - /* Overwrite an existing dir. */ - /* For dir, the first perms should get left. */ - assertMakeDir("dir_overwrite_0744", 0744); - /* Check original perms. */ - assert(0 == stat("dir_overwrite_0744", &st)); - failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 0777) == 0744); - /* Overwrite shouldn't edit perms. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir_overwrite_0744"); - archive_entry_set_mode(ae, S_IFDIR | 0777); - assert(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assert(0 == archive_write_finish_entry(a)); - /* Make sure they're unchanged. */ - assert(0 == stat("dir_overwrite_0744", &st)); - failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 0777) == 0744); - - /* Write a regular file with SUID bit, but don't use _EXTRACT_PERM. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "file_no_suid"); - archive_entry_set_mode(ae, S_IFREG | S_ISUID | 0777); - archive_write_disk_set_options(a, 0); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - - /* Write a regular file with ARCHIVE_EXTRACT_PERM. */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_0777"); - archive_entry_set_mode(ae, S_IFREG | 0777); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_PERM); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - - /* Write a regular file with ARCHIVE_EXTRACT_PERM & SUID bit */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_4742"); - archive_entry_set_mode(ae, S_IFREG | S_ISUID | 0742); - archive_entry_set_uid(ae, getuid()); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_PERM); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - - /* - * Write a regular file with ARCHIVE_EXTRACT_PERM & SUID bit, - * but wrong uid. POSIX says you shouldn't restore SUID bit - * unless the UID could be restored. - */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_bad_suid"); - archive_entry_set_mode(ae, S_IFREG | S_ISUID | 0742); - archive_entry_set_uid(ae, getuid() + 1); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_PERM); - assertA(0 == archive_write_header(a, ae)); - /* - * Because we didn't ask for owner, the failure to - * restore SUID shouldn't return a failure. - * We check below to make sure SUID really wasn't set. - * See more detailed comments below. - */ - failure("Opportunistic SUID failure shouldn't return error."); - assertEqualInt(0, archive_write_finish_entry(a)); - - if (getuid() != 0) { - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_bad_suid2"); - archive_entry_set_mode(ae, S_IFREG | S_ISUID | 0742); - archive_entry_set_uid(ae, getuid() + 1); - archive_write_disk_set_options(a, - ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_OWNER); - assertA(0 == archive_write_header(a, ae)); - /* Owner change should fail here. */ - failure("Non-opportunistic SUID failure should return error."); - assertEqualInt(ARCHIVE_WARN, archive_write_finish_entry(a)); - } - - /* Write a regular file with ARCHIVE_EXTRACT_PERM & SGID bit */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_perm_sgid"); - archive_entry_set_mode(ae, S_IFREG | S_ISGID | 0742); - archive_entry_set_gid(ae, defaultgid()); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_PERM); - assert(0 == archive_write_header(a, ae)); - failure("Setting SGID bit should succeed here."); - assertEqualIntA(a, 0, archive_write_finish_entry(a)); - - if (altgid() == -1) { - /* - * Current user must belong to at least two groups or - * else we can't test setting the GID to another group. - */ - skipping("Current user can't test gid restore: must belong to more than one group."); - } else { - /* - * Write a regular file with ARCHIVE_EXTRACT_PERM & SGID bit - * but without ARCHIVE_EXTRACT_OWNER. - */ - /* - * This is a weird case: The user has asked for permissions to - * be restored but not asked for ownership to be restored. As - * a result, the default file creation will create a file with - * the wrong group. There are several possible behaviors for - * libarchive in this scenario: - * = Set the SGID bit. It is wrong and a security hole to - * set SGID with the wrong group. Even POSIX thinks so. - * = Implicitly set the group. I don't like this. - * = drop the SGID bit and warn (the old libarchive behavior) - * = drop the SGID bit and don't warn (the current libarchive - * behavior). - * The current behavior sees SGID/SUID restore when you - * don't ask for owner restore as an "opportunistic" - * action. That is, libarchive should do it if it can, - * but if it can't, it's not an error. - */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_alt_sgid"); - archive_entry_set_mode(ae, S_IFREG | S_ISGID | 0742); - archive_entry_set_uid(ae, getuid()); - archive_entry_set_gid(ae, altgid()); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_PERM); - assert(0 == archive_write_header(a, ae)); - failure("Setting SGID bit should fail because of group mismatch but the failure should be silent because we didn't ask for the group to be set."); - assertEqualIntA(a, 0, archive_write_finish_entry(a)); - - /* - * As above, but add _EXTRACT_OWNER to verify that it - * does succeed. - */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_alt_sgid_owner"); - archive_entry_set_mode(ae, S_IFREG | S_ISGID | 0742); - archive_entry_set_uid(ae, getuid()); - archive_entry_set_gid(ae, altgid()); - archive_write_disk_set_options(a, - ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_OWNER); - assert(0 == archive_write_header(a, ae)); - failure("Setting SGID bit should succeed here."); - assertEqualIntA(a, ARCHIVE_OK, archive_write_finish_entry(a)); - } - - /* - * Write a regular file with ARCHIVE_EXTRACT_PERM & SGID bit, - * but wrong GID. POSIX says you shouldn't restore SGID bit - * unless the GID could be restored. - */ - if (invalidgid() == -1) { - /* This test always fails for root. */ - printf("Running as root: Can't test SGID failures.\n"); - } else { - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_bad_sgid"); - archive_entry_set_mode(ae, S_IFREG | S_ISGID | 0742); - archive_entry_set_gid(ae, invalidgid()); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_PERM); - assertA(0 == archive_write_header(a, ae)); - failure("This SGID restore should fail without an error."); - assertEqualIntA(a, 0, archive_write_finish_entry(a)); - - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_bad_sgid2"); - archive_entry_set_mode(ae, S_IFREG | S_ISGID | 0742); - archive_entry_set_gid(ae, invalidgid()); - archive_write_disk_set_options(a, - ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_OWNER); - assertA(0 == archive_write_header(a, ae)); - failure("This SGID restore should fail with an error."); - assertEqualIntA(a, ARCHIVE_WARN, archive_write_finish_entry(a)); - } - - /* Set ownership should fail if we're not root. */ - if (getuid() == 0) { - printf("Running as root: Can't test setuid failures.\n"); - } else { - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "file_bad_owner"); - archive_entry_set_mode(ae, S_IFREG | 0744); - archive_entry_set_uid(ae, getuid() + 1); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_OWNER); - assertA(0 == archive_write_header(a, ae)); - assertEqualIntA(a,ARCHIVE_WARN,archive_write_finish_entry(a)); - } - -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assert(0 == archive_write_finish(a)); -#endif - archive_entry_free(ae); - - /* Test the entries on disk. */ - assert(0 == stat("file_0755", &st)); - failure("file_0755: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0755); - - assert(0 == stat("file_overwrite_0144", &st)); - failure("file_overwrite_0144: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0144); - - assert(0 == stat("dir_0514", &st)); - failure("dir_0514: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0514); - - assert(0 == stat("dir_overwrite_0744", &st)); - failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 0777) == 0744); - - assert(0 == stat("file_no_suid", &st)); - failure("file_0755: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0755); - - assert(0 == stat("file_0777", &st)); - failure("file_0777: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0777); - - /* SUID bit should get set here. */ - assert(0 == stat("file_4742", &st)); - failure("file_4742: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (S_ISUID | 0742)); - - /* SUID bit should NOT have been set here. */ - assert(0 == stat("file_bad_suid", &st)); - failure("file_bad_suid: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (0742)); - - /* Some things don't fail if you're root, so suppress this. */ - if (getuid() != 0) { - /* SUID bit should NOT have been set here. */ - assert(0 == stat("file_bad_suid2", &st)); - failure("file_bad_suid2: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (0742)); - } - - /* SGID should be set here. */ - assert(0 == stat("file_perm_sgid", &st)); - failure("file_perm_sgid: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (S_ISGID | 0742)); - - if (altgid() != -1) { - /* SGID should not be set here. */ - assert(0 == stat("file_alt_sgid", &st)); - failure("file_alt_sgid: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (0742)); - - /* SGID should be set here. */ - assert(0 == stat("file_alt_sgid_owner", &st)); - failure("file_alt_sgid: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (S_ISGID | 0742)); - } - - if (invalidgid() != -1) { - /* SGID should NOT be set here. */ - assert(0 == stat("file_bad_sgid", &st)); - failure("file_bad_sgid: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (0742)); - /* SGID should NOT be set here. */ - assert(0 == stat("file_bad_sgid2", &st)); - failure("file_bad_sgid2: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (0742)); - } - - if (getuid() != 0) { - assert(0 == stat("file_bad_owner", &st)); - failure("file_bad_owner: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == (0744)); - failure("file_bad_owner: st.st_uid=%d getuid()=%d", - st.st_uid, getuid()); - /* The entry had getuid()+1, but because we're - * not root, we should not have been able to set that. */ - assert(st.st_uid == getuid()); - } -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c b/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c deleted file mode 100644 index c14dadccfa6..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_secure.c 201247 2009-12-30 05:59:21Z kientzle $"); - -#define UMASK 022 - -/* - * Exercise security checks that should prevent certain - * writes. - */ - -DEFINE_TEST(test_write_disk_secure) -{ -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("archive_write_disk interface"); -#elif !defined(_WIN32) || defined(__CYGWIN__) - struct archive *a; - struct archive_entry *ae; - struct stat st; - - /* Start with a known umask. */ - assertUmask(UMASK); - - /* Create an archive_write_disk object. */ - assert((a = archive_write_disk_new()) != NULL); - - /* Write a regular dir to it. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "dir"); - archive_entry_set_mode(ae, S_IFDIR | 0777); - assert(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assert(0 == archive_write_finish_entry(a)); - - /* Write a symlink to the dir above. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir"); - archive_entry_set_mode(ae, S_IFLNK | 0777); - archive_entry_set_symlink(ae, "dir"); - archive_write_disk_set_options(a, 0); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - - /* - * Without security checks, we should be able to - * extract a file through the link. - */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir/filea"); - archive_entry_set_mode(ae, S_IFREG | 0777); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - - /* But with security checks enabled, this should fail. */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir/fileb"); - archive_entry_set_mode(ae, S_IFREG | 0777); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS); - failure("Extracting a file through a symlink should fail here."); - assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae)); - archive_entry_free(ae); - assert(0 == archive_write_finish_entry(a)); - - /* Create another link. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir2"); - archive_entry_set_mode(ae, S_IFLNK | 0777); - archive_entry_set_symlink(ae, "dir"); - archive_write_disk_set_options(a, 0); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - - /* - * With symlink check and unlink option, it should remove - * the link and create the dir. - */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir2/filec"); - archive_entry_set_mode(ae, S_IFREG | 0777); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS | ARCHIVE_EXTRACT_UNLINK); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - archive_entry_free(ae); - assert(0 == archive_write_finish_entry(a)); - - /* - * Without security checks, extracting a dir over a link to a - * dir should follow the link. - */ - /* Create a symlink to a dir. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir3"); - archive_entry_set_mode(ae, S_IFLNK | 0777); - archive_entry_set_symlink(ae, "dir"); - archive_write_disk_set_options(a, 0); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - /* Extract a dir whose name matches the symlink. */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir3"); - archive_entry_set_mode(ae, S_IFDIR | 0777); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - /* Verify link was followed. */ - assertEqualInt(0, lstat("link_to_dir3", &st)); - assert(S_ISLNK(st.st_mode)); - archive_entry_free(ae); - - /* - * As above, but a broken link, so the link should get replaced. - */ - /* Create a symlink to a dir. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir4"); - archive_entry_set_mode(ae, S_IFLNK | 0777); - archive_entry_set_symlink(ae, "nonexistent_dir"); - archive_write_disk_set_options(a, 0); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - /* Extract a dir whose name matches the symlink. */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir4"); - archive_entry_set_mode(ae, S_IFDIR | 0777); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - /* Verify link was replaced. */ - assertEqualInt(0, lstat("link_to_dir4", &st)); - assert(S_ISDIR(st.st_mode)); - archive_entry_free(ae); - - /* - * As above, but a link to a non-dir, so the link should get replaced. - */ - /* Create a regular file and a symlink to it */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "non_dir"); - archive_entry_set_mode(ae, S_IFREG | 0777); - archive_write_disk_set_options(a, 0); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - /* Create symlink to the file. */ - archive_entry_copy_pathname(ae, "link_to_dir5"); - archive_entry_set_mode(ae, S_IFLNK | 0777); - archive_entry_set_symlink(ae, "non_dir"); - archive_write_disk_set_options(a, 0); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - /* Extract a dir whose name matches the symlink. */ - assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "link_to_dir5"); - archive_entry_set_mode(ae, S_IFDIR | 0777); - assert(0 == archive_write_header(a, ae)); - assert(0 == archive_write_finish_entry(a)); - /* Verify link was replaced. */ - assertEqualInt(0, lstat("link_to_dir5", &st)); - assert(S_ISDIR(st.st_mode)); - archive_entry_free(ae); - - assert(0 == archive_write_finish(a)); - - /* Test the entries on disk. */ - assert(0 == lstat("dir", &st)); - failure("dir: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 0777) == 0755); - - assert(0 == lstat("link_to_dir", &st)); - failure("link_to_dir: st.st_mode=%o", st.st_mode); - assert(S_ISLNK(st.st_mode)); -#if HAVE_LCHMOD - /* Systems that lack lchmod() can't set symlink perms, so skip this. */ - failure("link_to_dir: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0755); -#endif - - assert(0 == lstat("dir/filea", &st)); - failure("dir/filea: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0755); - - failure("dir/fileb: This file should not have been created"); - assert(0 != lstat("dir/fileb", &st)); - - assert(0 == lstat("link_to_dir2", &st)); - failure("link_to_dir2 should have been re-created as a true dir"); - assert(S_ISDIR(st.st_mode)); - failure("link_to_dir2: Implicit dir creation should obey umask, but st.st_mode=%o", st.st_mode); - assert((st.st_mode & 0777) == 0755); - - assert(0 == lstat("link_to_dir2/filec", &st)); - assert(S_ISREG(st.st_mode)); - failure("link_to_dir2/filec: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0755); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_ar.c b/archivers/libarchive/files/libarchive/test/test_write_format_ar.c deleted file mode 100644 index 5822b3f3817..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_ar.c +++ /dev/null @@ -1,209 +0,0 @@ -/*- - * Copyright (c) 2007 Kai Wang - * Copyright (c) 2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_ar.c 189308 2009-03-03 17:02:51Z kientzle $"); - -char buff[4096]; -char buff2[64]; -static char strtab[] = "abcdefghijklmn.o/\nggghhhjjjrrrttt.o/\niiijjjdddsssppp.o/\n"; - -DEFINE_TEST(test_write_format_ar) -{ -#if ARCHIVE_VERSION_NUMBER < 1009000 - skipping("ar write support"); -#else - struct archive_entry *ae; - struct archive* a; - size_t used; - - /* - * First we try to create a SVR4/GNU format archive. - */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_ar_svr4(a)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - - /* write the filename table */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "//"); - archive_entry_set_size(ae, strlen(strtab)); - assertA(0 == archive_write_header(a, ae)); - assertA(strlen(strtab) == (size_t)archive_write_data(a, strtab, strlen(strtab))); - archive_entry_free(ae); - - /* write entries */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_mtime(ae, 1, 0); - assert(1 == archive_entry_mtime(ae)); - archive_entry_set_mode(ae, S_IFREG | 0755); - assert((S_IFREG | 0755) == archive_entry_mode(ae)); - archive_entry_copy_pathname(ae, "abcdefghijklmn.o"); - archive_entry_set_size(ae, 8); - assertA(0 == archive_write_header(a, ae)); - assertA(8 == archive_write_data(a, "87654321", 15)); - archive_entry_free(ae); - - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "ggghhhjjjrrrttt.o"); - archive_entry_set_filetype(ae, AE_IFREG); - archive_entry_set_size(ae, 7); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - assertEqualIntA(a, 7, archive_write_data(a, "7777777", 7)); - archive_entry_free(ae); - - /* test full pathname */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "/usr/home/xx/iiijjjdddsssppp.o"); - archive_entry_set_mode(ae, S_IFREG | 0755); - archive_entry_set_size(ae, 8); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - assertEqualIntA(a, 8, archive_write_data(a, "88877766", 8)); - archive_entry_free(ae); - - /* trailing "/" should be rejected */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "/usr/home/xx/iiijjj/"); - archive_entry_set_size(ae, 8); - assertA(0 != archive_write_header(a, ae)); - archive_entry_free(ae); - - /* Non regular file should be rejected */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "gfgh.o"); - archive_entry_set_mode(ae, S_IFDIR | 0755); - archive_entry_set_size(ae, 6); - assertA(0 != archive_write_header(a, ae)); - archive_entry_free(ae); - - archive_write_close(a); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assertEqualInt(0, archive_write_finish(a)); -#endif - - /* - * Now, read the data back. - */ - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used)); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(0, archive_entry_mtime(ae)); - assertEqualString("//", archive_entry_pathname(ae)); - assertEqualInt(0, archive_entry_size(ae)); - - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(1, archive_entry_mtime(ae)); - assertEqualString("abcdefghijklmn.o", archive_entry_pathname(ae)); - assertEqualInt(8, archive_entry_size(ae)); - assertEqualIntA(a, 8, archive_read_data(a, buff2, 10)); - assertEqualMem(buff2, "87654321", 8); - - assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualString("ggghhhjjjrrrttt.o", archive_entry_pathname(ae)); - assertEqualInt(7, archive_entry_size(ae)); - assertEqualIntA(a, 7, archive_read_data(a, buff2, 11)); - assertEqualMem(buff2, "7777777", 7); - - assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); - assertEqualString("iiijjjdddsssppp.o", archive_entry_pathname(ae)); - assertEqualInt(8, archive_entry_size(ae)); - assertEqualIntA(a, 8, archive_read_data(a, buff2, 17)); - assertEqualMem(buff2, "88877766", 8); - - assertEqualIntA(a, 0, archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(0, archive_read_finish(a)); -#endif - - /* - * Then, we try to create a BSD format archive. - */ - 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_open_memory(a, buff, sizeof(buff), &used)); - - /* write a entry need long name extension */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "ttttyyyyuuuuiiii.o"); - archive_entry_set_filetype(ae, AE_IFREG); - archive_entry_set_size(ae, 5); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - assertEqualInt(5, archive_entry_size(ae)); - assertEqualIntA(a, 5, archive_write_data(a, "12345", 7)); - archive_entry_free(ae); - - /* write a entry with a short name */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "ttyy.o"); - archive_entry_set_filetype(ae, AE_IFREG); - archive_entry_set_size(ae, 6); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - assertEqualIntA(a, 6, archive_write_data(a, "555555", 7)); - archive_entry_free(ae); - archive_write_close(a); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assertEqualInt(0, archive_write_finish(a)); -#endif - - /* Now, Read the data back */ - assert((a = archive_read_new()) != NULL); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used)); - - assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); - assertEqualString("ttttyyyyuuuuiiii.o", archive_entry_pathname(ae)); - assertEqualInt(5, archive_entry_size(ae)); - assertEqualIntA(a, 5, archive_read_data(a, buff2, 10)); - assertEqualMem(buff2, "12345", 5); - - assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); - assertEqualString("ttyy.o", archive_entry_pathname(ae)); - assertEqualInt(6, archive_entry_size(ae)); - assertEqualIntA(a, 6, archive_read_data(a, buff2, 10)); - assertEqualMem(buff2, "555555", 6); - - /* Test EOF */ - assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - assertEqualIntA(a, 0, archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assertEqualInt(0, archive_read_finish(a)); -#endif -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_cpio.c b/archivers/libarchive/files/libarchive/test/test_write_format_cpio.c deleted file mode 100644 index 7bf2a41a528..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_cpio.c +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio.c 185672 2008-12-06 06:02:26Z kientzle $"); - -/* The version stamp macro was introduced after cpio write support. */ -#if ARCHIVE_VERSION_NUMBER >= 1009000 -static void -test_format(int (*set_format)(struct archive *)) -{ - char filedata[64]; - struct archive_entry *ae; - struct archive *a; - char *p; - size_t used; - size_t buffsize = 1000000; - char *buff; - int damaged = 0; - - buff = malloc(buffsize); - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == (*set_format)(a)); - assertA(0 == archive_write_set_compression_none(a)); - assertA(0 == archive_write_open_memory(a, buff, buffsize, &used)); - - /* - * Write a file to it. - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_mtime(ae, 1, 10); - assert(1 == archive_entry_mtime(ae)); - assert(10 == archive_entry_mtime_nsec(ae)); - p = strdup("file"); - archive_entry_copy_pathname(ae, p); - strcpy(p, "XXXX"); - free(p); - assertEqualString("file", archive_entry_pathname(ae)); - archive_entry_set_mode(ae, S_IFREG | 0755); - assert((S_IFREG | 0755) == archive_entry_mode(ae)); - archive_entry_set_size(ae, 8); - - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA(8 == archive_write_data(a, "12345678", 9)); - - /* - * Write another file to it. - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_mtime(ae, 1, 10); - assert(1 == archive_entry_mtime(ae)); - assert(10 == archive_entry_mtime_nsec(ae)); - p = strdup("file2"); - archive_entry_copy_pathname(ae, p); - strcpy(p, "XXXX"); - free(p); - assertEqualString("file2", archive_entry_pathname(ae)); - archive_entry_set_mode(ae, S_IFREG | 0755); - assert((S_IFREG | 0755) == archive_entry_mode(ae)); - archive_entry_set_size(ae, 4); - - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA(4 == archive_write_data(a, "1234", 5)); - - /* - * Write a directory to it. - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_mtime(ae, 11, 110); - archive_entry_copy_pathname(ae, "dir"); - archive_entry_set_mode(ae, S_IFDIR | 0755); - archive_entry_set_size(ae, 512); - - assertA(0 == archive_write_header(a, ae)); - assertEqualInt(0, archive_entry_size(ae)); - archive_entry_free(ae); - assertEqualIntA(a, 0, archive_write_data(a, "12345678", 9)); - - - /* 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 - - /* - * Damage the second entry to test the search-ahead recovery. - * TODO: Move the damage-recovery checking to a separate test; - * it doesn't really belong in this write test. - */ - { - int i; - for (i = 80; i < 150; i++) { - if (memcmp(buff + i, "07070", 5) == 0) { - damaged = 1; - buff[i] = 'X'; - break; - } - } - } - failure("Unable to locate the second header for damage-recovery test."); - assert(damaged == 1); - - /* - * Now, read the data back. - */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used)); - - if (!assertEqualIntA(a, 0, archive_read_next_header(a, &ae))) { - archive_read_finish(a); - return; - } - - assertEqualInt(1, archive_entry_mtime(ae)); - /* Not the same as above: cpio doesn't store hi-res times. */ - assert(0 == archive_entry_mtime_nsec(ae)); - assert(0 == archive_entry_atime(ae)); - assert(0 == archive_entry_ctime(ae)); - assertEqualString("file", archive_entry_pathname(ae)); - assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae)); - assertEqualInt(8, archive_entry_size(ae)); - assertA(8 == archive_read_data(a, filedata, 10)); - assert(0 == memcmp(filedata, "12345678", 8)); - - /* - * The second file can't be read because we damaged its header. - */ - - /* - * Read the dir entry back. - * ARCHIVE_WARN here because the damaged entry was skipped. - */ - assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); - assertEqualInt(11, archive_entry_mtime(ae)); - assert(0 == archive_entry_mtime_nsec(ae)); - assert(0 == archive_entry_atime(ae)); - assert(0 == archive_entry_ctime(ae)); - assertEqualString("dir", archive_entry_pathname(ae)); - assertEqualInt((S_IFDIR | 0755), archive_entry_mode(ae)); - assertEqualInt(0, archive_entry_size(ae)); - assertEqualIntA(a, 0, archive_read_data(a, filedata, 10)); - - /* Verify the end of the archive. */ - assertEqualIntA(a, 1, archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - - free(buff); -} -#endif - -DEFINE_TEST(test_write_format_cpio) -{ -#if ARCHIVE_VERSION_NUMBER >= 1009000 - test_format(archive_write_set_format_cpio); - test_format(archive_write_set_format_cpio_newc); -#else - skipping("cpio write support"); -#endif -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_empty.c b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_empty.c deleted file mode 100644 index 131ac24617d..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_empty.c +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio_empty.c 201247 2009-12-30 05:59:21Z kientzle $"); - -/* - * Check that an "empty" cpio archive is correctly created. - */ - -/* Here's what an empty cpio archive should look like. */ -static char ref[] = -"070707" /* Magic number */ -"000000" /* Dev = 0 */ -"000000" /* ino = 0 */ -"000000" /* mode = 0 */ -"000000" /* uid = 0 */ -"000000" /* gid = 0 */ -"000001" /* nlink = 1 */ -"000000" /* rdev = 0 */ -"00000000000" /* mtime = 0 */ -"000013" /* Namesize = 11 */ -"00000000000" /* filesize = 0 */ -"TRAILER!!!\0"; /* Name */ - -DEFINE_TEST(test_write_format_cpio_empty) -{ - struct archive *a; - char buff[2048]; - size_t used; - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_cpio(a)); - assertA(0 == archive_write_set_compression_none(a)); - /* 1-byte block size ensures we see only the required bytes. */ - /* We're not testing the padding here. */ - assertA(0 == archive_write_set_bytes_per_block(a, 1)); - assertA(0 == archive_write_set_bytes_in_last_block(a, 1)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - - /* 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 - - failure("Empty cpio archive should be exactly 87 bytes, was %d.", used); - assert(used == 87); - failure("Empty cpio archive is incorrectly formatted."); - assertEqualMem(buff, ref, 87); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_newc.c b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_newc.c deleted file mode 100644 index 1c3c330b0e9..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_newc.c +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio_newc.c 201247 2009-12-30 05:59:21Z kientzle $"); - - -static int -is_hex(const char *p, size_t l) -{ - while (l > 0) { - if (*p >= 0 && *p <= '9') { - /* Ascii digit */ - } else if (*p >= 'a' && *p <= 'f') { - /* lowercase letter a-f */ - } else { - /* Not hex. */ - return (0); - } - --l; - ++p; - } - return (1); -} - -/* - * Detailed verification that cpio 'newc' archives are written with - * the correct format. - */ -DEFINE_TEST(test_write_format_cpio_newc) -{ - struct archive *a; - struct archive_entry *entry; - char *buff, *e, *file; - size_t buffsize = 100000; - size_t used; - - buff = malloc(buffsize); - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, 0, archive_write_set_format_cpio_newc(a)); - assertEqualIntA(a, 0, archive_write_set_compression_none(a)); - assertEqualIntA(a, 0, archive_write_open_memory(a, buff, buffsize, &used)); - - /* - * Add various files to it. - * TODO: Extend this to cover more filetypes. - */ - - /* Regular file */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 1, 10); - archive_entry_set_pathname(entry, "file"); - archive_entry_set_mode(entry, S_IFREG | 0664); - archive_entry_set_size(entry, 10); - archive_entry_set_uid(entry, 80); - archive_entry_set_gid(entry, 90); - archive_entry_set_dev(entry, 12); - archive_entry_set_ino(entry, 89); - archive_entry_set_nlink(entry, 1); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10)); - - /* Directory */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 2, 20); - archive_entry_set_pathname(entry, "dir"); - archive_entry_set_mode(entry, S_IFDIR | 0775); - archive_entry_set_size(entry, 10); - archive_entry_set_nlink(entry, 2); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10)); - - /* Symlink */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 3, 30); - archive_entry_set_pathname(entry, "lnk"); - archive_entry_set_mode(entry, 0664); - archive_entry_set_filetype(entry, AE_IFLNK); - archive_entry_set_size(entry, 0); - archive_entry_set_uid(entry, 83); - archive_entry_set_gid(entry, 93); - archive_entry_set_dev(entry, 13); - archive_entry_set_ino(entry, 88); - archive_entry_set_nlink(entry, 1); - archive_entry_set_symlink(entry,"a"); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - - -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assert(0 == archive_write_finish(a)); -#endif - - /* - * Verify the archive format. - */ - e = buff; - - /* First entry is "file" */ - file = e; - assert(is_hex(e, 110)); /* Entire header is hex digits. */ - assertEqualMem(e + 0, "070701", 6); /* Magic */ - assert(memcmp(e + 6, "00000000", 8) != 0); /* ino != 0 */ - assertEqualMem(e + 14, "000081b4", 8); /* Mode */ - assertEqualMem(e + 22, "00000050", 8); /* uid */ - assertEqualMem(e + 30, "0000005a", 8); /* gid */ - assertEqualMem(e + 38, "00000001", 8); /* nlink */ - assertEqualMem(e + 46, "00000001", 8); /* mtime */ - assertEqualMem(e + 54, "0000000a", 8); /* File size */ - assertEqualMem(e + 62, "00000000", 8); /* devmajor */ - assertEqualMem(e + 70, "0000000c", 8); /* devminor */ - assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */ - assertEqualMem(e + 86, "00000000", 8); /* rdevminor */ - assertEqualMem(e + 94, "00000005", 8); /* Name size */ - assertEqualMem(e + 102, "00000000", 8); /* CRC */ - assertEqualMem(e + 110, "file\0\0", 6); /* Name contents */ - assertEqualMem(e + 116, "1234567890", 10); /* File body */ - assertEqualMem(e + 126, "\0\0", 2); /* Pad to multiple of 4 */ - e += 128; /* Must be multiple of four here! */ - - /* Second entry is "dir" */ - assert(is_hex(e, 110)); - assertEqualMem(e + 0, "070701", 6); /* Magic */ - assertEqualMem(e + 6, "00000000", 8); /* ino */ - assertEqualMem(e + 14, "000041fd", 8); /* Mode */ - assertEqualMem(e + 22, "00000000", 8); /* uid */ - assertEqualMem(e + 30, "00000000", 8); /* gid */ - assertEqualMem(e + 38, "00000002", 8); /* nlink */ - assertEqualMem(e + 46, "00000002", 8); /* mtime */ - assertEqualMem(e + 54, "00000000", 8); /* File size */ - assertEqualMem(e + 62, "00000000", 8); /* devmajor */ - assertEqualMem(e + 70, "00000000", 8); /* devminor */ - assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */ - assertEqualMem(e + 86, "00000000", 8); /* rdevminor */ - assertEqualMem(e + 94, "00000004", 8); /* Name size */ - assertEqualMem(e + 102, "00000000", 8); /* CRC */ - assertEqualMem(e + 110, "dir\0", 4); /* name */ - assertEqualMem(e + 114, "\0\0", 2); /* Pad to multiple of 4 */ - e += 116; /* Must be multiple of four here! */ - - /* Third entry is "lnk" */ - assert(is_hex(e, 110)); /* Entire header is hex digits. */ - assertEqualMem(e + 0, "070701", 6); /* Magic */ - assert(memcmp(e + 6, file + 6, 8) != 0); /* ino != file ino */ - assert(memcmp(e + 6, "00000000", 8) != 0); /* ino != 0 */ - assertEqualMem(e + 14, "0000a1b4", 8); /* Mode */ - assertEqualMem(e + 22, "00000053", 8); /* uid */ - assertEqualMem(e + 30, "0000005d", 8); /* gid */ - assertEqualMem(e + 38, "00000001", 8); /* nlink */ - assertEqualMem(e + 46, "00000003", 8); /* mtime */ - assertEqualMem(e + 54, "00000001", 8); /* File size */ - assertEqualMem(e + 62, "00000000", 8); /* devmajor */ - assertEqualMem(e + 70, "0000000d", 8); /* devminor */ - assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */ - assertEqualMem(e + 86, "00000000", 8); /* rdevminor */ - assertEqualMem(e + 94, "00000004", 8); /* Name size */ - assertEqualMem(e + 102, "00000000", 8); /* CRC */ - assertEqualMem(e + 110, "lnk\0\0\0", 6); /* Name contents */ - assertEqualMem(e + 116, "a\0\0\0", 4); /* File body + pad */ - e += 120; /* Must be multiple of four here! */ - - /* TODO: Verify other types of entries. */ - - /* Last entry is end-of-archive marker. */ - assert(is_hex(e, 76)); - assertEqualMem(e + 0, "070701", 6); /* Magic */ - assertEqualMem(e + 6, "00000000", 8); /* ino */ - assertEqualMem(e + 14, "00000000", 8); /* Mode */ - assertEqualMem(e + 22, "00000000", 8); /* uid */ - assertEqualMem(e + 30, "00000000", 8); /* gid */ - assertEqualMem(e + 38, "00000001", 8); /* nlink */ - assertEqualMem(e + 46, "00000000", 8); /* mtime */ - assertEqualMem(e + 54, "00000000", 8); /* File size */ - assertEqualMem(e + 62, "00000000", 8); /* devmajor */ - assertEqualMem(e + 70, "00000000", 8); /* devminor */ - assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */ - assertEqualMem(e + 86, "00000000", 8); /* rdevminor */ - assertEqualMem(e + 94, "0000000b", 8); /* Name size */ - assertEqualMem(e + 102, "00000000", 8); /* CRC */ - assertEqualMem(e + 110, "TRAILER!!!\0", 11); /* Name */ - assertEqualMem(e + 121, "\0\0\0", 3); /* Pad to multiple of 4 bytes */ - e += 124; /* Must be multiple of four here! */ - - assertEqualInt((int)used, e - buff); - - free(buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_odc.c b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_odc.c deleted file mode 100644 index e2136f87cfb..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_odc.c +++ /dev/null @@ -1,241 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio_odc.c 201247 2009-12-30 05:59:21Z kientzle $"); - - -static int -is_octal(const char *p, size_t l) -{ - while (l > 0) { - if (*p < '0' || *p > '7') - return (0); - --l; - ++p; - } - return (1); -} - -/* - * Detailed verification that cpio 'odc' archives are written with - * the correct format. - */ -DEFINE_TEST(test_write_format_cpio_odc) -{ - struct archive *a; - struct archive_entry *entry; - char *buff, *e, *file; - size_t buffsize = 100000; - size_t used; - - buff = malloc(buffsize); - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, 0, archive_write_set_format_cpio(a)); - assertEqualIntA(a, 0, archive_write_set_compression_none(a)); - assertEqualIntA(a, 0, archive_write_open_memory(a, buff, buffsize, &used)); - - /* - * Add various files to it. - * TODO: Extend this to cover more filetypes. - */ - - /* "file" with 10 bytes of content */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 1, 10); - archive_entry_set_pathname(entry, "file"); - archive_entry_set_mode(entry, S_IFREG | 0664); - archive_entry_set_size(entry, 10); - archive_entry_set_uid(entry, 80); - archive_entry_set_gid(entry, 90); - archive_entry_set_dev(entry, 12); - archive_entry_set_ino(entry, 89); - archive_entry_set_nlink(entry, 2); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10)); - - /* Hardlink to "file" with 10 bytes of content */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 1, 10); - archive_entry_set_pathname(entry, "linkfile"); - archive_entry_set_mode(entry, S_IFREG | 0664); - archive_entry_set_size(entry, 10); - archive_entry_set_uid(entry, 80); - archive_entry_set_gid(entry, 90); - archive_entry_set_dev(entry, 12); - archive_entry_set_ino(entry, 89); - archive_entry_set_nlink(entry, 2); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10)); - - /* "dir" */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 2, 20); - archive_entry_set_pathname(entry, "dir"); - archive_entry_set_mode(entry, S_IFDIR | 0775); - archive_entry_set_size(entry, 10); - archive_entry_set_nlink(entry, 2); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - /* Write of data to dir should fail == zero bytes get written. */ - assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10)); - - /* "symlink" pointing to "file" */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 3, 30); - archive_entry_set_pathname(entry, "symlink"); - archive_entry_set_mode(entry, 0664); - archive_entry_set_filetype(entry, AE_IFLNK); - archive_entry_set_symlink(entry,"file"); - archive_entry_set_size(entry, 0); - archive_entry_set_uid(entry, 88); - archive_entry_set_gid(entry, 98); - archive_entry_set_dev(entry, 12); - archive_entry_set_ino(entry, 90); - archive_entry_set_nlink(entry, 1); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - /* Write of data to symlink should fail == zero bytes get written. */ - assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10)); - -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assert(0 == archive_write_finish(a)); -#endif - - /* - * Verify the archive format. - * - * Notes on the ino validation: cpio does not actually require - * that the ino values written to the archive match those read - * from disk. It really requires that: - * * matching non-zero ino values be written as matching - * non-zero values - * * non-matching non-zero ino values be written as non-matching - * non-zero values - * Libarchive further ensures that zero ino values get written - * as zeroes. This allows the cpio writer to generate - * synthetic ino values for the archive that may be different - * than those on disk in order to avoid problems due to truncation. - * This is especially needed for odc (POSIX format) that - * only supports 18-bit ino values. - */ - e = buff; - - /* "file" */ - file = e; /* Remember where this starts... */ - assert(is_octal(e, 76)); /* Entire header is octal digits. */ - assertEqualMem(e + 0, "070707", 6); /* Magic */ - assertEqualMem(e + 6, "000014", 6); /* dev */ - assert(memcmp(e + 12, "000000", 6) != 0); /* ino must be != 0 */ - assertEqualMem(e + 18, "100664", 6); /* Mode */ - assertEqualMem(e + 24, "000120", 6); /* uid */ - assertEqualMem(e + 30, "000132", 6); /* gid */ - assertEqualMem(e + 36, "000002", 6); /* nlink */ - assertEqualMem(e + 42, "000000", 6); /* rdev */ - assertEqualMem(e + 48, "00000000001", 11); /* mtime */ - assertEqualMem(e + 59, "000005", 6); /* Name size */ - assertEqualMem(e + 65, "00000000012", 11); /* File size */ - assertEqualMem(e + 76, "file\0", 5); /* Name contents */ - assertEqualMem(e + 81, "1234567890", 10); /* File contents */ - e += 91; - - /* hardlink to "file" */ - assert(is_octal(e, 76)); /* Entire header is octal digits. */ - assertEqualMem(e + 0, "070707", 6); /* Magic */ - assertEqualMem(e + 6, "000014", 6); /* dev */ - assertEqualMem(e + 12, file + 12, 6); /* ino must match above */ - assertEqualMem(e + 18, "100664", 6); /* Mode */ - assertEqualMem(e + 24, "000120", 6); /* uid */ - assertEqualMem(e + 30, "000132", 6); /* gid */ - assertEqualMem(e + 36, "000002", 6); /* nlink */ - assertEqualMem(e + 42, "000000", 6); /* rdev */ - assertEqualMem(e + 48, "00000000001", 11); /* mtime */ - assertEqualMem(e + 59, "000011", 6); /* Name size */ - assertEqualMem(e + 65, "00000000012", 11); /* File size */ - assertEqualMem(e + 76, "linkfile\0", 9); /* Name contents */ - assertEqualMem(e + 85, "1234567890", 10); /* File contents */ - e += 95; - - /* "dir" */ - assert(is_octal(e, 76)); - assertEqualMem(e + 0, "070707", 6); /* Magic */ - assertEqualMem(e + 6, "000000", 6); /* dev */ - assertEqualMem(e + 12, "000000", 6); /* ino */ - assertEqualMem(e + 18, "040775", 6); /* Mode */ - assertEqualMem(e + 24, "000000", 6); /* uid */ - assertEqualMem(e + 30, "000000", 6); /* gid */ - assertEqualMem(e + 36, "000002", 6); /* Nlink */ - assertEqualMem(e + 42, "000000", 6); /* rdev */ - assertEqualMem(e + 48, "00000000002", 11); /* mtime */ - assertEqualMem(e + 59, "000004", 6); /* Name size */ - assertEqualMem(e + 65, "00000000000", 11); /* File size */ - assertEqualMem(e + 76, "dir\0", 4); /* name */ - e += 80; - - /* "symlink" pointing to "file" */ - assert(is_octal(e, 76)); /* Entire header is octal digits. */ - assertEqualMem(e + 0, "070707", 6); /* Magic */ - assertEqualMem(e + 6, "000014", 6); /* dev */ - assert(memcmp(e + 12, file + 12, 6) != 0); /* ino must != file ino */ - assert(memcmp(e + 12, "000000", 6) != 0); /* ino must != 0 */ - assertEqualMem(e + 18, "120664", 6); /* Mode */ - assertEqualMem(e + 24, "000130", 6); /* uid */ - assertEqualMem(e + 30, "000142", 6); /* gid */ - assertEqualMem(e + 36, "000001", 6); /* nlink */ - assertEqualMem(e + 42, "000000", 6); /* rdev */ - assertEqualMem(e + 48, "00000000003", 11); /* mtime */ - assertEqualMem(e + 59, "000010", 6); /* Name size */ - assertEqualMem(e + 65, "00000000004", 11); /* File size */ - assertEqualMem(e + 76, "symlink\0", 8); /* Name contents */ - assertEqualMem(e + 84, "file", 4); /* File contents == link target */ - e += 88; - - /* TODO: Verify other types of entries. */ - - /* Last entry is end-of-archive marker. */ - assert(is_octal(e, 76)); - assertEqualMem(e + 0, "070707", 6); /* Magic */ - assertEqualMem(e + 6, "000000", 6); /* dev */ - assertEqualMem(e + 12, "000000", 6); /* ino */ - assertEqualMem(e + 18, "000000", 6); /* Mode */ - assertEqualMem(e + 24, "000000", 6); /* uid */ - assertEqualMem(e + 30, "000000", 6); /* gid */ - assertEqualMem(e + 36, "000001", 6); /* Nlink */ - assertEqualMem(e + 42, "000000", 6); /* rdev */ - assertEqualMem(e + 48, "00000000000", 11); /* mtime */ - assertEqualMem(e + 59, "000013", 6); /* Name size */ - assertEqualMem(e + 65, "00000000000", 11); /* File size */ - assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */ - e += 87; - - assertEqualInt((int)used, e - buff); - - free(buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_shar_empty.c b/archivers/libarchive/files/libarchive/test/test_write_format_shar_empty.c deleted file mode 100644 index 14ee3889a36..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_shar_empty.c +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_shar_empty.c,v 1.3 2008/09/01 05:38:33 kientzle Exp $"); - -/* - * Check that an "empty" shar archive is correctly created as an empty file. - */ - -DEFINE_TEST(test_write_format_shar_empty) -{ - struct archive *a; - char buff[2048]; - size_t used; - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_shar(a)); - assertA(0 == archive_write_set_compression_none(a)); - /* 1-byte block size ensures we see only the required bytes. */ - /* We're not testing the padding here. */ - assertA(0 == archive_write_set_bytes_per_block(a, 1)); - assertA(0 == archive_write_set_bytes_in_last_block(a, 1)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - - /* 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 - - failure("Empty shar archive should be exactly 0 bytes, was %d.", used); - assert(used == 0); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_tar.c b/archivers/libarchive/files/libarchive/test/test_write_format_tar.c deleted file mode 100644 index 372fef1f023..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_tar.c +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_tar.c 189308 2009-03-03 17:02:51Z kientzle $"); - -char buff[1000000]; -char buff2[64]; - -DEFINE_TEST(test_write_format_tar) -{ - struct archive_entry *ae; - struct archive *a; - char *p; - size_t used; - size_t blocksize; - - /* Repeat the following for a variety of odd blocksizes. */ - for (blocksize = 1; blocksize < 100000; blocksize += blocksize + 3) { - /* 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_none(a)); - 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)); - - /* - * Write a file to it. - */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_mtime(ae, 1, 10); - assert(1 == archive_entry_mtime(ae)); -#if !defined(__INTERIX) - assert(10 == archive_entry_mtime_nsec(ae)); -#endif - p = strdup("file"); - archive_entry_copy_pathname(ae, p); - strcpy(p, "XXXX"); - free(p); - assertEqualString("file", archive_entry_pathname(ae)); - archive_entry_set_mode(ae, S_IFREG | 0755); - assert((S_IFREG | 0755) == archive_entry_mode(ae)); - archive_entry_set_size(ae, 8); - - assertA(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - assertA(8 == archive_write_data(a, "12345678", 9)); - - /* 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 - /* This calculation gives "the smallest multiple of - * the block size that is at least 2048 bytes". */ - assert(((2048 - 1)/blocksize+1)*blocksize == used); - - /* - * Now, read the data back. - */ - assert((a = archive_read_new()) != NULL); - assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == archive_read_open_memory(a, buff, used)); - - assertA(0 == archive_read_next_header(a, &ae)); - - assert(1 == archive_entry_mtime(ae)); - /* Not the same as above: ustar doesn't store hi-res times. */ - assert(0 == archive_entry_mtime_nsec(ae)); - assert(0 == archive_entry_atime(ae)); - assert(0 == archive_entry_ctime(ae)); - assertEqualString("file", archive_entry_pathname(ae)); - assert((S_IFREG | 0755) == archive_entry_mode(ae)); - assert(8 == archive_entry_size(ae)); - assertA(8 == archive_read_data(a, buff2, 10)); - assert(0 == memcmp(buff2, "12345678", 8)); - - /* Verify the end of the archive. */ - assert(1 == archive_read_next_header(a, &ae)); - assert(0 == archive_read_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_read_finish(a); -#else - assert(0 == archive_read_finish(a)); -#endif - } -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_tar_empty.c b/archivers/libarchive/files/libarchive/test/test_write_format_tar_empty.c deleted file mode 100644 index 6b40f0767f3..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_tar_empty.c +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_tar_empty.c 189308 2009-03-03 17:02:51Z kientzle $"); - -/* - * Check that an "empty" tar archive is correctly created. - */ - -DEFINE_TEST(test_write_format_tar_empty) -{ - struct archive *a; - char buff[2048]; - size_t used; - unsigned int i; - - /* USTAR format: 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_none(a)); - assertA(0 == archive_write_set_bytes_per_block(a, 512)); - assertA(0 == archive_write_set_bytes_in_last_block(a, 512)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - - /* 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 - -#if ARCHIVE_VERSION_NUMBER < 1009000 - /* Earlier versions wrote 0-length files for empty tar archives. */ - skipping("empty tar archive size"); -#else - assert(used == 1024); -#endif - for (i = 0; i < used; i++) { - failure("Empty tar archive should be all nulls."); - assert(buff[i] == 0); - } - - /* PAX format: Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertA(0 == archive_write_set_format_pax(a)); - assertA(0 == archive_write_set_compression_none(a)); - assertA(0 == archive_write_set_bytes_per_block(a, 512)); - assertA(0 == archive_write_set_bytes_in_last_block(a, 512)); - assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); - - /* 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 - -#if ARCHIVE_VERSION_NUMBER < 1009000 - /* Earlier versions wrote 0-length files for empty tar archives. */ - skipping("empty tar archive size"); -#else - assertEqualInt((int)used, 1024); -#endif - for (i = 0; i < used; i++) { - failure("Empty tar archive should be all nulls."); - assert(buff[i] == 0); - } -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_tar_ustar.c b/archivers/libarchive/files/libarchive/test/test_write_format_tar_ustar.c deleted file mode 100644 index 29968dfb331..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_format_tar_ustar.c +++ /dev/null @@ -1,347 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_tar_ustar.c 201247 2009-12-30 05:59:21Z kientzle $"); - -static int -is_null(const char *p, size_t l) -{ - while (l > 0) { - if (*p != '\0') - return (0); - --l; - ++p; - } - return (1); -} - -/* Verify the contents, then erase them to NUL bytes. */ -/* Tar requires all "unused" bytes be set to NUL; this allows us - * to easily verify that by invoking is_null() over the entire header - * after verifying each field. */ -#define myAssertEqualMem(a,b,s) assertEqualMem(a, b, s); memset(a, 0, s) - -/* - * Detailed verification that 'ustar' archives are written with - * the correct format. - */ -DEFINE_TEST(test_write_format_tar_ustar) -{ - struct archive *a; - struct archive_entry *entry; - char *buff, *e; - size_t buffsize = 100000; - size_t used; - int i; - char f99[100]; - char f100[101]; - char f256[257]; - - for (i = 0; i < 99; ++i) - f99[i] = 'a' + i % 26; - f99[99] = '\0'; - - for (i = 0; i < 100; ++i) - f100[i] = 'A' + i % 26; - f100[100] = '\0'; - - for (i = 0; i < 256; ++i) - f256[i] = 'A' + i % 26; - f256[155] = '/'; - f256[256] = '\0'; - - buff = malloc(buffsize); - - /* Create a new archive in memory. */ - assert((a = archive_write_new()) != NULL); - assertEqualIntA(a, 0, archive_write_set_format_ustar(a)); - assertEqualIntA(a, 0, archive_write_set_compression_none(a)); - assertEqualIntA(a, 0, archive_write_open_memory(a, buff, buffsize, &used)); - - /* - * Add various files to it. - * TODO: Extend this to cover more filetypes. - */ - - /* "file" with 10 bytes of content */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 1, 10); - archive_entry_set_pathname(entry, "file"); - archive_entry_set_mode(entry, S_IFREG | 0664); - archive_entry_set_size(entry, 10); - archive_entry_set_uid(entry, 80); - archive_entry_set_gid(entry, 90); - archive_entry_set_dev(entry, 12); - archive_entry_set_ino(entry, 89); - archive_entry_set_nlink(entry, 2); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10)); - - /* Hardlink to "file" with 10 bytes of content */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 1, 10); - archive_entry_set_pathname(entry, "linkfile"); - archive_entry_set_mode(entry, S_IFREG | 0664); - /* TODO: Put this back and fix the bug. */ - /* archive_entry_set_size(entry, 10); */ - archive_entry_set_uid(entry, 80); - archive_entry_set_gid(entry, 90); - archive_entry_set_dev(entry, 12); - archive_entry_set_ino(entry, 89); - archive_entry_set_nlink(entry, 2); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - /* Write of data to dir should fail == zero bytes get written. */ - assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10)); - - /* "dir" */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 2, 20); - archive_entry_set_pathname(entry, "dir"); - archive_entry_set_mode(entry, S_IFDIR | 0775); - archive_entry_set_size(entry, 10); - archive_entry_set_nlink(entry, 2); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - /* Write of data to dir should fail == zero bytes get written. */ - assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10)); - - /* "symlink" pointing to "file" */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 3, 30); - archive_entry_set_pathname(entry, "symlink"); - archive_entry_set_mode(entry, 0664); - archive_entry_set_filetype(entry, AE_IFLNK); - archive_entry_set_symlink(entry,"file"); - archive_entry_set_size(entry, 0); - archive_entry_set_uid(entry, 88); - archive_entry_set_gid(entry, 98); - archive_entry_set_dev(entry, 12); - archive_entry_set_ino(entry, 90); - archive_entry_set_nlink(entry, 1); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - /* Write of data to symlink should fail == zero bytes get written. */ - assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10)); - - /* file with 99-char filename. */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 1, 10); - archive_entry_set_pathname(entry, f99); - archive_entry_set_mode(entry, S_IFREG | 0664); - archive_entry_set_size(entry, 0); - archive_entry_set_uid(entry, 82); - archive_entry_set_gid(entry, 93); - archive_entry_set_dev(entry, 102); - archive_entry_set_ino(entry, 7); - archive_entry_set_nlink(entry, 1); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - - /* file with 100-char filename. */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 1, 10); - archive_entry_set_pathname(entry, f100); - archive_entry_set_mode(entry, S_IFREG | 0664); - archive_entry_set_size(entry, 0); - archive_entry_set_uid(entry, 82); - archive_entry_set_gid(entry, 93); - archive_entry_set_dev(entry, 102); - archive_entry_set_ino(entry, 7); - archive_entry_set_nlink(entry, 1); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - - /* file with 256-char filename. */ - assert((entry = archive_entry_new()) != NULL); - archive_entry_set_mtime(entry, 1, 10); - archive_entry_set_pathname(entry, f256); - archive_entry_set_mode(entry, S_IFREG | 0664); - archive_entry_set_size(entry, 0); - archive_entry_set_uid(entry, 82); - archive_entry_set_gid(entry, 93); - archive_entry_set_dev(entry, 102); - archive_entry_set_ino(entry, 7); - archive_entry_set_nlink(entry, 1); - assertEqualIntA(a, 0, archive_write_header(a, entry)); - archive_entry_free(entry); - -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assert(0 == archive_write_finish(a)); -#endif - - /* - * Verify the archive format. - */ - e = buff; - - /* "file" */ - myAssertEqualMem(e + 0, "file", 5); /* Filename */ - myAssertEqualMem(e + 100, "000664 ", 8); /* mode */ - myAssertEqualMem(e + 108, "000120 ", 8); /* uid */ - myAssertEqualMem(e + 116, "000132 ", 8); /* gid */ - myAssertEqualMem(e + 124, "00000000012 ", 12); /* size */ - myAssertEqualMem(e + 136, "00000000001 ", 12); /* mtime */ - myAssertEqualMem(e + 148, "010034\0 ", 8); /* checksum */ - myAssertEqualMem(e + 156, "0", 1); /* linkflag */ - myAssertEqualMem(e + 157, "", 1); /* linkname */ - myAssertEqualMem(e + 257, "ustar\000000", 8); /* signature/version */ - myAssertEqualMem(e + 265, "", 1); /* uname */ - myAssertEqualMem(e + 297, "", 1); /* gname */ - myAssertEqualMem(e + 329, "000000 ", 8); /* devmajor */ - myAssertEqualMem(e + 337, "000000 ", 8); /* devminor */ - myAssertEqualMem(e + 345, "", 1); /* prefix */ - assert(is_null(e + 0, 512)); - myAssertEqualMem(e + 512, "1234567890", 10); - assert(is_null(e + 512, 512)); - e += 1024; - - /* hardlink to "file" */ - myAssertEqualMem(e + 0, "linkfile", 9); /* Filename */ - myAssertEqualMem(e + 100, "000664 ", 8); /* mode */ - myAssertEqualMem(e + 108, "000120 ", 8); /* uid */ - myAssertEqualMem(e + 116, "000132 ", 8); /* gid */ - myAssertEqualMem(e + 124, "00000000000 ", 12); /* size */ - myAssertEqualMem(e + 136, "00000000001 ", 12); /* mtime */ - myAssertEqualMem(e + 148, "010707\0 ", 8); /* checksum */ - myAssertEqualMem(e + 156, "0", 1); /* linkflag */ - myAssertEqualMem(e + 157, "", 1); /* linkname */ - myAssertEqualMem(e + 257, "ustar\000000", 8); /* signature/version */ - myAssertEqualMem(e + 265, "", 1); /* uname */ - myAssertEqualMem(e + 297, "", 1); /* gname */ - myAssertEqualMem(e + 329, "000000 ", 8); /* devmajor */ - myAssertEqualMem(e + 337, "000000 ", 8); /* devminor */ - myAssertEqualMem(e + 345, "", 1); /* prefix */ - assert(is_null(e + 0, 512)); - e += 512; - - /* "dir" */ - myAssertEqualMem(e + 0, "dir/", 4); /* Filename */ - myAssertEqualMem(e + 100, "000775 ", 8); /* mode */ - myAssertEqualMem(e + 108, "000000 ", 8); /* uid */ - myAssertEqualMem(e + 116, "000000 ", 8); /* gid */ - myAssertEqualMem(e + 124, "00000000000 ", 12); /* size */ - myAssertEqualMem(e + 136, "00000000002 ", 12); /* mtime */ - myAssertEqualMem(e + 148, "007747\0 ", 8); /* checksum */ - myAssertEqualMem(e + 156, "5", 1); /* typeflag */ - myAssertEqualMem(e + 157, "", 1); /* linkname */ - myAssertEqualMem(e + 257, "ustar\000000", 8); /* signature/version */ - myAssertEqualMem(e + 265, "", 1); /* uname */ - myAssertEqualMem(e + 297, "", 1); /* gname */ - myAssertEqualMem(e + 329, "000000 ", 8); /* devmajor */ - myAssertEqualMem(e + 337, "000000 ", 8); /* devminor */ - myAssertEqualMem(e + 345, "", 1); /* prefix */ - assert(is_null(e + 0, 512)); - e += 512; - - /* "symlink" pointing to "file" */ - myAssertEqualMem(e + 0, "symlink", 8); /* Filename */ - myAssertEqualMem(e + 100, "000664 ", 8); /* mode */ - myAssertEqualMem(e + 108, "000130 ", 8); /* uid */ - myAssertEqualMem(e + 116, "000142 ", 8); /* gid */ - myAssertEqualMem(e + 124, "00000000000 ", 12); /* size */ - myAssertEqualMem(e + 136, "00000000003 ", 12); /* mtime */ - myAssertEqualMem(e + 148, "011446\0 ", 8); /* checksum */ - myAssertEqualMem(e + 156, "2", 1); /* linkflag */ - myAssertEqualMem(e + 157, "file", 5); /* linkname */ - myAssertEqualMem(e + 257, "ustar\000000", 8); /* signature/version */ - myAssertEqualMem(e + 265, "", 1); /* uname */ - myAssertEqualMem(e + 297, "", 1); /* gname */ - myAssertEqualMem(e + 329, "000000 ", 8); /* devmajor */ - myAssertEqualMem(e + 337, "000000 ", 8); /* devminor */ - myAssertEqualMem(e + 345, "", 1); /* prefix */ - assert(is_null(e + 0, 512)); - e += 512; - - /* File with 99-char filename */ - myAssertEqualMem(e + 0, f99, 100); /* Filename */ - myAssertEqualMem(e + 100, "000664 ", 8); /* mode */ - myAssertEqualMem(e + 108, "000122 ", 8); /* uid */ - myAssertEqualMem(e + 116, "000135 ", 8); /* gid */ - myAssertEqualMem(e + 124, "00000000000 ", 12); /* size */ - myAssertEqualMem(e + 136, "00000000001 ", 12); /* mtime */ - myAssertEqualMem(e + 148, "034242\0 ", 8); /* checksum */ - myAssertEqualMem(e + 156, "0", 1); /* linkflag */ - myAssertEqualMem(e + 157, "", 1); /* linkname */ - myAssertEqualMem(e + 257, "ustar\000000", 8); /* signature/version */ - myAssertEqualMem(e + 265, "", 1); /* uname */ - myAssertEqualMem(e + 297, "", 1); /* gname */ - myAssertEqualMem(e + 329, "000000 ", 8); /* devmajor */ - myAssertEqualMem(e + 337, "000000 ", 8); /* devminor */ - myAssertEqualMem(e + 345, "", 1); /* prefix */ - assert(is_null(e + 0, 512)); - e += 512; - - /* File with 100-char filename */ - myAssertEqualMem(e + 0, f100, 100); /* Filename */ - myAssertEqualMem(e + 100, "000664 ", 8); /* mode */ - myAssertEqualMem(e + 108, "000122 ", 8); /* uid */ - myAssertEqualMem(e + 116, "000135 ", 8); /* gid */ - myAssertEqualMem(e + 124, "00000000000 ", 12); /* size */ - myAssertEqualMem(e + 136, "00000000001 ", 12); /* mtime */ - myAssertEqualMem(e + 148, "026230\0 ", 8); /* checksum */ - myAssertEqualMem(e + 156, "0", 1); /* linkflag */ - myAssertEqualMem(e + 157, "", 1); /* linkname */ - myAssertEqualMem(e + 257, "ustar\000000", 8); /* signature/version */ - myAssertEqualMem(e + 265, "", 1); /* uname */ - myAssertEqualMem(e + 297, "", 1); /* gname */ - myAssertEqualMem(e + 329, "000000 ", 8); /* devmajor */ - myAssertEqualMem(e + 337, "000000 ", 8); /* devminor */ - myAssertEqualMem(e + 345, "", 1); /* prefix */ - assert(is_null(e + 0, 512)); - e += 512; - - /* File with 256-char filename */ - myAssertEqualMem(e + 0, f256 + 156, 100); /* Filename */ - myAssertEqualMem(e + 100, "000664 ", 8); /* mode */ - myAssertEqualMem(e + 108, "000122 ", 8); /* uid */ - myAssertEqualMem(e + 116, "000135 ", 8); /* gid */ - myAssertEqualMem(e + 124, "00000000000 ", 12); /* size */ - myAssertEqualMem(e + 136, "00000000001 ", 12); /* mtime */ - myAssertEqualMem(e + 148, "055570\0 ", 8); /* checksum */ - myAssertEqualMem(e + 156, "0", 1); /* linkflag */ - myAssertEqualMem(e + 157, "", 1); /* linkname */ - myAssertEqualMem(e + 257, "ustar\000000", 8); /* signature/version */ - myAssertEqualMem(e + 265, "", 1); /* uname */ - myAssertEqualMem(e + 297, "", 1); /* gname */ - myAssertEqualMem(e + 329, "000000 ", 8); /* devmajor */ - myAssertEqualMem(e + 337, "000000 ", 8); /* devminor */ - myAssertEqualMem(e + 345, f256, 155); /* prefix */ - assert(is_null(e + 0, 512)); - e += 512; - - /* TODO: Verify other types of entries. */ - - /* Last entry is end-of-archive marker. */ - assert(is_null(e, 1024)); - e += 1024; - - assertEqualInt((int)used, e - buff); - - free(buff); -} diff --git a/archivers/libarchive/files/libarchive/test/test_write_open_memory.c b/archivers/libarchive/files/libarchive/test/test_write_open_memory.c deleted file mode 100644 index 696db6c963a..00000000000 --- a/archivers/libarchive/files/libarchive/test/test_write_open_memory.c +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * Copyright (c) 2003-2007 Tim Kientzle - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_open_memory.c 189308 2009-03-03 17:02:51Z kientzle $"); - -/* Try to force archive_write_open_memory.c to write past the end of an array. */ -static unsigned char buff[16384]; - -DEFINE_TEST(test_write_open_memory) -{ - unsigned int i; - struct archive *a; - struct archive_entry *ae; - const char *name="/tmp/test"; - - /* Create a simple archive_entry. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_set_pathname(ae, name); - archive_entry_set_mode(ae, S_IFREG); - assertEqualString(archive_entry_pathname(ae), name); - - /* Try writing with different buffer sizes. */ - /* Make sure that we get failure on too-small buffers, success on - * large enough ones. */ - for (i = 100; i < 1600; i++) { - size_t s; - size_t blocksize = 94; - 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, (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. */ - if (i < (511/blocksize)*blocksize) - assertA(ARCHIVE_FATAL == archive_write_header(a,ae)); - else - assertA(0 == archive_write_header(a, ae)); - /* If buffer is smaller than a tar header plus 1024 byte - * end-of-archive marker, then this should fail. */ - if (i < 1536) - assertA(ARCHIVE_FATAL == archive_write_close(a)); - else - assertA(0 == archive_write_close(a)); -#if ARCHIVE_VERSION_NUMBER < 2000000 - archive_write_finish(a); -#else - assert(0 == archive_write_finish(a)); -#endif - assert(buff[i] == 0xAE); - assert(s <= i); - } - archive_entry_free(ae); -} |