summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/test/main.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2007-07-06 15:43:11 +0000
committerkientzle <kientzle@FreeBSD.org>2007-07-06 15:43:11 +0000
commit627342641db59a7eaa904ec6654e5622fb4653eb (patch)
treeb17c1fbc8f181078146027ab4987cac1af8c73a3 /lib/libarchive/test/main.c
parent8f8c5c97731ba5f5874c4278189ec2138711e819 (diff)
downloadFreeBSD-src-627342641db59a7eaa904ec6654e5622fb4653eb.zip
FreeBSD-src-627342641db59a7eaa904ec6654e5622fb4653eb.tar.gz
Make test suite work with libarchive 1.3.1: Take advantage of
ARCHIVE_VERSION_STAMP to selectively disable tests that don't apply to that version; new "skipping()" function reports skipped tests; modify final summary to report component test failures and skips. Note: I don't currently intend to MFC the test suite itself; anyone interested should just checkout and use this version of the test suite, which should work for any library version. Approved by: re (Ken Smith, blanket)
Diffstat (limited to 'lib/libarchive/test/main.c')
-rw-r--r--lib/libarchive/test/main.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/lib/libarchive/test/main.c b/lib/libarchive/test/main.c
index 1e95f89..21ecb8c 100644
--- a/lib/libarchive/test/main.c
+++ b/lib/libarchive/test/main.c
@@ -38,8 +38,10 @@ __FBSDID("$FreeBSD$");
static int dump_on_failure = 1;
/* Default is to print some basic information about each test. */
static int quiet_flag = 0;
-/* Cumulative count of failures. */
+/* Cumulative count of component failures. */
static int failures = 0;
+/* Cumulative count of skipped component tests. */
+static int skips = 0;
/*
* My own implementation of the standard assert() macro emits the
@@ -59,6 +61,19 @@ static int failures = 0;
static char msg[4096];
+/* Inform user that we're skipping a test. */
+void
+skipping(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ fprintf(stderr, " *** SKIPPING: ");
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+ ++skips;
+}
+
/* Common handling of failed tests. */
static void
test_failed(struct archive *a)
@@ -202,7 +217,7 @@ static int test_run(int i, const char *tmpdir)
exit(1);
}
(*tests[i].func)();
- return (failures - failures_before);
+ return (failures == failures_before ? 0 : 1);
}
static void usage(void)
@@ -226,7 +241,7 @@ static void usage(void)
int main(int argc, char **argv)
{
static const int limit = sizeof(tests) / sizeof(tests[0]);
- int i, tests_run = 0, tests_succeeded = 0, opt;
+ int i, tests_run = 0, tests_failed = 0, opt;
time_t now;
char tmpdir[256];
@@ -266,13 +281,16 @@ int main(int argc, char **argv)
exit(1);
}
- printf("Running libarchive tests in: %s\n", tmpdir);
+ if (!quiet_flag) {
+ printf("Running libarchive tests in: %s\n", tmpdir);
+ printf("Exercising %s\n", archive_version());
+ }
if (argc == 0) {
/* Default: Run all tests. */
for (i = 0; i < limit; i++) {
- if (test_run(i, tmpdir) == 0)
- tests_succeeded++;
+ if (test_run(i, tmpdir))
+ tests_failed++;
tests_run++;
}
} else {
@@ -282,13 +300,16 @@ int main(int argc, char **argv)
printf("*** INVALID Test %s\n", *argv);
usage();
} else {
- if (test_run(i, tmpdir) == 0)
- tests_succeeded++;
+ if (test_run(i, tmpdir))
+ tests_failed++;
tests_run++;
}
}
}
-
- printf("%d of %d tests succeeded.\n", tests_succeeded, tests_run);
- return (tests_succeeded == tests_run ? 0 : 1);
+ printf("\n");
+ printf("%d of %d test groups reported failures\n",
+ tests_failed, tests_run);
+ printf(" Total of %d individual tests failed.\n", failures);
+ printf(" Total of %d individual tests were skipped.\n", skips);
+ return (tests_failed);
}
OpenPOWER on IntegriCloud