From: Tim Kientzle Date: Sun, 2 Aug 2009 20:01:21 +0000 (-0400) Subject: Reduce the differences between libarchive/test/main.c and tar/test/main.c. X-Git-Tag: v2.8.0~474 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0ddea17b42e2570c1786aaa03c6a76fba8d674d;p=thirdparty%2Flibarchive.git Reduce the differences between libarchive/test/main.c and tar/test/main.c. SVN-Revision: 1309 --- diff --git a/libarchive/test/main.c b/libarchive/test/main.c index d59e35115..652934050 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -946,6 +946,13 @@ test_assert_is_symlink(const char *file, int line, const char *pathname, const char *contents) { #if defined(_WIN32) && !defined(__CYGWIN__) + // TODO: Vista supports symlinks + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Symlink ``%s'' not supported\n", + file, line, pathname); + report_failure(NULL); + } return (0); #else char buff[300]; diff --git a/tar/config_freebsd.h b/tar/config_freebsd.h index 81313c311..c0b057ade 100644 --- a/tar/config_freebsd.h +++ b/tar/config_freebsd.h @@ -43,6 +43,7 @@ #undef HAVE_LIBACL #define HAVE_LIBARCHIVE 1 #define HAVE_LIMITS_H 1 +#define HAVE_LINK 1 #undef HAVE_LINUX_EXT2_FS_H #undef HAVE_LINUX_FS_H #define HAVE_LOCALE_H 1 @@ -53,6 +54,7 @@ #endif #define HAVE_PATHS_H 1 #define HAVE_PWD_H 1 +#define HAVE_READLINK 1 #define HAVE_REGEX_H 1 #define HAVE_SETLOCALE 1 #define HAVE_SIGNAL_H 1 @@ -65,6 +67,7 @@ #undef HAVE_STRUCT_STAT_ST_MTIME_USEC #define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1 #undef HAVE_STRUCT_STAT_ST_UMTIME +#define HAVE_SYMLINK 1 #undef HAVE_SYS_DIR_H #define HAVE_SYS_IOCTL_H 1 #undef HAVE_SYS_NDIR_H diff --git a/tar/test/main.c b/tar/test/main.c index 8891e90fc..2dedfecb9 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -50,6 +50,7 @@ #define S_ISREG(m) ((m) & _S_IFREG) #endif #define access _access +#define chdir _chdir #ifndef fileno #define fileno _fileno #endif @@ -762,10 +763,10 @@ test_assert_file_contents(const void *buff, int s, const char *fpattern, ...) test_filename, test_line); fprintf(stderr, " file=\"%s\"\n", fn); if (n > 0) - hexdump(contents, buff, n, 0); + hexdump(contents, buff, n > 512 ? 512 : 0, 0); else { fprintf(stderr, " File empty, contents should be:\n"); - hexdump(buff, NULL, s, 0); + hexdump(buff, NULL, s > 512 ? 512 : 0, 0); } report_failure(test_extra); } @@ -913,7 +914,7 @@ test_assert_is_dir(const char *file, int line, const char *pathname, int mode) count_assertion(file, line); r = lstat(pathname, &st); - if (r != 0 || !S_ISDIR(st.st_mode)) { + if (r != 0) { ++failures; if (!previous_failures(file, line, 1)) { fprintf(stderr, "%s:%d: Dir ``%s'' doesn't exist\n", @@ -922,8 +923,19 @@ test_assert_is_dir(const char *file, int line, const char *pathname, int mode) } return (0); } - if (mode < 0) + if (!S_ISDIR(st.st_mode)) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: ``%s'' is not a dir\n", + file, line, pathname); + report_failure(NULL); + } + return (0); + } + if (mode < 0) { + msg[0] = '\0'; return (1); + } if (mode != (st.st_mode & 07777)) { ++failures; if (!previous_failures(file, line, 1)) { @@ -935,11 +947,12 @@ test_assert_is_dir(const char *file, int line, const char *pathname, int mode) } return (0); } + msg[0] = '\0'; return (1); } int -test_assert_is_link(const char *file, int line, +test_assert_is_symlink(const char *file, int line, const char *pathname, const char *contents) { #if defined(_WIN32) && !defined(__CYGWIN__) @@ -1093,7 +1106,7 @@ test_assert_make_hardlink(const char *file, int line, int test_assert_make_symlink(const char *file, int line, - const char *newpath, const char *linkto) + const char *newpath, const char *linkto) { int succeeded; diff --git a/tar/test/test.h b/tar/test/test.h index 62a47849e..996eb6b35 100644 --- a/tar/test/test.h +++ b/tar/test/test.h @@ -156,10 +156,10 @@ test_setup(__FILE__, __LINE__);test_assert_text_file_contents #define assertIsDir(pathname, mode) \ test_assert_is_dir(__FILE__, __LINE__, pathname, mode) -#define assertIsLink(pathname, contents) \ - test_assert_is_link(__FILE__, __LINE__, pathname, contents) #define assertIsReg(pathname, mode) \ test_assert_is_reg(__FILE__, __LINE__, pathname, mode) +#define assertIsSymlink(pathname, contents) \ + test_assert_is_symlink(__FILE__, __LINE__, pathname, contents) /* Create a directory, report error if it fails. */ #define assertMakeDir(dirname, mode) \ test_assert_make_dir(__FILE__, __LINE__, dirname, mode) @@ -200,8 +200,8 @@ int test_assert_file_not_exists(const char *, ...); int test_assert_file_nlinks(const char *, int, const char *, int); int test_assert_file_size(const char *, int, const char *, long); int test_assert_is_dir(const char *, int, const char *, int); -int test_assert_is_link(const char *, int, const char *, const char *); int test_assert_is_reg(const char *, int, const char *, int); +int test_assert_is_symlink(const char *, int, const char *, const char *); int test_assert_make_dir(const char *, int, const char *, int); int test_assert_make_hardlink(const char *, int, const char *newpath, const char *); int test_assert_make_symlink(const char *, int, const char *newpath, const char *); diff --git a/tar/test/test_basic.c b/tar/test/test_basic.c index ef287e238..aa5995f5f 100644 --- a/tar/test/test_basic.c +++ b/tar/test/test_basic.c @@ -71,7 +71,7 @@ basic_tar(const char *target, const char *pack_options, #if !defined(_WIN32) || defined(__CYGWIN__) /* Symlink */ - assertIsLink("symlink", "file"); + assertIsSymlink("symlink", "file"); #endif /* dir */ diff --git a/tar/test/test_copy.c b/tar/test/test_copy.c index 04660eddd..c48cdfea6 100644 --- a/tar/test/test_copy.c +++ b/tar/test/test_copy.c @@ -222,7 +222,7 @@ verify_tree(int limit) strcpy(name2, "../f/"); strcat(name2, filename); if (limit != LIMIT_USTAR || strlen(name2) <= 100) - assertIsLink(name1, name2); + assertIsSymlink(name1, name2); #else skipping("verify symlink"); #endif diff --git a/tar/test/test_strip_components.c b/tar/test/test_strip_components.c index 64743e71c..2ae108184 100644 --- a/tar/test/test_strip_components.c +++ b/tar/test/test_strip_components.c @@ -64,7 +64,7 @@ DEFINE_TEST(test_strip_components) failure("d0/d1/s2 is a symlink to something that won't be extracted"); #if !defined(_WIN32) || defined(__CYGWIN__) assertFileNotExists("target/s2"); - assertIsLink("target/s2", "d2/f1"); + assertIsSymlink("target/s2", "d2/f1"); #else skipping("symlink"); #endif