From: Charles Wilson Date: Thu, 19 Mar 2009 02:54:30 +0000 (-0400) Subject: Issue 15, part 6. Fix test failure on cygwin-1.7.x X-Git-Tag: v2.7.0~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbf42b59e5b2825909a64f584e33a0c96b909593;p=thirdparty%2Flibarchive.git Issue 15, part 6. Fix test failure on cygwin-1.7.x 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 --- diff --git a/cpio/test/test.h b/cpio/test/test.h index 090b039ba..5aa4ed6c9 100644 --- a/cpio/test/test.h +++ b/cpio/test/test.h @@ -50,6 +50,18 @@ #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 #include #include diff --git a/cpio/test/test_format_newc.c b/cpio/test/test_format_newc.c index 1c3ae5658..18a6c7bc8 100644 --- a/cpio/test/test_format_newc.c +++ b/cpio/test/test_format_newc.c @@ -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. */ diff --git a/cpio/test/test_option_c.c b/cpio/test/test_option_c.c index 6da080bfd..2f4e3bc58 100644 --- a/cpio/test/test_option_c.c +++ b/cpio/test/test_option_c.c @@ -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. */