summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/tar/test
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/libarchive/files/tar/test')
-rw-r--r--archivers/libarchive/files/tar/test/CMakeLists.txt6
-rw-r--r--archivers/libarchive/files/tar/test/test.h330
-rw-r--r--archivers/libarchive/files/tar/test/test_copy.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_leading_slash.c1
-rw-r--r--archivers/libarchive/files/tar/test/test_missing_file.c6
-rw-r--r--archivers/libarchive/files/tar/test/test_option_H_upper.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_option_L_upper.c12
-rw-r--r--archivers/libarchive/files/tar/test/test_option_U_upper.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_option_a.c7
-rw-r--r--archivers/libarchive/files/tar/test/test_option_b.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_option_b64encode.c2
-rw-r--r--archivers/libarchive/files/tar/test/test_option_gid_gname.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_option_grzip.c3
-rw-r--r--archivers/libarchive/files/tar/test/test_option_j.c7
-rw-r--r--archivers/libarchive/files/tar/test/test_option_lrzip.c2
-rw-r--r--archivers/libarchive/files/tar/test/test_option_lz4.c17
-rw-r--r--archivers/libarchive/files/tar/test/test_option_lzma.c5
-rw-r--r--archivers/libarchive/files/tar/test/test_option_lzop.c7
-rw-r--r--archivers/libarchive/files/tar/test/test_option_n.c2
-rw-r--r--archivers/libarchive/files/tar/test/test_option_r.c34
-rw-r--r--archivers/libarchive/files/tar/test/test_option_uid_uname.c13
-rw-r--r--archivers/libarchive/files/tar/test/test_option_uuencode.c2
-rw-r--r--archivers/libarchive/files/tar/test/test_option_xz.c7
-rw-r--r--archivers/libarchive/files/tar/test/test_option_z.c7
-rw-r--r--archivers/libarchive/files/tar/test/test_stdio.c1
-rw-r--r--archivers/libarchive/files/tar/test/test_symlink_dir.c20
-rw-r--r--archivers/libarchive/files/tar/test/test_version.c72
-rw-r--r--archivers/libarchive/files/tar/test/test_windows.c2
28 files changed, 144 insertions, 441 deletions
diff --git a/archivers/libarchive/files/tar/test/CMakeLists.txt b/archivers/libarchive/files/tar/test/CMakeLists.txt
index f19a5f69c50..3dd36019eed 100644
--- a/archivers/libarchive/files/tar/test/CMakeLists.txt
+++ b/archivers/libarchive/files/tar/test/CMakeLists.txt
@@ -6,7 +6,7 @@
IF(ENABLE_TAR AND ENABLE_TEST)
SET(bsdtar_test_SOURCES
../../test_utils/test_utils.c
- main.c
+ ../../test_utils/test_main.c
test.h
test_0.c
test_basic.c
@@ -96,11 +96,13 @@ IF(ENABLE_TAR AND ENABLE_TEST)
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
+ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/tar/test)
# Experimental new test handling
ADD_CUSTOM_TARGET(run_bsdtar_test
COMMAND bsdtar_test -p $<TARGET_FILE:bsdtar>
- -r ${CMAKE_CURRENT_SOURCE_DIR})
+ -r ${CMAKE_CURRENT_SOURCE_DIR}
+ -vv)
ADD_DEPENDENCIES(run_bsdtar_test bsdtar)
ADD_DEPENDENCIES(run_all_tests run_bsdtar_test)
diff --git a/archivers/libarchive/files/tar/test/test.h b/archivers/libarchive/files/tar/test/test.h
index 704a137ed3f..1e1bee80709 100644
--- a/archivers/libarchive/files/tar/test/test.h
+++ b/archivers/libarchive/files/tar/test/test.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2006 Tim Kientzle
+ * Copyright (c) 2003-2017 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,323 +22,19 @@
* (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: src/usr.bin/tar/test/test.h,v 1.4 2008/08/21 07:04:57 kientzle Exp $
+ * $FreeBSD$
*/
/* 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 <ctype.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__)
-#undef chdir
-#define chdir _chdir
-#define strdup _strdup
-#endif
-#endif
-
-/* Visual Studio */
-#if defined(_MSC_VER) && _MSC_VER < 1900
-#define snprintf sprintf_s
-#endif
-
-#if defined(__BORLANDC__)
-#pragma warn -8068 /* Constant out of range in comparison. */
-#endif
-
-/* Haiku OS and QNX */
-#if defined(__HAIKU__) || defined(__QNXNTO__)
-/* Haiku and QNX have 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, 0)
-#define assertEqualUTF8String(v1,v2) \
- assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 1)
-/* 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 that memory is full of a specified byte */
-#define assertMemoryFilledWith(v1, l, b) \
- assertion_memory_filled_with(__FILE__, __LINE__, (v1), #v1, (l), #l, (b), #b, NULL)
-/* Assert two files are the same. */
-#define assertEqualFile(f1, f2) \
- assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
-/* Assert that a file is empty. */
-#define assertEmptyFile(pathname) \
- assertion_empty_file(__FILE__, __LINE__, (pathname))
-/* Assert that a file is not empty. */
-#define assertNonEmptyFile(pathname) \
- assertion_non_empty_file(__FILE__, __LINE__, (pathname))
-#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(pathname) \
- assertion_file_exists(__FILE__, __LINE__, pathname)
-/* Assert that a file exists. */
-#define assertFileNotExists(pathname) \
- assertion_file_not_exists(__FILE__, __LINE__, pathname)
-/* Assert that file contents match a string. */
-#define assertFileContents(data, data_size, pathname) \
- assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
-#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(text, pathname) \
- assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
-#define assertFileContainsLinesAnyOrder(pathname, lines) \
- assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines)
-#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, -1, contents)
-#define assertMakeBinFile(path, mode, csize, contents) \
- assertion_make_file(__FILE__, __LINE__, path, mode, csize, contents)
-#define assertMakeHardlink(newfile, oldfile) \
- assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile)
-#define assertMakeSymlink(newfile, linkto) \
- assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
-#define assertNodump(path) \
- assertion_nodump(__FILE__, __LINE__, path)
-#define assertUmask(mask) \
- assertion_umask(__FILE__, __LINE__, mask)
-#define assertUtimes(pathname, atime, atime_nsec, mtime, mtime_nsec) \
- assertion_utimes(__FILE__, __LINE__, pathname, atime, atime_nsec, mtime, mtime_nsec)
-
-/*
- * 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 \
- skipping_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, const char *);
-int assertion_equal_file(const char *, int, 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_memory_filled_with(const char *, int, const void *, const char *, size_t, const char *, char, const char *, void *);
-int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
-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_contains_lines_any_order(const char *, int, const char *, const char **);
-int assertion_file_contents(const char *, int, const void *, int, const char *);
-int assertion_file_exists(const char *, int, 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, 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, int, const void *);
-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_nodump(const char *, int, const char *);
-int assertion_non_empty_file(const char *, int, const char *);
-int assertion_text_file_contents(const char *, int, const char *buff, const char *f);
-int assertion_umask(const char *, int, int);
-int assertion_utimes(const char *, int, const char *, long, long, long, long );
-
-void skipping_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 "bzip2" program. */
-int canBzip2(void);
-
-/* Return true if this platform can run the "grzip" program. */
-int canGrzip(void);
-
-/* Return true if this platform can run the "gzip" program. */
-int canGzip(void);
-
-/* Return true if this platform can run the specified command. */
-int canRunCommand(const char *);
-
-/* Return true if this platform can run the "lrzip" program. */
-int canLrzip(void);
-
-/* Return true if this platform can run the "lz4" program. */
-int canLz4(void);
-
-/* Return true if this platform can run the "lzip" program. */
-int canLzip(void);
-
-/* Return true if this platform can run the "lzma" program. */
-int canLzma(void);
-
-/* Return true if this platform can run the "lzop" program. */
-int canLzop(void);
-
-/* Return true if this platform can run the "xz" program. */
-int canXz(void);
-
-/* Return true if this filesystem can handle nodump flags. */
-int canNodump(void);
-
-/* Return true if the file has large i-node number(>0xffffffff). */
-int is_LargeInode(const char *);
-
-/* 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, ...);
-
-/* Dump block of bytes to a file. */
-void dumpfile(const char *filename, void *, size_t);
-
-/* Extracts named reference file to the current directory. */
-void extract_reference_file(const char *);
-/* Copies named reference file to the current directory. */
-void copy_reference_file(const char *);
-
-/* Extracts a list of files to the current directory.
- * List must be NULL terminated.
- */
-void extract_reference_files(const char **);
-
-/* Path to working directory for current test */
-extern const char *testworkdir;
-
-/*
- * Special interfaces for program test harness.
- */
-
-/* Pathname of exe to be tested. */
-extern const char *testprogfile;
-/* Name of exe to use in printf-formatted command strings. */
-/* On Windows, this includes leading/trailing quotes. */
-extern const char *testprog;
-
-#ifdef USE_DMALLOC
-#include <dmalloc.h>
-#endif
+#define KNOWNREF "test_patterns_2.tar.uu"
+#define ENVBASE "BSDTAR" /* Prefix for environment variables. */
+#define PROGRAM "bsdtar" /* Name of program being tested. */
+#define PROGRAM_ALIAS "tar" /* Generic alias for program */
+#undef LIBRARY /* Not testing a library. */
+#undef EXTRA_DUMP /* How to dump extra data */
+#undef EXTRA_ERRNO /* How to dump errno */
+/* How to generate extra version info. */
+#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
+
+#include "test_common.h"
diff --git a/archivers/libarchive/files/tar/test/test_copy.c b/archivers/libarchive/files/tar/test/test_copy.c
index c4c1aa05745..e6e31f45228 100644
--- a/archivers/libarchive/files/tar/test/test_copy.c
+++ b/archivers/libarchive/files/tar/test/test_copy.c
@@ -285,7 +285,7 @@ copy_basic(void)
/* NOTE: for proper operation on cygwin-1.5 and windows, the
* length of the name of the directory below, "plain", must be
- * less than or equal to the lengthe of the name of the original
+ * less than or equal to the length of the name of the original
* directory, "original" This restriction derives from the
* extremely limited pathname lengths on those platforms.
*/
@@ -327,7 +327,7 @@ copy_ustar(void)
/* NOTE: for proper operation on cygwin-1.5 and windows, the
* length of the name of the directory below, "ustar", must be
- * less than or equal to the lengthe of the name of the original
+ * less than or equal to the length of the name of the original
* directory, "original" This restriction derives from the
* extremely limited pathname lengths on those platforms.
*/
diff --git a/archivers/libarchive/files/tar/test/test_leading_slash.c b/archivers/libarchive/files/tar/test/test_leading_slash.c
index a8921ebcbae..572c45e3cbb 100644
--- a/archivers/libarchive/files/tar/test/test_leading_slash.c
+++ b/archivers/libarchive/files/tar/test/test_leading_slash.c
@@ -44,6 +44,7 @@ DEFINE_TEST(test_leading_slash)
if (assertFileExists("test.err")) {
errfile = slurpfile(&errfile_size, "test.err");
assert(strstr(errfile, expected_errmsg) != NULL);
+ free(errfile);
}
}
diff --git a/archivers/libarchive/files/tar/test/test_missing_file.c b/archivers/libarchive/files/tar/test/test_missing_file.c
index e2e5da5bddf..808e384e10b 100644
--- a/archivers/libarchive/files/tar/test/test_missing_file.c
+++ b/archivers/libarchive/files/tar/test/test_missing_file.c
@@ -27,11 +27,15 @@ __FBSDID("$FreeBSD$");
DEFINE_TEST(test_missing_file)
{
+ const char * invalid_stderr[] = { "INTERNAL ERROR", NULL };
assertMakeFile("file1", 0644, "file1");
assertMakeFile("file2", 0644, "file2");
assert(0 == systemf("%s -cf archive.tar file1 file2 2>stderr1", testprog));
assertEmptyFile("stderr1");
assert(0 != systemf("%s -cf archive.tar file1 file2 file3 2>stderr2", testprog));
+ assertFileContainsNoInvalidStrings("stderr2", invalid_stderr);
assert(0 != systemf("%s -cf archive.tar 2>stderr3", testprog));
- assert(0 != systemf("%s -cf archive.tar file3 2>stderr4", testprog));
+ assertFileContainsNoInvalidStrings("stderr3", invalid_stderr);
+ assert(0 != systemf("%s -cf archive.tar file3 file4 2>stderr4", testprog));
+ assertFileContainsNoInvalidStrings("stderr4", invalid_stderr);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_H_upper.c b/archivers/libarchive/files/tar/test/test_option_H_upper.c
index 7ddd917b7b9..adc294b55b2 100644
--- a/archivers/libarchive/files/tar/test/test_option_H_upper.c
+++ b/archivers/libarchive/files/tar/test/test_option_H_upper.c
@@ -83,10 +83,10 @@ DEFINE_TEST(test_option_H_upper)
assertChdir("test3");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsDir("ld1", 0755);
+ assertIsDir("ld1", umasked(0755));
assertIsSymlink("d1/linkX", "fileX");
assertIsSymlink("d1/link1", "file1");
- assertIsReg("link2", 0644);
+ assertIsReg("link2", umasked(0644));
assertIsSymlink("linkY", "d1/fileY");
assertChdir("..");
}
diff --git a/archivers/libarchive/files/tar/test/test_option_L_upper.c b/archivers/libarchive/files/tar/test/test_option_L_upper.c
index 57abe412cd2..f5a3c5ab4cb 100644
--- a/archivers/libarchive/files/tar/test/test_option_L_upper.c
+++ b/archivers/libarchive/files/tar/test/test_option_L_upper.c
@@ -69,10 +69,10 @@ DEFINE_TEST(test_option_L_upper)
assertChdir("test2");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsDir("ld1", 0755);
- assertIsReg("d1/link1", 0644);
+ assertIsDir("ld1", umasked(0755));
+ assertIsReg("d1/link1", umasked(0644));
assertIsSymlink("d1/linkX", "fileX");
- assertIsReg("link2", 0644);
+ assertIsReg("link2", umasked(0644));
assertIsSymlink("linkY", "d1/fileY");
assertChdir("..");
@@ -83,10 +83,10 @@ DEFINE_TEST(test_option_L_upper)
assertChdir("test3");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsDir("ld1", 0755);
- assertIsReg("d1/link1", 0644);
+ assertIsDir("ld1", umasked(0755));
+ assertIsReg("d1/link1", umasked(0644));
assertIsSymlink("d1/linkX", "fileX");
- assertIsReg("link2", 0644);
+ assertIsReg("link2", umasked(0644));
assertIsSymlink("linkY", "d1/fileY");
assertChdir("..");
}
diff --git a/archivers/libarchive/files/tar/test/test_option_U_upper.c b/archivers/libarchive/files/tar/test/test_option_U_upper.c
index 4d77cb03810..2c43e002df5 100644
--- a/archivers/libarchive/files/tar/test/test_option_U_upper.c
+++ b/archivers/libarchive/files/tar/test/test_option_U_upper.c
@@ -135,7 +135,7 @@ DEFINE_TEST(test_option_U_upper)
assertMakeSymlink("d1/file1", "d1/realfile1");
assertEqualInt(0,
systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
- assertIsReg("d1/file1", 0644);
+ assertIsReg("d1/file1", umasked(0644));
assertFileContents("d1/file1", 8, "d1/file1");
assertFileContents("realfile1", 9, "d1/realfile1");
assertEmptyFile("test.out");
@@ -150,7 +150,7 @@ DEFINE_TEST(test_option_U_upper)
assertMakeSymlink("d1/file1", "d1/realfile1");
assertEqualInt(0,
systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
- assertIsReg("d1/file1", 0644);
+ assertIsReg("d1/file1", umasked(0644));
assertFileContents("d1/file1", 8, "d1/file1");
assertFileContents("realfile1", 9, "d1/realfile1");
assertEmptyFile("test.out");
diff --git a/archivers/libarchive/files/tar/test/test_option_a.c b/archivers/libarchive/files/tar/test/test_option_a.c
index a000621cb8b..d9eed8777ff 100644
--- a/archivers/libarchive/files/tar/test/test_option_a.c
+++ b/archivers/libarchive/files/tar/test/test_option_a.c
@@ -43,6 +43,7 @@ DEFINE_TEST(test_option_a)
assert(s > 2);
failure("The archive should be compressed");
assertEqualMem(p, "\x1f\x9d", 2);
+ free(p);
/* Test2: archive it with .taZ suffix. */
assertEqualInt(0,
@@ -53,6 +54,7 @@ DEFINE_TEST(test_option_a)
assert(s > 2);
failure("The archive should be compressed");
assertEqualMem(p, "\x1f\x9d", 2);
+ free(p);
/* Test3: archive it with .tar.Z.uu suffix. */
assertEqualInt(0,
@@ -63,6 +65,7 @@ DEFINE_TEST(test_option_a)
assert(s > 12);
failure("The archive should be uuencoded");
assertEqualMem(p, "begin 644 -\n", 12);
+ free(p);
/* Test4: archive it with .zip suffix. */
assertEqualInt(0,
@@ -73,6 +76,7 @@ DEFINE_TEST(test_option_a)
assert(s > 4);
failure("The archive should be zipped");
assertEqualMem(p, "\x50\x4b\x03\x04", 4);
+ free(p);
/* Test5: archive it with .tar.Z suffix and --uuencode option. */
assertEqualInt(0,
@@ -84,6 +88,7 @@ DEFINE_TEST(test_option_a)
assert(s > 2);
failure("The archive should be compressed, ignoring --uuencode option");
assertEqualMem(p, "\x1f\x9d", 2);
+ free(p);
/* Test6: archive it with .xxx suffix(unknown suffix) and
* --uuencode option. */
@@ -96,6 +101,7 @@ DEFINE_TEST(test_option_a)
assert(s > 12);
failure("The archive should be uuencoded");
assertEqualMem(p, "begin 644 -\n", 12);
+ free(p);
/* Test7: archive it with .tar.Z suffix using a long-name option. */
assertEqualInt(0,
@@ -107,4 +113,5 @@ DEFINE_TEST(test_option_a)
assert(s > 2);
failure("The archive should be compressed");
assertEqualMem(p, "\x1f\x9d", 2);
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_b.c b/archivers/libarchive/files/tar/test/test_option_b.c
index 81f50be8355..0eee80d86f4 100644
--- a/archivers/libarchive/files/tar/test/test_option_b.c
+++ b/archivers/libarchive/files/tar/test/test_option_b.c
@@ -33,7 +33,7 @@ DEFINE_TEST(test_option_b)
assertMakeFile("file1", 0644, "file1");
if (systemf("cat file1 > test_cat.out 2> test_cat.err") != 0) {
- skipping("Platform doesn't have cat");
+ skipping("This test requires a `cat` program");
return;
}
testprog_ustar = malloc(strlen(testprog) + sizeof(USTAR_OPT) + 1);
@@ -78,4 +78,6 @@ DEFINE_TEST(test_option_b)
* Note: It's not possible to verify at this level that blocks
* are getting written with the
*/
+
+ free(testprog_ustar);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_b64encode.c b/archivers/libarchive/files/tar/test/test_option_b64encode.c
index 1e7c57175ce..1d0420430e0 100644
--- a/archivers/libarchive/files/tar/test/test_option_b64encode.c
+++ b/archivers/libarchive/files/tar/test/test_option_b64encode.c
@@ -42,6 +42,7 @@ DEFINE_TEST(test_option_b64encode)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "begin-base64 644", 16);
+ free(p);
/* Archive it with uuencode only. */
assertEqualInt(0,
@@ -51,4 +52,5 @@ DEFINE_TEST(test_option_b64encode)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "begin-base64 644", 16);
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_gid_gname.c b/archivers/libarchive/files/tar/test/test_option_gid_gname.c
index e45da5b9146..4e5f51c8f48 100644
--- a/archivers/libarchive/files/tar/test/test_option_gid_gname.c
+++ b/archivers/libarchive/files/tar/test/test_option_gid_gname.c
@@ -53,6 +53,7 @@ DEFINE_TEST(test_option_gid_gname)
/* Should force gid and gname fields in ustar header. */
assertEqualMem(data + 116, "000021 \0", 8);
assertEqualMem(data + 297, "foofoofoo\0", 10);
+ free(data);
/* Again with just --gname */
failure("Error invoking %s c", testprog);
@@ -65,6 +66,8 @@ DEFINE_TEST(test_option_gid_gname)
/* Gid should be unchanged from original reference. */
assertEqualMem(data + 116, reference + 116, 8);
assertEqualMem(data + 297, "foofoofoo\0", 10);
+ free(data);
+ free(reference);
/* Again with --gid and force gname to empty. */
failure("Error invoking %s c", testprog);
@@ -77,6 +80,7 @@ DEFINE_TEST(test_option_gid_gname)
assertEqualMem(data + 116, "000021 \0", 8);
/* Gname field in ustar header should be empty. */
assertEqualMem(data + 297, "\0", 1);
+ free(data);
/* TODO: It would be nice to verify that --gid= by itself
* will look up the associated gname and use that, but
diff --git a/archivers/libarchive/files/tar/test/test_option_grzip.c b/archivers/libarchive/files/tar/test/test_option_grzip.c
index 5132eeec26e..fbff252421d 100644
--- a/archivers/libarchive/files/tar/test/test_option_grzip.c
+++ b/archivers/libarchive/files/tar/test/test_option_grzip.c
@@ -45,8 +45,11 @@ DEFINE_TEST(test_option_grzip)
testprog));
p = slurpfile(&s, "archive.err");
p[s] = '\0';
+ free(p);
+
/* Check that the archive file has an grzip signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12);
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_j.c b/archivers/libarchive/files/tar/test/test_option_j.c
index 3202c3b8391..838234a2aeb 100644
--- a/archivers/libarchive/files/tar/test/test_option_j.c
+++ b/archivers/libarchive/files/tar/test/test_option_j.c
@@ -42,15 +42,18 @@ DEFINE_TEST(test_option_j)
if (r != 0) {
if (!canBzip2()) {
skipping("bzip2 is not supported on this platform");
- return;
+ goto done;
}
failure("-j option is broken");
assertEqualInt(r, 0);
- return;
+ goto done;
}
+ free(p);
assertEmptyFile("archive.err");
/* Check that the archive file has a bzip2 signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "BZh9", 4);
+done:
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_lrzip.c b/archivers/libarchive/files/tar/test/test_option_lrzip.c
index d3486a3a27b..11e9827e040 100644
--- a/archivers/libarchive/files/tar/test/test_option_lrzip.c
+++ b/archivers/libarchive/files/tar/test/test_option_lrzip.c
@@ -45,8 +45,10 @@ DEFINE_TEST(test_option_lrzip)
testprog));
p = slurpfile(&s, "archive.err");
p[s] = '\0';
+ free(p);
/* Check that the archive file has an lzma signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "LRZI\x00", 5);
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_lz4.c b/archivers/libarchive/files/tar/test/test_option_lz4.c
index 5dc94521630..70fdaac3600 100644
--- a/archivers/libarchive/files/tar/test/test_option_lz4.c
+++ b/archivers/libarchive/files/tar/test/test_option_lz4.c
@@ -43,7 +43,7 @@ DEFINE_TEST(test_option_lz4)
if (strstr(p, "Unsupported compression") != NULL) {
skipping("This version of bsdtar was compiled "
"without lz4 support");
- return;
+ goto done;
}
/* POSIX permits different handling of the spawnp
* system call used to launch the subsidiary
@@ -52,7 +52,7 @@ DEFINE_TEST(test_option_lz4)
if (strstr(p, "Can't launch") != NULL && !canLz4()) {
skipping("This version of bsdtar uses an external lz4 program "
"but no such program is available on this system.");
- return;
+ goto done;
}
/* Some systems successfully spawn the new process,
* but fail to exec a program within that process.
@@ -61,14 +61,25 @@ DEFINE_TEST(test_option_lz4)
if (strstr(p, "Can't write") != NULL && !canLz4()) {
skipping("This version of bsdtar uses an external lz4 program "
"but no such program is available on this system.");
+ goto done;
+ }
+ /* On some systems the error won't be detected until closing
+ time, by a 127 exit error returned by waitpid. */
+ if (strstr(p, "Error closing") != NULL && !canLz4()) {
+ skipping("This version of bsdcpio uses an external lz4 program "
+ "but no such program is available on this system.");
return;
}
failure("--lz4 option is broken: %s", p);
assertEqualInt(r, 0);
- return;
+ goto done;
}
+ free(p);
/* Check that the archive file has an lz4 signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\x04\x22\x4d\x18", 4);
+
+done:
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_lzma.c b/archivers/libarchive/files/tar/test/test_option_lzma.c
index a845666e34f..a618ff8a340 100644
--- a/archivers/libarchive/files/tar/test/test_option_lzma.c
+++ b/archivers/libarchive/files/tar/test/test_option_lzma.c
@@ -48,10 +48,13 @@ DEFINE_TEST(test_option_lzma)
}
failure("--lzma option is broken");
assertEqualInt(r, 0);
- return;
+ goto done;
}
+ free(p);
/* Check that the archive file has an lzma signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\x5d\00\00", 3);
+done:
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_lzop.c b/archivers/libarchive/files/tar/test/test_option_lzop.c
index 1145499a460..20ef06c5c8a 100644
--- a/archivers/libarchive/files/tar/test/test_option_lzop.c
+++ b/archivers/libarchive/files/tar/test/test_option_lzop.c
@@ -42,14 +42,17 @@ DEFINE_TEST(test_option_lzop)
if (r != 0) {
if (!canLzop()) {
skipping("lzop is not supported on this platform");
- return;
+ goto done;
}
failure("--lzop option is broken");
assertEqualInt(r, 0);
- return;
+ goto done;
}
+ free(p);
/* Check that the archive file has an lzma signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9);
+done:
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_n.c b/archivers/libarchive/files/tar/test/test_option_n.c
index 4017dd9f01f..18ab6142d0f 100644
--- a/archivers/libarchive/files/tar/test/test_option_n.c
+++ b/archivers/libarchive/files/tar/test/test_option_n.c
@@ -55,7 +55,7 @@ DEFINE_TEST(test_option_n)
systemf("%s -xf archive.tar >x.out 2>x.err", testprog));
assertEmptyFile("x.out");
assertEmptyFile("x.err");
- assertIsDir("d1", 0755);
+ assertIsDir("d1", umasked(0755));
assertFileNotExists("d1/file1");
assertChdir("..");
}
diff --git a/archivers/libarchive/files/tar/test/test_option_r.c b/archivers/libarchive/files/tar/test/test_option_r.c
index 77876857ea7..287e80939ad 100644
--- a/archivers/libarchive/files/tar/test/test_option_r.c
+++ b/archivers/libarchive/files/tar/test/test_option_r.c
@@ -36,6 +36,10 @@ DEFINE_TEST(test_option_r)
size_t s, buff_size_rounded;
int r, i;
+ buff = NULL;
+ p0 = NULL;
+ p1 = NULL;
+
/* Create an archive with one file. */
assertMakeFile("f1", 0644, "abc");
r = systemf("%s cf archive.tar --format=ustar f1 >step1.out 2>step1.err", testprog);
@@ -47,11 +51,9 @@ DEFINE_TEST(test_option_r)
/* Do some basic validation of the constructed archive. */
p0 = slurpfile(&s, "archive.tar");
if (!assert(p0 != NULL))
- return;
- if (!assert(s >= 2048)) {
- free(p0);
- return;
- }
+ goto done;
+ if (!assert(s >= 2048))
+ goto done;
assertEqualMem(p0 + 0, "f1", 3);
assertEqualMem(p0 + 512, "abc", 3);
assertEqualMem(p0 + 1024, "\0\0\0\0\0\0\0\0", 8);
@@ -60,10 +62,8 @@ DEFINE_TEST(test_option_r)
/* Edit that file with a lot more data and update the archive with a new copy. */
buff = malloc(buff_size);
assert(buff != NULL);
- if (buff == NULL) {
- free(p0);
- return;
- }
+ if (buff == NULL)
+ goto done;
for (i = 0; i < (int)buff_size; ++i)
buff[i] = "abcdefghijklmnopqrstuvwxyz"[rand() % 26];
@@ -77,10 +77,8 @@ DEFINE_TEST(test_option_r)
/* The constructed archive should just have the new entry appended. */
p1 = slurpfile(&s, "archive.tar");
- if (!assert(p1 != NULL)) {
- free(p0);
- return;
- }
+ if (!assert(p1 != NULL))
+ goto done;
buff_size_rounded = ((buff_size + 511) / 512) * 512;
assert(s >= 2560 + buff_size_rounded);
/* Verify first entry is unchanged. */
@@ -105,10 +103,8 @@ DEFINE_TEST(test_option_r)
/* Validate the constructed archive. */
p1 = slurpfile(&s, "archive.tar");
- if (!assert(p1 != NULL)) {
- free(p0);
- return;
- }
+ if (!assert(p1 != NULL))
+ goto done;
assert(s >= 3584 + buff_size_rounded);
/* Verify first two entries are unchanged. */
assertEqualMem(p0, p1, 1536 + buff_size_rounded);
@@ -118,7 +114,6 @@ DEFINE_TEST(test_option_r)
/* Verify end-of-archive marker. */
assertEqualMem(p1 + 2560 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
assertEqualMem(p1 + 3072 + buff_size_rounded, "\0\0\0\0\0\0\0\0", 8);
- free(p0);
free(p1);
/* Unpack everything */
@@ -132,4 +127,7 @@ DEFINE_TEST(test_option_r)
/* Verify that the second copy of f1 overwrote the first. */
assertFileContents(buff, (int)strlen(buff), "f1");
+done:
+ free(buff);
+ free(p0);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_uid_uname.c b/archivers/libarchive/files/tar/test/test_option_uid_uname.c
index 83ea5f1ecbb..80c06196148 100644
--- a/archivers/libarchive/files/tar/test/test_option_uid_uname.c
+++ b/archivers/libarchive/files/tar/test/test_option_uid_uname.c
@@ -45,26 +45,28 @@ DEFINE_TEST(test_option_uid_uname)
/* Again with both --uid and --uname */
failure("Error invoking %s c", testprog);
assertEqualInt(0,
- systemf("%s cf archive2 --uid=17 --uname=foofoofoo --format=ustar file >stdout2.txt 2>stderr2.txt",
+ systemf("%s cf archive2 --uid=65123 --uname=foofoofoo --format=ustar file >stdout2.txt 2>stderr2.txt",
testprog));
assertEmptyFile("stdout2.txt");
assertEmptyFile("stderr2.txt");
data = slurpfile(&s, "archive2");
/* Should force uid and uname fields in ustar header. */
- assertEqualMem(data + 108, "000021 \0", 8);
+ assertEqualMem(data + 108, "177143 \0", 8);
assertEqualMem(data + 265, "foofoofoo\0", 10);
+ free(data);
/* Again with just --uid */
failure("Error invoking %s c", testprog);
assertEqualInt(0,
- systemf("%s cf archive3 --uid=17 --format=ustar file >stdout3.txt 2>stderr3.txt",
+ systemf("%s cf archive3 --uid=65123 --format=ustar file >stdout3.txt 2>stderr3.txt",
testprog));
assertEmptyFile("stdout3.txt");
assertEmptyFile("stderr3.txt");
data = slurpfile(&s, "archive3");
- assertEqualMem(data + 108, "000021 \0", 8);
+ assertEqualMem(data + 108, "177143 \0", 8);
/* Uname field in ustar header should be empty. */
assertEqualMem(data + 265, "\0", 1);
+ free(data);
/* Again with just --uname */
failure("Error invoking %s c", testprog);
@@ -77,4 +79,7 @@ DEFINE_TEST(test_option_uid_uname)
/* Uid should be unchanged from original reference. */
assertEqualMem(data + 108, reference + 108, 8);
assertEqualMem(data + 265, "foofoofoo\0", 10);
+ free(data);
+
+ free(reference);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_uuencode.c b/archivers/libarchive/files/tar/test/test_option_uuencode.c
index cdc6babd519..a28a8e3407a 100644
--- a/archivers/libarchive/files/tar/test/test_option_uuencode.c
+++ b/archivers/libarchive/files/tar/test/test_option_uuencode.c
@@ -42,6 +42,7 @@ DEFINE_TEST(test_option_uuencode)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "begin 644", 9);
+ free(p);
/* Archive it with uuencode only. */
assertEqualInt(0,
@@ -51,4 +52,5 @@ DEFINE_TEST(test_option_uuencode)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "begin 644", 9);
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_xz.c b/archivers/libarchive/files/tar/test/test_option_xz.c
index 7387a604e07..91da0730ac9 100644
--- a/archivers/libarchive/files/tar/test/test_option_xz.c
+++ b/archivers/libarchive/files/tar/test/test_option_xz.c
@@ -44,14 +44,17 @@ DEFINE_TEST(test_option_xz)
if (strstr(p, "Unsupported compression") != NULL) {
skipping("This version of bsdtar was compiled "
"without xz support");
- return;
+ goto done;
}
failure("--xz option is broken");
assertEqualInt(r, 0);
- return;
+ goto done;
}
+ free(p);
/* Check that the archive file has an xz signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\xFD\x37\x7A\x58\x5A\x00", 6);
+done:
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_option_z.c b/archivers/libarchive/files/tar/test/test_option_z.c
index 1f952abe3af..59744999fc5 100644
--- a/archivers/libarchive/files/tar/test/test_option_z.c
+++ b/archivers/libarchive/files/tar/test/test_option_z.c
@@ -42,14 +42,17 @@ DEFINE_TEST(test_option_z)
if (r != 0) {
if (!canGzip()) {
skipping("gzip is not supported on this platform");
- return;
+ goto done;
}
failure("-z option is broken");
assertEqualInt(r, 0);
- return;
+ goto done;
}
+ free(p);
/* Check that the archive file has a gzip signature. */
p = slurpfile(&s, "archive.out");
assert(s > 4);
assertEqualMem(p, "\x1f\x8b\x08\x00", 4);
+done:
+ free(p);
}
diff --git a/archivers/libarchive/files/tar/test/test_stdio.c b/archivers/libarchive/files/tar/test/test_stdio.c
index bf5dd77443b..d6650a5eb20 100644
--- a/archivers/libarchive/files/tar/test/test_stdio.c
+++ b/archivers/libarchive/files/tar/test/test_stdio.c
@@ -116,6 +116,7 @@ DEFINE_TEST(test_stdio)
assertEqualInt((int)s, 3);
assertEqualMem(p, "abc", 3);
/* TODO: Verify xvf.err */
+ free(p);
/* 'xvf -' should generate list on stderr, empty stdout. */
r = systemf("%s xvf - < archive >xvf-.out 2>xvf-.err", testprog);
diff --git a/archivers/libarchive/files/tar/test/test_symlink_dir.c b/archivers/libarchive/files/tar/test/test_symlink_dir.c
index f6e99662bf1..852e00b37c6 100644
--- a/archivers/libarchive/files/tar/test/test_symlink_dir.c
+++ b/archivers/libarchive/files/tar/test/test_symlink_dir.c
@@ -47,11 +47,18 @@ DEFINE_TEST(test_symlink_dir)
assertMakeDir("source/dir3", 0755);
assertMakeDir("source/dir3/d3", 0755);
assertMakeFile("source/dir3/f3", 0755, "abcde");
+ assertMakeDir("source/dir4", 0755);
+ assertMakeFile("source/dir4/file3", 0755, "abcdef");
+ assertMakeHardlink("source/dir4/file4", "source/dir4/file3");
assertEqualInt(0,
systemf("%s -cf test.tar -C source dir dir2 dir3 file file2",
testprog));
+ /* Second archive with hardlinks */
+ assertEqualInt(0,
+ systemf("%s -cf test2.tar -C source dir4", testprog));
+
/*
* Extract with -x and without -P.
*/
@@ -63,7 +70,7 @@ DEFINE_TEST(test_symlink_dir)
/* "dir2" is a symlink to a non-existing "real_dir2" */
assertMakeSymlink("dest1/dir2", "real_dir2");
} else {
- skipping("some symlink checks");
+ skipping("Symlinks are not supported on this platform");
}
/* "dir3" is a symlink to an existing "non_dir3" */
assertMakeFile("dest1/non_dir3", 0755, "abcdef");
@@ -118,9 +125,15 @@ DEFINE_TEST(test_symlink_dir)
assertMakeSymlink("dest2/file2", "real_file2");
assertEqualInt(0, systemf("%s -xPf test.tar -C dest2", testprog));
- /* dest2/dir symlink should be followed */
+ /* "dir4" is a symlink to existing "real_dir" */
+ if (canSymlink())
+ assertMakeSymlink("dest2/dir4", "real_dir");
+ assertEqualInt(0, systemf("%s -xPf test2.tar -C dest2", testprog));
+
+ /* dest2/dir and dest2/dir4 symlinks should be followed */
if (canSymlink()) {
assertIsSymlink("dest2/dir", "real_dir");
+ assertIsSymlink("dest2/dir4", "real_dir");
assertIsDir("dest2/real_dir", -1);
}
@@ -141,4 +154,7 @@ DEFINE_TEST(test_symlink_dir)
/* dest2/file2 symlink should be removed */
failure("Symlink to non-existing file should be removed");
assertIsReg("dest2/file2", -1);
+
+ /* dest2/dir4/file3 and dest2/dir4/file4 should be hard links */
+ assertIsHardlink("dest2/dir4/file3", "dest2/dir4/file4");
}
diff --git a/archivers/libarchive/files/tar/test/test_version.c b/archivers/libarchive/files/tar/test/test_version.c
index 5474261d207..1b896c0c49d 100644
--- a/archivers/libarchive/files/tar/test/test_version.c
+++ b/archivers/libarchive/files/tar/test/test_version.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2017 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_version.c,v 1.2 2008/05/26 17:10:10 kientzle Exp $");
/*
* Test that --version option works and generates reasonable output.
@@ -31,72 +30,5 @@ __FBSDID("$FreeBSD: src/usr.bin/tar/test/test_version.c,v 1.2 2008/05/26 17:10:1
DEFINE_TEST(test_version)
{
- int r;
- char *p, *q;
- size_t s;
-
-
- r = systemf("%s --version >version.stdout 2>version.stderr", testprog);
- if (r != 0)
- r = systemf("%s -W version >version.stdout 2>version.stderr",
- testprog);
- failure("Unable to run either %s --version or %s -W version",
- testprog, testprog);
- if (!assert(r == 0))
- return;
-
- /* --version should generate nothing to stdout. */
- assertEmptyFile("version.stderr");
- /* Verify format of version message. */
- q = p = slurpfile(&s, "version.stdout");
- /* Version message should start with name of program, then space. */
- assert(s > 6);
- failure("Version must start with 'bsdtar': ``%s''", p);
- if (!assertEqualMem(q, "bsdtar ", 7))
- return;
- q += 7; s -= 7;
- /* Version number is a series of digits and periods. */
- while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
- ++q;
- --s;
- }
- /* Version number terminated by space. */
- failure("No space after bsdtar version: ``%s''", p);
- assert(s > 1);
- /* Skip a single trailing a,b,c, or d. */
- if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
- ++q;
- failure("No space after bsdtar version: ``%s''", p);
- assert(*q == ' ');
- ++q; --s;
- /* Separator. */
- failure("No `-' between bsdtar and libarchive versions: ``%s''", p);
- assertEqualMem(q, "- ", 2);
- q += 2; s -= 2;
- /* libarchive name and version number */
- failure("Not long enough for libarchive version: ``%s''", p);
- assert(s > 11);
- failure("Libarchive version must start with `libarchive': ``%s''", p);
- assertEqualMem(q, "libarchive ", 11);
- q += 11; s -= 11;
- /* Version number is a series of digits and periods. */
- while (s > 0 && (*q == '.' || (*q >= '0' && *q <= '9'))) {
- ++q;
- --s;
- }
- /* Skip a single trailing a,b,c, or d. */
- if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
- ++q;
- /* Skip arbitrary third-party version numbers. */
- while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
- ++q;
- --s;
- }
- /* All terminated by end-of-line. */
- assert(s >= 1);
- /* Skip an optional CR character (e.g., Windows) */
- failure("Version output must end with \\n or \\r\\n");
- if (*q == '\r') { ++q; --s; }
- assertEqualMem(q, "\n", 1);
- free(p);
+ assertVersion(testprog, "bsdtar");
}
diff --git a/archivers/libarchive/files/tar/test/test_windows.c b/archivers/libarchive/files/tar/test/test_windows.c
index 1977ec644e6..d619667bfa6 100644
--- a/archivers/libarchive/files/tar/test/test_windows.c
+++ b/archivers/libarchive/files/tar/test/test_windows.c
@@ -133,7 +133,7 @@ DEFINE_TEST(test_windows)
char *fp1, *fp2;
/*
- * Preparre tests.
+ * Prepare tests.
* Create directories and files.
*/
assertMakeDir("tmp", 0775);