The newc-format verification is now a little smarter about
following the archive structure. In particular, it no longer crashes if you run it against GNU cpio 2.9 (although it does still complain a lot more than it should).
This commit is contained in:
parent
83cb61fa3a
commit
643cd4ffe7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=181986
@ -68,7 +68,7 @@ DEFINE_TEST(test_format_newc)
|
||||
int devmajor, devminor, ino, gid;
|
||||
time_t t, t2, now;
|
||||
char *p, *e;
|
||||
size_t s;
|
||||
size_t s, fs, ns;
|
||||
mode_t oldmask;
|
||||
|
||||
oldmask = umask(0);
|
||||
@ -141,16 +141,21 @@ DEFINE_TEST(test_format_newc)
|
||||
" first appearance should be empty, so this file size\n"
|
||||
" field should be zero");
|
||||
assertEqualInt(0, from_hex(e + 54, 8)); /* File size */
|
||||
fs = from_hex(e + 54, 8);
|
||||
fs += 3 & -fs;
|
||||
devmajor = from_hex(e + 62, 8); /* devmajor */
|
||||
devminor = from_hex(e + 70, 8); /* devminor */
|
||||
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
||||
assert(is_hex(e + 86, 8)); /* rdevminor */
|
||||
assertEqualMem(e + 94, "00000006", 8); /* Name size */
|
||||
ns = from_hex(e + 94, 8);
|
||||
ns += 3 & (-ns - 2);
|
||||
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
||||
assertEqualMem(e + 110, "file1\0", 6); /* Name contents */
|
||||
/* Since there's another link, no file contents here. */
|
||||
/* But add in file size so that an error here doesn't cascade. */
|
||||
e += 116 + from_hex(e + 54, 8) + (3 & -from_hex(e + 54, 8));
|
||||
e += 110 + fs + ns;
|
||||
|
||||
/* "symlink" pointing to "file1" */
|
||||
assert(is_hex(e, 110));
|
||||
assertEqualMem(e + 0, "070701", 6); /* Magic */
|
||||
@ -163,15 +168,19 @@ DEFINE_TEST(test_format_newc)
|
||||
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 */
|
||||
fs = from_hex(e + 54, 8);
|
||||
fs += 3 & -fs;
|
||||
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
||||
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
||||
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
||||
assert(is_hex(e + 86, 8)); /* rdevminor */
|
||||
assertEqualMem(e + 94, "00000008", 8); /* Name size */
|
||||
ns = from_hex(e + 94, 8);
|
||||
ns += 3 & (-ns - 2);
|
||||
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
||||
assertEqualMem(e + 110, "symlink\0\0\0", 10); /* Name contents */
|
||||
assertEqualMem(e + 120, "file1\0\0\0", 8); /* symlink target */
|
||||
e += 120 + from_hex(e + 54, 8) + (3 & -from_hex(e + 54, 8));
|
||||
assertEqualMem(e + 110 + ns, "file1\0\0\0", 8); /* symlink target */
|
||||
e += 110 + fs + ns;
|
||||
|
||||
/* "dir" */
|
||||
assert(is_hex(e, 110));
|
||||
@ -185,16 +194,18 @@ DEFINE_TEST(test_format_newc)
|
||||
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 */
|
||||
fs = from_hex(e + 54, 8);
|
||||
fs += 3 & -fs;
|
||||
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
||||
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
||||
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
||||
assert(is_hex(e + 86, 8)); /* rdevminor */
|
||||
assertEqualMem(e + 94, "00000004", 8); /* Name size */
|
||||
ns = from_hex(e + 94, 8);
|
||||
ns += 3 & (-ns - 2);
|
||||
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
||||
assertEqualMem(e + 110, "dir\0\0\0", 6); /* Name contents */
|
||||
e += 116;
|
||||
|
||||
/* TODO: Verify other types of entries. */
|
||||
e += 110 + fs + ns;
|
||||
|
||||
/* Hardlink identical to "file1" */
|
||||
/* Since we only wrote two of the three links to this
|
||||
@ -211,15 +222,19 @@ DEFINE_TEST(test_format_newc)
|
||||
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 */
|
||||
fs = from_hex(e + 54, 8);
|
||||
fs += 3 & -fs;
|
||||
assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */
|
||||
assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */
|
||||
assert(is_hex(e + 78, 8)); /* rdevmajor */
|
||||
assert(is_hex(e + 86, 8)); /* rdevminor */
|
||||
assertEqualMem(e + 94, "00000009", 8); /* Name size */
|
||||
ns = from_hex(e + 94, 8);
|
||||
ns += 3 & (-ns - 2);
|
||||
assertEqualInt(0, from_hex(e + 102, 8)); /* check field */
|
||||
assertEqualMem(e + 110, "hardlink\0\0", 10); /* Name contents */
|
||||
assertEqualMem(e + 120, "123456789\0\0\0", 12); /* File contents */
|
||||
e += 120 + from_hex(e + 54, 8) + (3 & -from_hex(e + 54, 8));
|
||||
assertEqualMem(e + 110 + ns, "123456789\0\0\0", 12); /* File contents */
|
||||
e += 110 + ns + fs;
|
||||
|
||||
/* Last entry is end-of-archive marker. */
|
||||
assert(is_hex(e, 110));
|
||||
|
Loading…
Reference in New Issue
Block a user