From: Tim Kientzle Date: Sun, 4 Jan 2009 07:57:36 +0000 (-0500) Subject: Merge r353 from release/2.6: Fixes to assertEmptyFile() and assertFileContents() X-Git-Tag: v2.7.0~479 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7edacea3206a7027d3282c0376a94dcc047809ec;p=thirdparty%2Flibarchive.git Merge r353 from release/2.6: Fixes to assertEmptyFile() and assertFileContents() SVN-Revision: 368 --- diff --git a/tar/test/main.c b/tar/test/main.c index 2a29ca092..c588c538a 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -476,7 +476,9 @@ test_assert_empty_file(const char *f1fmt, ...) va_end(ap); if (stat(f1, &st) != 0) { - fprintf(stderr, "%s:%d: Could not stat: %s\n", test_filename, test_line, f1); + fprintf(stderr, "%s:%d: Could not stat: %s\n", + test_filename, test_line, f1); + failures ++; report_failure(NULL); return (0); } @@ -519,6 +521,7 @@ test_assert_non_empty_file(const char *f1fmt, ...) fprintf(stderr, "%s:%d: Could not stat: %s\n", test_filename, test_line, f1); report_failure(NULL); + failures++; return (0); } if (st.st_size != 0) @@ -630,6 +633,15 @@ test_assert_file_contents(const void *buff, int s, const char *fpattern, ...) va_end(ap); fd = open(f, O_RDONLY); + if (fd < 0) { + failures ++; + if (!previous_failures(test_filename, test_line)) { + fprintf(stderr, "%s:%d: File doesn't exist: %s\n", + test_filename, test_line, f); + report_failure(test_extra); + } + return (0); + } contents = malloc(s * 2); n = read(fd, contents, s * 2); if (n == s && memcmp(buff, contents, s) == 0) {