svn commit: r189381 - head/lib/libarchive/test
Tim Kientzle
kientzle at FreeBSD.org
Wed Mar 4 16:31:50 PST 2009
Author: kientzle
Date: Thu Mar 5 00:31:48 2009
New Revision: 189381
URL: http://svn.freebsd.org/changeset/base/189381
Log:
Merge r341,r345,r346,347 from libarchive.googlecode.com: Style
fixes to test harness and a few extra guards to detect tests
that can't succeed on certain platforms.
Modified:
head/lib/libarchive/test/main.c
head/lib/libarchive/test/test.h
head/lib/libarchive/test/test_read_compress_program.c
head/lib/libarchive/test/test_read_format_cpio_bin_Z.c
head/lib/libarchive/test/test_read_format_cpio_svr4c_Z.c
head/lib/libarchive/test/test_read_format_tz.c
Modified: head/lib/libarchive/test/main.c
==============================================================================
--- head/lib/libarchive/test/main.c Thu Mar 5 00:15:43 2009 (r189380)
+++ head/lib/libarchive/test/main.c Thu Mar 5 00:31:48 2009 (r189381)
@@ -33,6 +33,9 @@
#include <locale.h>
#include <stdarg.h>
#include <time.h>
+#ifdef _WIN32
+#include <crtdbg.h>
+#endif
/*
* This same file is used pretty much verbatim for all test harnesses.
@@ -907,6 +910,10 @@ get_refdir(void)
strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
}
+ /* You should have to add "$(TargetDir)" to
+ * Properties > Configuration Properties > Debugging > Working Directory,
+ * if you are running libarchive_test.exe on Visual Studio.
+ */
printf("Unable to locate known reference file %s\n", KNOWNREF);
printf(" Checked following directories:\n%s\n", tried);
exit(1);
@@ -966,7 +973,7 @@ int main(int argc, char **argv)
* Parse options, without using getopt(), which isn't available
* on all platforms.
*/
- ++argv; /* Skip program name */
+ ++argv; --argc;/* Skip program name */
while (*argv != NULL) {
p = *argv++;
if (*p++ != '-')
Modified: head/lib/libarchive/test/test.h
==============================================================================
--- head/lib/libarchive/test/test.h Thu Mar 5 00:15:43 2009 (r189380)
+++ head/lib/libarchive/test/test.h Thu Mar 5 00:31:48 2009 (r189381)
@@ -73,6 +73,7 @@
#endif
#ifdef _WIN32
+#define snprintf sprintf_s
#define LOCALE_DE "deu"
#else
#define LOCALE_DE "de_DE.UTF-8"
Modified: head/lib/libarchive/test/test_read_compress_program.c
==============================================================================
--- head/lib/libarchive/test/test_read_compress_program.c Thu Mar 5 00:15:43 2009 (r189380)
+++ head/lib/libarchive/test/test_read_compress_program.c Thu Mar 5 00:31:48 2009 (r189381)
@@ -42,16 +42,20 @@ DEFINE_TEST(test_read_compress_program)
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
- assertEqualIntA(a, 0, archive_read_support_compression_none(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_none(a));
r = archive_read_support_compression_program(a, "gunzip");
if (r == ARCHIVE_FATAL) {
skipping("archive_read_support_compression_program() unsupported on this platform");
return;
}
assertEqualIntA(a, ARCHIVE_OK, r);
- assert(0 == archive_read_support_format_all(a));
- assertEqualIntA(a, 0, archive_read_open_memory(a, archive, sizeof(archive)));
- assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
assert(archive_compression(a) == ARCHIVE_COMPRESSION_PROGRAM);
assert(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR);
assert(0 == archive_read_close(a));
Modified: head/lib/libarchive/test/test_read_format_cpio_bin_Z.c
==============================================================================
--- head/lib/libarchive/test/test_read_format_cpio_bin_Z.c Thu Mar 5 00:15:43 2009 (r189380)
+++ head/lib/libarchive/test/test_read_format_cpio_bin_Z.c Thu Mar 5 00:31:48 2009 (r189381)
@@ -36,17 +36,24 @@ DEFINE_TEST(test_read_format_cpio_bin_Z)
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assertA(0 == archive_read_next_header(a, &ae));
- assertA(archive_compression(a) == ARCHIVE_COMPRESSION_COMPRESS);
- assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE);
- assert(0 == archive_read_close(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ failure("archive_compression_name(a)=\"%s\"",
+ archive_compression_name(a));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ failure("archive_format_name(a)=\"%s\"",
+ archive_format_name(a));
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
#else
- assert(0 == archive_read_finish(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
Modified: head/lib/libarchive/test/test_read_format_cpio_svr4c_Z.c
==============================================================================
--- head/lib/libarchive/test/test_read_format_cpio_svr4c_Z.c Thu Mar 5 00:15:43 2009 (r189380)
+++ head/lib/libarchive/test/test_read_format_cpio_svr4c_Z.c Thu Mar 5 00:31:48 2009 (r189381)
@@ -39,17 +39,23 @@ DEFINE_TEST(test_read_format_cpio_svr4c_
struct archive *a;
/* printf("Archive address: start=%X, end=%X\n", archive, archive+sizeof(archive)); */
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assertA(0 == archive_read_next_header(a, &ae));
- assertA(archive_compression(a) == ARCHIVE_COMPRESSION_COMPRESS);
- assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_SVR4_CRC);
- assert(0 == archive_read_close(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ failure("archive_compression_name(a)=\"%s\"",
+ archive_compression_name(a));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ failure("archive_format_name(a)=\"%s\"", archive_format_name(a));
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_CRC);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
#else
- assert(0 == archive_read_finish(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
Modified: head/lib/libarchive/test/test_read_format_tz.c
==============================================================================
--- head/lib/libarchive/test/test_read_format_tz.c Thu Mar 5 00:15:43 2009 (r189380)
+++ head/lib/libarchive/test/test_read_format_tz.c Thu Mar 5 00:31:48 2009 (r189381)
@@ -39,17 +39,22 @@ DEFINE_TEST(test_read_format_tz)
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assertA(0 == archive_read_next_header(a, &ae));
- assertA(archive_compression(a) == ARCHIVE_COMPRESSION_COMPRESS);
- assertA(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR);
- assert(0 == archive_read_close(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ failure("archive_compression_name(a)=\"%s\"",
+ archive_compression_name(a));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ failure("archive_format_name(a)=\"%s\"", archive_format_name(a));
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
#else
- assert(0 == archive_read_finish(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
More information about the svn-src-head
mailing list