]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Use assertIsSymlink() instead of manual lstat()/readlink()
authorTim Kientzle <kientzle@gmail.com>
Sun, 2 Aug 2009 21:47:10 +0000 (17:47 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 2 Aug 2009 21:47:10 +0000 (17:47 -0400)
SVN-Revision: 1317

cpio/test/test_basic.c
cpio/test/test_gcpio_compat.c

index 96137233cb16c985eec62b58bef6074c8d30a7cd..13bddfaea4892f55853799237d421a23fce23a38 100644 (file)
@@ -29,9 +29,6 @@ static void
 verify_files(const char *target)
 {
        struct stat st, st2;
-#if !defined(_WIN32) || defined(__CYGWIN__)
-       char buff[128];
-#endif
        int r;
 
        /*
@@ -78,21 +75,8 @@ verify_files(const char *target)
        }
 
        /* Symlink */
-       r = lstat("symlink", &st);
-       failure("Failed to stat file %s/symlink, errno=%d", target, errno);
-       assertEqualInt(r, 0);
 #if !defined(_WIN32) || defined(__CYGWIN__)
-       if (r == 0) {
-               failure("symlink should be a symlink; actual mode is %o",
-                   st.st_mode);
-               assert(S_ISLNK(st.st_mode));
-               if (S_ISLNK(st.st_mode)) {
-                       r = readlink("symlink", buff, sizeof(buff));
-                       assertEqualInt(r, 4);
-                       buff[r] = '\0';
-                       assertEqualString(buff, "file");
-               }
-       }
+       assertIsSymlink("symlink", "file");
 #endif
 
        /* Another file with 1 link and different permissions. */
index f9604b98a99cffb032b1e553a51a576b2ac83e78..21b75cd028fc364559e98b0d99b7e05263e6e41d 100644 (file)
@@ -29,9 +29,6 @@ static void
 unpack_test(const char *from, const char *options, const char *se)
 {
        struct stat st, st2;
-#if !defined(_WIN32) || defined(__CYGWIN__)
-       char buff[128];
-#endif
        int r;
 
        /* Create a work dir named after the file we're unpacking. */
@@ -95,22 +92,7 @@ unpack_test(const char *from, const char *options, const char *se)
        }
 
        /* Symlink */
-       r = lstat("symlink", &st);
-       failure("Failed to stat file %s/symlink, errno=%d", from, errno);
-       assertEqualInt(r, 0);
-#if !defined(_WIN32) || defined(__CYGWIN__)
-       if (r == 0) {
-               failure("symlink should be a symlink; actual mode is %o",
-                   st.st_mode);
-               assert(S_ISLNK(st.st_mode));
-               if (S_ISLNK(st.st_mode)) {
-                       r = readlink("symlink", buff, sizeof(buff));
-                       assertEqualInt(r, 4);
-                       buff[r] = '\0';
-                       assertEqualString(buff, "file");
-               }
-       }
-#endif
+       assertIsSymlink("symlink", "file");
 
        /* dir */
        r = lstat("dir", &st);