From: Tim Kientzle Date: Sun, 2 Aug 2009 21:47:10 +0000 (-0400) Subject: Use assertIsSymlink() instead of manual lstat()/readlink() X-Git-Tag: v2.8.0~470 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c92210d78cedd1b894232af794f3492d55fbd32;p=thirdparty%2Flibarchive.git Use assertIsSymlink() instead of manual lstat()/readlink() SVN-Revision: 1317 --- diff --git a/cpio/test/test_basic.c b/cpio/test/test_basic.c index 96137233c..13bddfaea 100644 --- a/cpio/test/test_basic.c +++ b/cpio/test/test_basic.c @@ -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. */ diff --git a/cpio/test/test_gcpio_compat.c b/cpio/test/test_gcpio_compat.c index f9604b98a..21b75cd02 100644 --- a/cpio/test/test_gcpio_compat.c +++ b/cpio/test/test_gcpio_compat.c @@ -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);