]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix a small race in the format check for cpio; the four entries
authorTim Kientzle <kientzle@gmail.com>
Sun, 11 May 2008 14:47:11 +0000 (10:47 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 11 May 2008 14:47:11 +0000 (10:47 -0400)
might get slightly different timestamps.

SVN-Revision: 40

cpio/test/test_format_newc.c

index 1c84dc4c6fb227003cb9bebd372ccdab7e97b9bc..0714bd427e2194875745156b1e02754729aa83cf 100644 (file)
@@ -66,7 +66,7 @@ DEFINE_TEST(test_format_newc)
        int fd, list;
        int r;
        int devmajor, devminor, ino, gid;
-       time_t t, now;
+       time_t t, t2, now;
        char *p, *e;
        size_t s;
        mode_t oldmask;
@@ -159,7 +159,9 @@ DEFINE_TEST(test_format_newc)
        assertEqualInt(from_hex(e + 22, 8), getuid()); /* uid */
        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
        assertEqualMem(e + 38, "00000001", 8); /* nlink */
-       assertEqualInt(t, from_hex(e + 46, 8)); /* mtime */
+       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. */
        assertEqualMem(e + 54, "00000005", 8); /* File size */
        assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
        assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
@@ -179,7 +181,9 @@ DEFINE_TEST(test_format_newc)
        assertEqualInt(from_hex(e + 22, 8), getuid()); /* uid */
        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
        assertEqualMem(e + 38, "00000002", 8); /* nlink */
-       assertEqualInt(t, from_hex(e + 46, 8)); /* mtime */
+       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. */
        assertEqualMem(e + 54, "00000000", 8); /* File size */
        assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
        assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
@@ -203,7 +207,9 @@ DEFINE_TEST(test_format_newc)
        assertEqualInt(from_hex(e + 22, 8), getuid()); /* uid */
        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
        assertEqualMem(e + 38, "00000003", 8); /* nlink */
-       assertEqualInt(t, from_hex(e + 46, 8)); /* mtime */
+       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. */
        assertEqualInt(10, from_hex(e + 54, 8)); /* File size */
        assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
        assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */