diff options
Diffstat (limited to 'libarchive/test/test.h')
-rw-r--r-- | libarchive/test/test.h | 96 |
1 files changed, 50 insertions, 46 deletions
diff --git a/libarchive/test/test.h b/libarchive/test/test.h index 40c31e1..4c82ece 100644 --- a/libarchive/test/test.h +++ b/libarchive/test/test.h @@ -86,9 +86,6 @@ #if !defined(__BORLANDC__) #define strdup _strdup #endif -#define LOCALE_UTF8 NULL -#else -#define LOCALE_UTF8 "de_DE.UTF-8" #endif /* Visual Studio */ @@ -100,16 +97,9 @@ #pragma warn -8068 /* Constant out of range in comparison. */ #endif -/* Cygwin */ -#if defined(__CYGWIN__) -/* Cygwin-1.7.x is lazy about populating nlinks, so don't - * expect it to be accurate. */ -# define NLINKS_INACCURATE_FOR_DIRS -#endif - -/* Haiku OS */ -#if defined(__HAIKU__) -/* Haiku has typedefs in stdint.h (needed for int64_t) */ +/* Haiku OS and QNX */ +#if defined(__HAIKU__) || defined(__QNXNTO__) +/* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */ #include <stdint.h> #endif @@ -143,24 +133,24 @@ assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL) /* Assert two strings are the same. Reports value of each one if not. */ #define assertEqualString(v1,v2) \ - assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL) + assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 0) +#define assertEqualUTF8String(v1,v2) \ + assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 1) /* As above, but v1 and v2 are wchar_t * */ #define assertEqualWString(v1,v2) \ assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL) /* As above, but raw blocks of bytes. */ #define assertEqualMem(v1, v2, l) \ assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL) -/* Assert two files are the same; allow printf-style expansion of second name. - * See below for comments about variable arguments here... - */ -#define assertEqualFile \ - assertion_setup(__FILE__, __LINE__);assertion_equal_file -/* Assert that a file is empty; supports printf-style arguments. */ -#define assertEmptyFile \ - assertion_setup(__FILE__, __LINE__);assertion_empty_file -/* Assert that a file is not empty; supports printf-style arguments. */ -#define assertNonEmptyFile \ - assertion_setup(__FILE__, __LINE__);assertion_non_empty_file +/* Assert two files are the same. */ +#define assertEqualFile(f1, f2) \ + assertion_equal_file(__FILE__, __LINE__, (f1), (f2)) +/* Assert that a file is empty. */ +#define assertEmptyFile(pathname) \ + assertion_empty_file(__FILE__, __LINE__, (pathname)) +/* Assert that a file is not empty. */ +#define assertNonEmptyFile(pathname) \ + assertion_non_empty_file(__FILE__, __LINE__, (pathname)) #define assertFileAtime(pathname, sec, nsec) \ assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec) #define assertFileAtimeRecent(pathname) \ @@ -170,14 +160,14 @@ #define assertFileBirthtimeRecent(pathname) \ assertion_file_birthtime_recent(__FILE__, __LINE__, pathname) /* Assert that a file exists; supports printf-style arguments. */ -#define assertFileExists \ - assertion_setup(__FILE__, __LINE__);assertion_file_exists -/* Assert that a file exists; supports printf-style arguments. */ -#define assertFileNotExists \ - assertion_setup(__FILE__, __LINE__);assertion_file_not_exists -/* Assert that file contents match a string; supports printf-style arguments. */ -#define assertFileContents \ - assertion_setup(__FILE__, __LINE__);assertion_file_contents +#define assertFileExists(pathname) \ + assertion_file_exists(__FILE__, __LINE__, pathname) +/* Assert that a file exists. */ +#define assertFileNotExists(pathname) \ + assertion_file_not_exists(__FILE__, __LINE__, pathname) +/* Assert that file contents match a string. */ +#define assertFileContents(data, data_size, pathname) \ + assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname) #define assertFileMtime(pathname, sec, nsec) \ assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec) #define assertFileMtimeRecent(pathname) \ @@ -186,8 +176,10 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) -#define assertTextFileContents \ - assertion_setup(__FILE__, __LINE__);assertion_text_file_contents +#define assertTextFileContents(text, pathname) \ + assertion_text_file_contents(__FILE__, __LINE__, text, pathname) +#define assertFileContainsLinesAnyOrder(pathname, lines) \ + assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines) #define assertIsDir(pathname, mode) \ assertion_is_dir(__FILE__, __LINE__, pathname, mode) #define assertIsHardlink(path1, path2) \ @@ -209,6 +201,8 @@ assertion_make_symlink(__FILE__, __LINE__, newfile, linkto) #define assertUmask(mask) \ assertion_umask(__FILE__, __LINE__, mask) +#define assertUtimes(pathname, atime, atime_nsec, mtime, mtime_nsec) \ + assertion_utimes(__FILE__, __LINE__, pathname, atime, atime_nsec, mtime, mtime_nsec) /* * This would be simple with C99 variadic macros, but I don't want to @@ -217,28 +211,29 @@ * but effective. */ #define skipping \ - assertion_setup(__FILE__, __LINE__);test_skipping + skipping_setup(__FILE__, __LINE__);test_skipping /* Function declarations. These are defined in test_utility.c. */ void failure(const char *fmt, ...); int assertion_assert(const char *, int, int, const char *, void *); int assertion_chdir(const char *, int, const char *); -int assertion_empty_file(const char *, ...); -int assertion_equal_file(const char *, const char *, ...); +int assertion_empty_file(const char *, int, const char *); +int assertion_equal_file(const char *, int, const char *, const char *); int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *); int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *); -int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *); +int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int); int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *); int assertion_file_atime(const char *, int, const char *, long, long); int assertion_file_atime_recent(const char *, int, const char *); int assertion_file_birthtime(const char *, int, const char *, long, long); int assertion_file_birthtime_recent(const char *, int, const char *); -int assertion_file_contents(const void *, int, const char *, ...); -int assertion_file_exists(const char *, ...); +int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); +int assertion_file_contents(const char *, int, const void *, int, const char *); +int assertion_file_exists(const char *, int, const char *); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); -int assertion_file_not_exists(const char *, ...); +int assertion_file_not_exists(const char *, int, const char *); int assertion_file_size(const char *, int, const char *, long); int assertion_is_dir(const char *, int, const char *, int); int assertion_is_hardlink(const char *, int, const char *, const char *); @@ -249,11 +244,12 @@ int assertion_make_dir(const char *, int, const char *, int); int assertion_make_file(const char *, int, const char *, int, const char *); int assertion_make_hardlink(const char *, int, const char *newpath, const char *); int assertion_make_symlink(const char *, int, const char *newpath, const char *); -int assertion_non_empty_file(const char *, ...); -int assertion_text_file_contents(const char *buff, const char *f); +int assertion_non_empty_file(const char *, int, const char *); +int assertion_text_file_contents(const char *, int, const char *buff, const char *f); int assertion_umask(const char *, int, int); -void assertion_setup(const char *, int); +int assertion_utimes(const char *, int, const char *, long, long, long, long ); +void skipping_setup(const char *, int); void test_skipping(const char *fmt, ...); /* Like sprintf, then system() */ @@ -271,6 +267,9 @@ int canGzip(void); /* Return true if this platform can run the "gunzip" program. */ int canGunzip(void); +/* Return true if the file has large i-node number(>0xffffffff). */ +int is_LargeInode(const char *); + /* Suck file into string allocated via malloc(). Call free() when done. */ /* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */ char *slurpfile(size_t *, const char *fmt, ...); @@ -278,6 +277,9 @@ char *slurpfile(size_t *, const char *fmt, ...); /* Extracts named reference file to the current directory. */ void extract_reference_file(const char *); +/* Path to working directory for current test */ +const char *testworkdir; + /* * Special interfaces for libarchive test harness. */ @@ -289,13 +291,15 @@ void extract_reference_file(const char *); int read_open_memory(struct archive *, void *, size_t, size_t); /* "2" version exercises a slightly different set of libarchive APIs. */ int read_open_memory2(struct archive *, void *, size_t, size_t); +/* _seek version produces a seekable file. */ +int read_open_memory_seek(struct archive *, void *, size_t, size_t); /* Versions of above that accept an archive argument for additional info. */ #define assertA(e) assertion_assert(__FILE__, __LINE__, (e), #e, (a)) #define assertEqualIntA(a,v1,v2) \ assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a)) #define assertEqualStringA(a,v1,v2) \ - assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a)) + assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a), 0) #ifdef USE_DMALLOC #include <dmalloc.h> |