#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) */
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;
/* 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. */
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;
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. */
#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) */
#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) */