diff --git a/cpio/test/test.h b/cpio/test/test.h index 05fa2c3810..9d2c7d7881 100644 --- a/cpio/test/test.h +++ b/cpio/test/test.h @@ -101,13 +101,6 @@ #pragma warn -8068 /* Constant out of range in comparison. */ #endif -/* Cygwin */ -#if defined(__CYGWIN__) -/* Cygwin-1.7.x is lazy about populating nlinks, so don't - * expect it to be accurate. */ -# define NLINKS_INACCURATE_FOR_DIRS -#endif - /* Haiku OS and QNX */ #if defined(__HAIKU__) || defined(__QNXNTO__) /* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */ diff --git a/cpio/test/test_format_newc.c b/cpio/test/test_format_newc.c index e1047e5b4e..365859a521 100644 --- a/cpio/test/test_format_newc.c +++ b/cpio/test/test_format_newc.c @@ -68,6 +68,14 @@ from_hex(const char *p, size_t l) return (r); } +static int +nlinks(const char *p) +{ + struct stat st; + assertEqualInt(0, stat(p, &st)); + return st.st_nlink; +} + DEFINE_TEST(test_format_newc) { FILE *list; @@ -241,11 +249,9 @@ DEFINE_TEST(test_format_newc) /* Mode: sgid bit sometimes propagates from parent dirs, ignore it. */ assertEqualInt(040775, from_hex(e + 14, 8) & ~02000); #endif - assertEqualInt(from_hex(e + 22, 8), uid); /* uid */ + assertEqualInt(uid, from_hex(e + 22, 8)); /* uid */ assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */ -#ifndef NLINKS_INACCURATE_FOR_DIRS - assertEqualMem(e + 38, "00000002", 8); /* nlink */ -#endif + assertEqualInt(nlinks("dir"), from_hex(e + 38, 8)); /* nlinks */ t2 = from_hex(e + 46, 8); /* mtime */ failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2); assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */ diff --git a/cpio/test/test_option_c.c b/cpio/test/test_option_c.c index 241bcf67bb..f9fbc92df0 100644 --- a/cpio/test/test_option_c.c +++ b/cpio/test/test_option_c.c @@ -51,6 +51,14 @@ from_octal(const char *p, size_t l) return (r); } +static int +nlinks(const char *p) +{ + struct stat st; + assertEqualInt(0, stat(p, &st)); + return st.st_nlink; +} + DEFINE_TEST(test_option_c) { FILE *filelist; @@ -185,13 +193,13 @@ DEFINE_TEST(test_option_c) if (memcmp(e + 18, "042775", 6) != 0) assertEqualMem(e + 18, "040775", 6); /* Mode */ #endif - assertEqualInt(from_octal(e + 24, 6), uid); /* uid */ + assertEqualInt(uid, from_octal(e + 24, 6)); /* uid */ /* Gid should be same as first entry. */ assert(is_octal(e + 30, 6)); /* gid */ assertEqualInt(gid, from_octal(e + 30, 6)); -#ifndef NLINKS_INACCURATE_FOR_DIRS - assertEqualMem(e + 36, "000002", 6); /* Nlink */ -#endif + + assertEqualInt(nlinks("dir"), from_octal(e + 36, 6)); /* Nlink */ + t = from_octal(e + 48, 11); /* mtime */ assert(t <= now); /* File wasn't created in future. */ assert(t >= now - 2); /* File was created w/in last 2 secs. */ diff --git a/libarchive/test/test.h b/libarchive/test/test.h index d9c6a08ec1..19aee761a0 100644 --- a/libarchive/test/test.h +++ b/libarchive/test/test.h @@ -97,13 +97,6 @@ #pragma warn -8068 /* Constant out of range in comparison. */ #endif -/* Cygwin */ -#if defined(__CYGWIN__) -/* Cygwin-1.7.x is lazy about populating nlinks, so don't - * expect it to be accurate. */ -# define NLINKS_INACCURATE_FOR_DIRS -#endif - /* Haiku OS and QNX */ #if defined(__HAIKU__) || defined(__QNXNTO__) /* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */ diff --git a/tar/test/test.h b/tar/test/test.h index c4088cbbae..7166493a20 100644 --- a/tar/test/test.h +++ b/tar/test/test.h @@ -101,13 +101,6 @@ #pragma warn -8068 /* Constant out of range in comparison. */ #endif -/* Cygwin */ -#if defined(__CYGWIN__) -/* Cygwin-1.7.x is lazy about populating nlinks, so don't - * expect it to be accurate. */ -# define NLINKS_INACCURATE_FOR_DIRS -#endif - /* Haiku OS and QNX */ #if defined(__HAIKU__) || defined(__QNXNTO__) /* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */