summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/cpio/test
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/libarchive/files/cpio/test')
-rw-r--r--archivers/libarchive/files/cpio/test/main.c53
-rw-r--r--archivers/libarchive/files/cpio/test/test.h39
2 files changed, 70 insertions, 22 deletions
diff --git a/archivers/libarchive/files/cpio/test/main.c b/archivers/libarchive/files/cpio/test/main.c
index c88dd2ac341..e0f8c2e1175 100644
--- a/archivers/libarchive/files/cpio/test/main.c
+++ b/archivers/libarchive/files/cpio/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.
*
@@ -44,7 +44,7 @@
#undef EXTRA_DUMP /* How to dump extra data */
/* How to generate extra version info. */
#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/usr.bin/cpio/test/main.c,v 1.2 2008/06/21 02:17:18 kientzle Exp $");
/*
* "list.h" is simply created by "grep DEFINE_TEST"; it has
@@ -541,6 +541,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, ...)
@@ -670,8 +712,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.
diff --git a/archivers/libarchive/files/cpio/test/test.h b/archivers/libarchive/files/cpio/test/test.h
index 06e6d903fc8..431d5d7c4d5 100644
--- a/archivers/libarchive/files/cpio/test/test.h
+++ b/archivers/libarchive/files/cpio/test/test.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: src/usr.bin/cpio/test/test.h,v 1.2 2008/06/21 02:17:18 kientzle Exp $
*/
/* Every test program should #include "test.h" as the first thing. */
@@ -31,8 +31,18 @@
* 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
+#if defined(HAVE_CONFIG_H)
+/* Most POSIX platforms use the 'configure' script to build config.h */
+#include "../../config.h"
+#elif defined(__FreeBSD__)
+/* Building as part of FreeBSD system requires a pre-built config.h. */
+#include "../config_freebsd.h"
+#elif defined(_WIN32)
+/* Win32 can't run the 'configure' script. */
+#include "../config_windows.h"
+#else
+/* Warn if the library hasn't been (automatically or manually) configured. */
+#error Oops: No config.h and no pre-built configuration in test.h.
#endif
#include <dirent.h>
@@ -51,20 +61,6 @@
#include <dmalloc.h>
#endif
-#if defined(HAVE_CONFIG_H)
-/* Most POSIX platforms use the 'configure' script to build config.h */
-#include "../../config.h"
-#elif defined(__FreeBSD__)
-/* Building as part of FreeBSD system requires a pre-built config.h. */
-#include "../config_freebsd.h"
-#elif defined(_WIN32)
-/* Win32 can't run the 'configure' script. */
-#include "../config_windows.h"
-#else
-/* Warn if the library hasn't been (automatically or manually) configured. */
-#error Oops: No config.h and no pre-built configuration in test.h.
-#endif
-
/* No non-FreeBSD platform will have __FBSDID, so just define it here. */
#ifdef __FreeBSD__
#include <sys/cdefs.h> /* For __FBSDID */
@@ -102,6 +98,12 @@
/* Assert that a file is empty; supports printf-style arguments. */
#define assertEmptyFile \
test_setup(__FILE__, __LINE__);test_assert_empty_file
+/* Assert that a file exists; supports printf-style arguments. */
+#define assertFileExists \
+ test_setup(__FILE__, __LINE__);test_assert_file_exists
+/* Assert that a file exists; supports printf-style arguments. */
+#define assertFileNotExists \
+ test_setup(__FILE__, __LINE__);test_assert_file_not_exists
/* Assert that file contents match a string; supports printf-style arguments. */
#define assertFileContents \
test_setup(__FILE__, __LINE__);test_assert_file_contents
@@ -127,6 +129,8 @@ int test_assert_equal_string(const char *, int, const char *v1, const char *, co
int test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
int test_assert_equal_mem(const char *, int, const char *, const char *, const char *, const char *, size_t, const char *, void *);
int test_assert_file_contents(const void *, int, const char *, ...);
+int test_assert_file_exists(const char *, ...);
+int test_assert_file_not_exists(const char *, ...);
/* Like sprintf, then system() */
int systemf(const char * fmt, ...);
@@ -144,4 +148,3 @@ void extract_reference_file(const char *);
/* Pathname of exe to be tested. */
char *testprog;
-