From: Tim Kientzle Date: Sat, 5 Nov 2011 04:16:35 +0000 (-0400) Subject: Add a test inspired by Issue #186. X-Git-Tag: v3.0.0a~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44a85834ef84b95eec7fc830edd7f4d9ed4a6f54;p=thirdparty%2Flibarchive.git Add a test inspired by Issue #186. I believe this shows that the issue reported there is not due to a problem in libarchive. SVN-Revision: 3747 --- diff --git a/libarchive/test/test_read_format_mtree.c b/libarchive/test/test_read_format_mtree.c index 94265b20e..304bb5876 100644 --- a/libarchive/test/test_read_format_mtree.c +++ b/libarchive/test/test_read_format_mtree.c @@ -302,6 +302,40 @@ test_read_format_mtree4(void) assertChdir(".."); } +/* + * We should get a warning if the contents file doesn't exist. + */ +static void +test_read_format_mtree5(void) +{ + static char archive[] = + "#mtree\n" + "a type=file contents=nonexistent_file\n"; + struct archive_entry *ae; + struct archive *a; + + assertMakeDir("mtree5", 0777); + assertChdir("mtree5"); + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_support_filter_all(a)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_support_format_all(a)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_memory(a, archive, sizeof(archive))); + assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); + assert(strlen(archive_error_string(a)) > 0); + assertEqualString(archive_entry_pathname(ae), "a"); + assertEqualInt(archive_entry_filetype(ae), AE_IFREG); + + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + assertEqualInt(1, archive_file_count(a)); + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + + assertChdir(".."); +} DEFINE_TEST(test_read_format_mtree) { @@ -309,4 +343,5 @@ DEFINE_TEST(test_read_format_mtree) test_read_format_mtree2(); test_read_format_mtree3(); test_read_format_mtree4(); + test_read_format_mtree5(); }