mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
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.
This commit is contained in:
parent
9c859a041a
commit
ba2a6a7201
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189381
|
@ -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++ != '-')
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define snprintf sprintf_s
|
||||
#define LOCALE_DE "deu"
|
||||
#else
|
||||
#define LOCALE_DE "de_DE.UTF-8"
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -39,17 +39,23 @@ DEFINE_TEST(test_read_format_cpio_svr4c_Z)
|
|||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue