From 7c92210d78cedd1b894232af794f3492d55fbd32 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 2 Aug 2009 17:47:10 -0400 Subject: [PATCH] Use assertIsSymlink() instead of manual lstat()/readlink() SVN-Revision: 1317 --- cpio/test/test_basic.c | 18 +----------------- cpio/test/test_gcpio_compat.c | 20 +------------------- 2 files changed, 2 insertions(+), 36 deletions(-) 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); -- 2.47.3