]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 15, part 6. Fix test failure on cygwin-1.7.x
authorCharles Wilson <cwilso11@gmail.com>
Thu, 19 Mar 2009 02:54:30 +0000 (22:54 -0400)
committerCharles Wilson <cwilso11@gmail.com>
Thu, 19 Mar 2009 02:54:30 +0000 (22:54 -0400)
  In cpio/test/tests.h: new #define to disable certain
  tests on cygwin. POSIX does not require that the .nlinks
  field be accurate for directories, and as an optimization
  newer cygwin does not even try to ensure its accuracy.
  Therefore, it is not a failure if wrong; cpio tests should
  not verify its value -- at least on cygwin.
  cpio/test/test_format_newc.c: Use new #define to skip
     .nlinks test.
  cpio/test/test_option_c.c: ditto.

SVN-Revision: 802

cpio/test/test.h
cpio/test/test_format_newc.c
cpio/test/test_option_c.c

index 090b039ba815262a25cd67d9fc53c118a719c150..5aa4ed6c92703f6112d60c2053ec749034c2365e 100644 (file)
 #else
 #include "../cpio_windows.h"
 #endif
+#if defined(__CYGWIN__)
+/* In cygwin-1.7.x, the .nlinks field of directories is
+ * deliberately inaccurate, because to populate it requires
+ * stat'ing every file in the directory, which is slow.
+ * So, as an optimization cygwin doesn't do that in newer
+ * releases; all correct applications on any platform should
+ * never rely on it being > 1, so this optimization doesn't
+ * impact the operation of correctly coded applications.
+ * Therefore, the cpio test should not check its accuracy
+ */
+# define NLINKS_INACCURATE_FOR_DIRS
+#endif
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
index 1c3ae565841408581f1b61ebf31f865a8e9b8bd0..18a6c7bc8b81f6888e2455240de45e19e133ab4f 100644 (file)
@@ -210,7 +210,9 @@ DEFINE_TEST(test_format_newc)
 #endif
        assertEqualInt(from_hex(e + 22, 8), getuid()); /* uid */
        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
+#ifndef NLINKS_INACCURATE_FOR_DIRS
        assertEqualMem(e + 38, "00000002", 8); /* nlink */
+#endif
        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. */
index 6da080bfd7aea2e138d4aed911742bf54637f8cb..2f4e3bc586f20aa778a11e29935baa5f7df81f2f 100644 (file)
@@ -191,7 +191,9 @@ DEFINE_TEST(test_option_c)
        /* 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
        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. */