From: Tim Kientzle Date: Sun, 11 Sep 2011 18:38:39 +0000 (-0400) Subject: More tweaks to mtree numeric range tests. X-Git-Tag: v3.0.0a~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f532d011ceeadd51258232a0a7ab3d96085ae228;p=thirdparty%2Flibarchive.git More tweaks to mtree numeric range tests. SVN-Revision: 3701 --- diff --git a/libarchive/test/test_read_format_mtree.c b/libarchive/test/test_read_format_mtree.c index da525fb67..94265b20e 100644 --- a/libarchive/test/test_read_format_mtree.c +++ b/libarchive/test/test_read_format_mtree.c @@ -33,7 +33,7 @@ test_read_format_mtree1(void) struct archive_entry *ae; struct archive *a; FILE *f; - // Compute min and max 64-bit signed twos-complement values + // Compute max 64-bit signed twos-complement value // without relying on overflow. This assumes that long long // is at least 64 bits. const static long long max_int64 = ((((long long)1) << 62) - 1) + (((long long)1) << 62); @@ -117,21 +117,25 @@ test_read_format_mtree1(void) assertEqualString(archive_entry_pathname(ae), "dir2/smallfile"); assertEqualInt(archive_entry_size(ae), 1); + /* TODO: Mtree reader should probably return ARCHIVE_WARN for this. */ + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString(archive_entry_pathname(ae), "dir2/toosmallfile"); + assertEqualInt(archive_entry_size(ae), -1); + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/bigfile"); assertEqualInt(archive_entry_size(ae), max_int64); - /* Size of this file is actually max_int64 + 1, but that should - * overflow and be returned as max_int64. */ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/toobigfile"); + /* Size in mtree is max_int64 + 1; should return max_int64. */ assertEqualInt(archive_entry_size(ae), max_int64); assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualString(archive_entry_pathname(ae), "dir2/veryoldfile"); - /* We can't know exact value here without knowing range of time_t. */ - min_time = archive_entry_mtime(ae); + /* The value in the file is MIN_INT64_T, but time_t may be narrower. */ /* Verify min_time is the smallest possible time_t. */ + min_time = archive_entry_mtime(ae); assert(min_time <= 0); assert(min_time - 1 > 0); @@ -142,7 +146,7 @@ test_read_format_mtree1(void) assertEqualInt(archive_entry_mtime(ae), min_time); assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); - assertEqualInt(18, archive_file_count(a)); + assertEqualInt(19, archive_file_count(a)); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); } diff --git a/libarchive/test/test_read_format_mtree.mtree.uu b/libarchive/test/test_read_format_mtree.mtree.uu index 993875fe7..a0dff18e4 100644 --- a/libarchive/test/test_read_format_mtree.mtree.uu +++ b/libarchive/test/test_read_format_mtree.mtree.uu @@ -8,11 +8,11 @@ M"B!I;F1I7!E/61I<@H@(&EN9&ER,V(@ M='EP93UF:6QE"B`@+BX*("XN"FYO=&EN9&ER('1Y<&4]9FEL90ID:7(R+V9U M;&QI;F1I7!E/69I;&4@7!E/69I;&4@=&EM93TM.3(R,S,W,C`S-C@U-#F4]+3$*9&ER,B]B:6=F:6QE('1Y<&4]9FEL92!S:7IE/3DR +M,C,S-S(P,S8X-30W-S4X,#<*9&ER,B]T;V]B:6=F:6QE('1Y<&4]9FEL92!S +M:7IE/3DR,C,S-S(P,S8X-30W-S4X,#@*9&ER,B]V97)Y;VQD9FEL92!T>7!E +M/69I;&4@=&EM93TM.3(R,S,W,C`S-C@U-#