summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/test/main.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2008-06-15 10:35:22 +0000
committerkientzle <kientzle@FreeBSD.org>2008-06-15 10:35:22 +0000
commit43197fcece165924136391beabb2ffbd6cf9ce7a (patch)
tree6277398c851abadcefd15aaabaaf16a1a12779c9 /lib/libarchive/test/main.c
parenta9ebcc947a4c893cbd622efa8f75afe6fb897cf6 (diff)
downloadFreeBSD-src-43197fcece165924136391beabb2ffbd6cf9ce7a.zip
FreeBSD-src-43197fcece165924136391beabb2ffbd6cf9ce7a.tar.gz
MfP4: test harness improvements.
Diffstat (limited to 'lib/libarchive/test/main.c')
-rw-r--r--lib/libarchive/test/main.c51
1 files changed, 48 insertions, 3 deletions
diff --git a/lib/libarchive/test/main.c b/lib/libarchive/test/main.c
index d518b8c..650495a 100644
--- a/lib/libarchive/test/main.c
+++ b/lib/libarchive/test/main.c
@@ -27,13 +27,13 @@
* Various utility routines useful for test programs.
* Each test program is linked against this file.
*/
+#include "test.h"
+
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
#include <time.h>
-#include "test.h"
-
/*
* This same file is used pretty much verbatim for all test harnesses.
*
@@ -540,6 +540,48 @@ test_assert_equal_file(const char *f1, const char *f2pattern, ...)
return (0);
}
+int
+test_assert_file_exists(const char *fpattern, ...)
+{
+ char f[1024];
+ va_list ap;
+
+ va_start(ap, fpattern);
+ vsprintf(f, fpattern, ap);
+ va_end(ap);
+
+ if (!access(f, F_OK))
+ return (1);
+ if (!previous_failures(test_filename, test_line)) {
+ fprintf(stderr, "%s:%d: File doesn't exist\n",
+ test_filename, test_line);
+ fprintf(stderr, " file=\"%s\"\n", f);
+ report_failure(test_extra);
+ }
+ return (0);
+}
+
+int
+test_assert_file_not_exists(const char *fpattern, ...)
+{
+ char f[1024];
+ va_list ap;
+
+ va_start(ap, fpattern);
+ vsprintf(f, fpattern, ap);
+ va_end(ap);
+
+ if (access(f, F_OK))
+ return (1);
+ if (!previous_failures(test_filename, test_line)) {
+ fprintf(stderr, "%s:%d: File exists and shouldn't\n",
+ test_filename, test_line);
+ fprintf(stderr, " file=\"%s\"\n", f);
+ report_failure(test_extra);
+ }
+ return (0);
+}
+
/* assertFileContents() asserts the contents of a file. */
int
test_assert_file_contents(const void *buff, int s, const char *fpattern, ...)
@@ -669,8 +711,11 @@ static int test_run(int i, const char *tmpdir)
{
int failures_before = failures;
- if (!quiet_flag)
+ if (!quiet_flag) {
printf("%d: %s\n", i, tests[i].name);
+ fflush(stdout);
+ }
+
/*
* Always explicitly chdir() in case the last test moved us to
* a strange place.
OpenPOWER on IntegriCloud