]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
We can always assert that the uid is the same for all entries.
authorTim Kientzle <kientzle@gmail.com>
Mon, 3 Aug 2009 03:12:55 +0000 (23:12 -0400)
committerTim Kientzle <kientzle@gmail.com>
Mon, 3 Aug 2009 03:12:55 +0000 (23:12 -0400)
If we are on POSIX, we can further assert that the uid is the current user.

SVN-Revision: 1332

cpio/test/test_format_newc.c

index f39db433e5f76cefcce04d2e6d6612a821ec3fc9..de48ec3b35f0f3242823ada3c8bde75276075248 100644 (file)
@@ -66,12 +66,17 @@ DEFINE_TEST(test_format_newc)
        FILE *list;
        int r;
        int devmajor, devminor, ino, gid;
+       int uid = -1;
        time_t t, t2, now;
        char *p, *e;
        size_t s, fs, ns;
 
        assertUmask(0);
 
+#if !defined(_WIN32)
+       uid = getuid();
+#endif
+
        /*
         * Create an assortment of files.
         * TODO: Extend this to cover more filetypes.
@@ -130,7 +135,9 @@ DEFINE_TEST(test_format_newc)
 #else
        assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */
 #endif
-       assertEqualInt(from_hex(e + 22, 8), getuid()); /* uid */
+       if (uid < 0)
+               uid = from_hex(e + 22, 8);
+       assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
        gid = from_hex(e + 30, 8); /* gid */
        assertEqualMem(e + 38, "00000003", 8); /* nlink */
        t = from_hex(e + 46, 8); /* mtime */
@@ -166,7 +173,7 @@ DEFINE_TEST(test_format_newc)
         * others bits do not work. */ 
        assertEqualInt(0xa1ff, from_hex(e + 14, 8)); /* Mode */
 #endif
-       assertEqualInt(from_hex(e + 22, 8), getuid()); /* uid */
+       assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
        assertEqualMem(e + 38, "00000001", 8); /* nlink */
        t2 = from_hex(e + 46, 8); /* mtime */
@@ -205,7 +212,7 @@ 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), getuid()); /* uid */
+       assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
 #ifndef NLINKS_INACCURATE_FOR_DIRS
        assertEqualMem(e + 38, "00000002", 8); /* nlink */
@@ -240,7 +247,7 @@ DEFINE_TEST(test_format_newc)
 #else
        assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */
 #endif
-       assertEqualInt(from_hex(e + 22, 8), getuid()); /* uid */
+       assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
        assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
        assertEqualMem(e + 38, "00000003", 8); /* nlink */
        t2 = from_hex(e + 46, 8); /* mtime */