diff options
author | kientzle <kientzle@FreeBSD.org> | 2007-04-14 22:34:10 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2007-04-14 22:34:10 +0000 |
commit | 7cead8e1b5557dab20b40aa5c83b5fabc472d1e3 (patch) | |
tree | f7c9108819c3e455e2359c0417fcbc48a4df0bb9 /lib/libarchive/test/test_read_format_ar.c | |
parent | d7e5af0175ad9acf090a0f95a484847cfcf3b392 (diff) | |
download | FreeBSD-src-7cead8e1b5557dab20b40aa5c83b5fabc472d1e3.zip FreeBSD-src-7cead8e1b5557dab20b40aa5c83b5fabc472d1e3.tar.gz |
Overhaul of 'ar' support:
* use "AR_GNU" as the format name instead of AR_SVR4 (it's what everyone is going to call it anyway)
* Simplify numeric parsing to unsigned (none of the numeric values should ever be negative); don't run off end of numeric fields.
* Finish parsing the common header fields before the next I/O request (which might dump the contents)
* Be smarter about format guessing and trimming filenames.
* Most of the magic values are only used in one place, so just inline them.
* Many more comments.
* Be smarter about handling damaged entries; return something reasonable.
* Call it a "filename table" instead of a "string table"
* Update tests.
Enable selection of 'ar', 'arbsd', and 'argnu' formats by name
(this allows bsdtar to create ar format archives).
The 'ar' writer still needs some work; it should reject
entries that aren't regular files and should probably also
strip leading paths from filenames.
Diffstat (limited to 'lib/libarchive/test/test_read_format_ar.c')
-rw-r--r-- | lib/libarchive/test/test_read_format_ar.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/libarchive/test/test_read_format_ar.c b/lib/libarchive/test/test_read_format_ar.c index d3e4f0e..7a2a1e4 100644 --- a/lib/libarchive/test/test_read_format_ar.c +++ b/lib/libarchive/test/test_read_format_ar.c @@ -64,17 +64,22 @@ DEFINE_TEST(test_read_format_ar) assertA(0 == archive_read_support_format_all(a)); assertA(0 == archive_read_open_memory(a, archive, sizeof(archive))); - /* First we meet the string table */ + /* Filename table. */ assertA(0 == archive_read_next_header(a, &ae)); - assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE); - assertA(archive_format(a) == ARCHIVE_FORMAT_AR); assert(0 == strcmp("//", archive_entry_pathname(ae))); - assert(40 == archive_entry_size(ae)); - assertA(40 == archive_read_data(a, buff, 45)); + assertEqualInt(0, archive_entry_mtime(ae)); + assertEqualInt(0, archive_entry_uid(ae)); + assertEqualInt(0, archive_entry_gid(ae)); + assertEqualInt(40, archive_entry_size(ae)); + assertEqualIntA(a, 40, archive_read_data(a, buff, 50)); + assert(0 == memcmp(buff, "yyytttsssaaafff.o/\nhhhhjjjjkkkkllll.o/\n\n", 40)); /* First Entry */ assertA(0 == archive_read_next_header(a, &ae)); assert(0 == strcmp("yyytttsssaaafff.o", archive_entry_pathname(ae))); + assertEqualInt(1175465652, archive_entry_mtime(ae)); + assertEqualInt(1001, archive_entry_uid(ae)); + assertEqualInt(0, archive_entry_gid(ae)); assert(8 == archive_entry_size(ae)); assertA(8 == archive_read_data(a, buff, 10)); assert(0 == memcmp(buff, "55667788", 8)); @@ -82,6 +87,9 @@ DEFINE_TEST(test_read_format_ar) /* Second Entry */ assertA(0 == archive_read_next_header(a, &ae)); assert(0 == strcmp("gghh.o", archive_entry_pathname(ae))); + assertEqualInt(1175465668, archive_entry_mtime(ae)); + assertEqualInt(1001, archive_entry_uid(ae)); + assertEqualInt(0, archive_entry_gid(ae)); assert(4 == archive_entry_size(ae)); assertA(4 == archive_read_data(a, buff, 10)); assert(0 == memcmp(buff, "3333", 4)); @@ -89,6 +97,9 @@ DEFINE_TEST(test_read_format_ar) /* Third Entry */ assertA(0 == archive_read_next_header(a, &ae)); assert(0 == strcmp("hhhhjjjjkkkkllll.o", archive_entry_pathname(ae))); + assertEqualInt(1175465713, archive_entry_mtime(ae)); + assertEqualInt(1001, archive_entry_uid(ae)); + assertEqualInt(0, archive_entry_gid(ae)); assert(9 == archive_entry_size(ae)); assertA(9 == archive_read_data(a, buff, 9)); assert(0 == memcmp(buff, "987654321", 9)); |