summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libarchive/test/main.c14
-rw-r--r--lib/libarchive/test/test.h7
2 files changed, 12 insertions, 9 deletions
diff --git a/lib/libarchive/test/main.c b/lib/libarchive/test/main.c
index ffe81cf30a51..a7289ec236ef 100644
--- a/lib/libarchive/test/main.c
+++ b/lib/libarchive/test/main.c
@@ -34,11 +34,8 @@
*/
#define PROGRAM "LIBARCHIVE"
-/*
- * Various utility routines useful for test programs.
- * Each test program is linked against this file.
- */
#include <errno.h>
+#include <locale.h>
#include <stdarg.h>
#include <time.h>
@@ -226,20 +223,21 @@ failure(const char *fmt, ...)
}
/* Generic assert() just displays the failed condition. */
-void
+int
test_assert(const char *file, int line, int value, const char *condition, void *extra)
{
++assertions;
if (value) {
msg[0] = '\0';
- return;
+ return (value);
}
failures ++;
if (previous_failures(file, line))
- return;
+ return (value);
fprintf(stderr, "%s:%d: Assertion failed\n", file, line);
fprintf(stderr, " Condition: %s\n", condition);
report_failure(extra);
+ return (value);
}
/* assertEqualInt() displays the values of the two integers. */
@@ -553,6 +551,8 @@ static int test_run(int i, const char *tmpdir)
tests[i].name);
exit(1);
}
+ /* Explicitly reset the locale before each test. */
+ setlocale(LC_ALL, "C");
/* Run the actual test. */
(*tests[i].func)();
/* Summarize the results of this test. */
diff --git a/lib/libarchive/test/test.h b/lib/libarchive/test/test.h
index 3ec41eba7236..07de016f3219 100644
--- a/lib/libarchive/test/test.h
+++ b/lib/libarchive/test/test.h
@@ -31,8 +31,9 @@
* The goal of this file (and the matching test.c) is to
* simplify the very repetitive test-*.c test programs.
*/
-
+#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
+#endif
#include <errno.h>
#include <fcntl.h>
@@ -40,7 +41,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#ifndef _WIN32
#include <unistd.h>
+#endif
#include <wchar.h>
#ifdef USE_DMALLOC
@@ -112,7 +115,7 @@
void failure(const char *fmt, ...);
void test_setup(const char *, int);
void test_skipping(const char *fmt, ...);
-void test_assert(const char *, int, int, const char *, void *);
+int test_assert(const char *, int, int, const char *, void *);
void test_assert_empty_file(const char *, ...);
void test_assert_equal_file(const char *, const char *, ...);
void test_assert_equal_int(const char *, int, int, const char *, int, const char *, void *);