]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Reduce the differences between libarchive/test/main.c and tar/test/main.c.
authorTim Kientzle <kientzle@gmail.com>
Sun, 2 Aug 2009 20:01:21 +0000 (16:01 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 2 Aug 2009 20:01:21 +0000 (16:01 -0400)
SVN-Revision: 1309

libarchive/test/main.c
tar/config_freebsd.h
tar/test/main.c
tar/test/test.h
tar/test/test_basic.c
tar/test/test_copy.c
tar/test/test_strip_components.c

index d59e35115e39291f0d16a19b1c22d192bc377f27..652934050480e15aa37777afca999dd9337d19be 100644 (file)
@@ -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];
index 81313c3111aef8f3a9b04e5d38f45991ca8b5809..c0b057adef04730188a0db5bda5de9b359e12f15 100644 (file)
@@ -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
index 8891e90fc260b0b0eb4274a4df9e6bf5caf8b18b..2dedfecb9a820946a197e1c5c6e1ad71b14c9f18 100644 (file)
@@ -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;
 
index 62a47849e2d34fa59f1a9859df3ffbd73d0869c8..996eb6b3579ce4307bcbed64f8bbae7bd8df993e 100644 (file)
   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 *);
index ef287e238da8fd9ea9adf09fd4595a1d80c50848..aa5995f5f005bc4c6811d1779d41714892537445 100644 (file)
@@ -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 */
index 04660edddddd09aca1d1568135ea20da49c216e0..c48cdfea620916955b0c561d33f162e145094d39 100644 (file)
@@ -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
index 64743e71c146a0156b31fc4e1aa0e193cc169ad6..2ae1081840f4f7f7470c21f076b1df786c9d39dd 100644 (file)
@@ -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