From: Tim Kientzle Date: Sun, 2 Aug 2009 21:41:53 +0000 (-0400) Subject: Reduce diffs between tar/test infrastructure and cpio/test infrastructure. X-Git-Tag: v2.8.0~472 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f82b7f4e58285fdc9a2ca64050505f946dac145;p=thirdparty%2Flibarchive.git Reduce diffs between tar/test infrastructure and cpio/test infrastructure. In particular, this makes it possible to use the new platform-independent assertions for creating dirs, testing file attributes, etc. SVN-Revision: 1315 --- diff --git a/cpio/test/main.c b/cpio/test/main.c index 20586ce17..9c40cc0f9 100644 --- a/cpio/test/main.c +++ b/cpio/test/main.c @@ -37,8 +37,31 @@ #if !defined(__GNUC__) #include #endif +#include #include #include +#ifndef F_OK +#define F_OK (0) +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) ((m) & _S_IFDIR) +#endif +#ifndef S_ISREG +#define S_ISREG(m) ((m) & _S_IFREG) +#endif +#define access _access +#define chdir _chdir +#ifndef fileno +#define fileno _fileno +#endif +//#define fstat _fstat64 +#define getcwd _getcwd +#define lstat stat +//#define lstat _stat64 +//#define stat _stat64 +#define rmdir _rmdir +#define strdup _strdup +#define umask _umask #endif /* @@ -284,7 +307,7 @@ test_assert(const char *file, int line, int value, const char *condition, void * msg[0] = '\0'; return (value); } - failures ++; + ++failures; if (!verbose && previous_failures(file, line, 1)) return (value); fprintf(stderr, "%s:%d: Assertion failed\n", file, line); @@ -293,23 +316,38 @@ test_assert(const char *file, int line, int value, const char *condition, void * return (value); } +int +test_assert_chdir(const char *file, int line, const char *pathname) +{ + count_assertion(file, line); + if (chdir(pathname) == 0) + return (1); + ++failures; + if (!verbose && previous_failures(file, line, 1)) + return (0); + fprintf(stderr, "%s:%d: chdir(\"%s\") failed\n", + file, line, pathname); + return (0); + +} + /* assertEqualInt() displays the values of the two integers. */ int test_assert_equal_int(const char *file, int line, - int v1, const char *e1, int v2, const char *e2, void *extra) + long long v1, const char *e1, long long v2, const char *e2, void *extra) { count_assertion(file, line); if (v1 == v2) { msg[0] = '\0'; return (1); } - failures ++; + ++failures; if (!verbose && previous_failures(file, line, 1)) return (0); fprintf(stderr, "%s:%d: Assertion failed: Ints not equal\n", file, line); - fprintf(stderr, " %s=%d\n", e1, v1); - fprintf(stderr, " %s=%d\n", e2, v2); + fprintf(stderr, " %s=%lld\n", e1, v1); + fprintf(stderr, " %s=%lld\n", e2, v2); report_failure(extra); return (0); } @@ -355,7 +393,7 @@ test_assert_equal_string(const char *file, int line, msg[0] = '\0'; return (1); } - failures ++; + ++failures; if (!verbose && previous_failures(file, line, 1)) return (0); fprintf(stderr, "%s:%d: Assertion failed: Strings not equal\n", @@ -413,7 +451,7 @@ test_assert_equal_wstring(const char *file, int line, msg[0] = '\0'; return (1); } - failures ++; + ++failures; if (!verbose && previous_failures(file, line, 1)) return (0); fprintf(stderr, "%s:%d: Assertion failed: Unicode strings not equal\n", @@ -486,7 +524,7 @@ test_assert_equal_mem(const char *file, int line, msg[0] = '\0'; return (1); } - failures ++; + ++failures; if (!verbose && previous_failures(file, line, 1)) return (0); fprintf(stderr, "%s:%d: Assertion failed: memory not equal\n", @@ -534,7 +572,7 @@ test_assert_empty_file(const char *f1fmt, ...) if (st.st_size == 0) return (1); - failures ++; + ++failures; if (!verbose && previous_failures(test_filename, test_line, 1)) return (0); @@ -571,13 +609,13 @@ test_assert_non_empty_file(const char *f1fmt, ...) fprintf(stderr, "%s:%d: Could not stat: %s\n", test_filename, test_line, f1); report_failure(NULL); - failures++; + ++failures; return (0); } if (st.st_size != 0) return (1); - failures ++; + ++failures; if (!verbose && previous_failures(test_filename, test_line, 1)) return (0); @@ -620,7 +658,7 @@ test_assert_equal_file(const char *fn1, const char *f2pattern, ...) } fclose(f1); fclose(f2); - failures ++; + ++failures; if (!verbose && previous_failures(test_filename, test_line, 1)) return (0); fprintf(stderr, "%s:%d: Files are not identical\n", @@ -637,12 +675,19 @@ test_assert_file_exists(const char *fpattern, ...) char f[1024]; va_list ap; + count_assertion(test_filename, test_line); va_start(ap, fpattern); vsprintf(f, fpattern, ap); va_end(ap); +#if defined(_WIN32) && !defined(__CYGWIN__) + if (!_access(f, 0)) + return (1); +#else if (!access(f, F_OK)) return (1); +#endif + ++failures; if (!previous_failures(test_filename, test_line, 1)) { fprintf(stderr, "%s:%d: File doesn't exist\n", test_filename, test_line); @@ -658,12 +703,19 @@ test_assert_file_not_exists(const char *fpattern, ...) char f[1024]; va_list ap; + count_assertion(test_filename, test_line); va_start(ap, fpattern); vsprintf(f, fpattern, ap); va_end(ap); +#if defined(_WIN32) && !defined(__CYGWIN__) + if (_access(f, 0)) + return (1); +#else if (access(f, F_OK)) return (1); +#endif + ++failures; if (!previous_failures(test_filename, test_line, 1)) { fprintf(stderr, "%s:%d: File exists and shouldn't\n", test_filename, test_line); @@ -683,13 +735,14 @@ test_assert_file_contents(const void *buff, int s, const char *fpattern, ...) FILE *f; int n; + count_assertion(test_filename, test_line); va_start(ap, fpattern); vsprintf(fn, fpattern, ap); va_end(ap); f = fopen(fn, "rb"); if (f == NULL) { - failures ++; + ++failures; if (!previous_failures(test_filename, test_line, 1)) { fprintf(stderr, "%s:%d: File doesn't exist: %s\n", test_filename, test_line, fn); @@ -704,16 +757,16 @@ test_assert_file_contents(const void *buff, int s, const char *fpattern, ...) free(contents); return (1); } - failures ++; + ++failures; if (!previous_failures(test_filename, test_line, 1)) { fprintf(stderr, "%s:%d: File contents don't match\n", test_filename, test_line); fprintf(stderr, " file=\"%s\"\n", fn); if (n > 0) - hexdump(contents, buff, n, 0); + hexdump(contents, buff, n > 512 ? 512 : 0, 0); else { fprintf(stderr, " File empty, contents should be:\n"); - hexdump(buff, NULL, s, 0); + hexdump(buff, NULL, s > 512 ? 512 : 0, 0); } report_failure(test_extra); } @@ -723,20 +776,21 @@ test_assert_file_contents(const void *buff, int s, const char *fpattern, ...) /* assertTextFileContents() asserts the contents of a text file. */ int -test_assert_text_file_contents(const char *buff, const char *f) +test_assert_text_file_contents(const char *buff, const char *fn) { char *contents; const char *btxt, *ftxt; - int fd; + FILE *f; int n, s; - fd = open(f, O_RDONLY); + count_assertion(test_filename, test_line); + f = fopen(fn, "r"); s = strlen(buff); contents = malloc(s * 2 + 128); - n = read(fd, contents, s * 2 + 128 -1); + n = fread(contents, 1, s * 2 + 128 - 1, f); if (n >= 0) contents[n] = '\0'; - close(fd); + fclose(f); /* Compare texts. */ btxt = buff; ftxt = (const char *)contents; @@ -758,11 +812,11 @@ test_assert_text_file_contents(const char *buff, const char *f) free(contents); return (1); } - failures ++; + ++failures; if (!previous_failures(test_filename, test_line, 1)) { fprintf(stderr, "%s:%d: File contents don't match\n", test_filename, test_line); - fprintf(stderr, " file=\"%s\"\n", f); + fprintf(stderr, " file=\"%s\"\n", fn); if (n > 0) hexdump(contents, buff, n, 0); else { @@ -775,6 +829,228 @@ test_assert_text_file_contents(const char *buff, const char *f) return (0); } +int +test_assert_file_hardlinks(const char *file, int line, + const char *path1, const char *path2) +{ + struct stat st1, st2; + int r; + + count_assertion(file, line); + r = lstat(path1, &st1); + if (r != 0) { + ++failures; + if (!previous_failures(file, line, 1)) + fprintf(stderr, "%s:%d: File ``%s'' should exist\n", + file, line, path1); + return (0); + } + r = lstat(path2, &st2); + if (r != 0) { + ++failures; + if (!previous_failures(file, line, 1)) + fprintf(stderr, "%s:%d: File ``%s'' should exist\n", + file, line, path2); + return (0); + } + if (st1.st_ino != st2.st_ino || st1.st_dev != st2.st_dev) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, + "%s:%d: Files ``%s'' and ``%s'' are not hardlinked\n", + file, line, path1, path2); + report_failure(NULL); + } + return (0); + } + return (1); +} + +int +test_assert_file_nlinks(const char *file, int line, + const char *pathname, int nlinks) +{ + struct stat st; + int r; + + count_assertion(file, line); + r = lstat(pathname, &st); + if (r == 0 && st.st_nlink == nlinks) + return (1); + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: File ``%s'' has %d links, expected %d\n", + file, line, pathname, st.st_nlink, nlinks); + report_failure(NULL); + } + return (0); +} + +int +test_assert_file_size(const char *file, int line, + const char *pathname, long size) +{ + struct stat st; + int r; + + count_assertion(file, line); + r = lstat(pathname, &st); + if (r == 0 && st.st_size == size) + return (1); + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: File ``%s'' has size %ld, expected %ld\n", + file, line, pathname, (long)st.st_size, (long)size); + report_failure(NULL); + } + return (0); +} + +int +test_assert_is_dir(const char *file, int line, const char *pathname, int mode) +{ + struct stat st; + int r; + + count_assertion(file, line); + r = lstat(pathname, &st); + if (r != 0) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Dir ``%s'' doesn't exist\n", + file, line, pathname); + report_failure(NULL); + } + return (0); + } + if (!S_ISDIR(st.st_mode)) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: ``%s'' is not a dir\n", + file, line, pathname); + report_failure(NULL); + } + return (0); + } + if (mode < 0) { + msg[0] = '\0'; + return (1); + } + if (mode != (st.st_mode & 07777)) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Dir ``%s'' has wrong mode\n", + file, line, pathname); + fprintf(stderr, " Expected: 0%3o\n", mode); + fprintf(stderr, " Found: 0%3o\n", st.st_mode & 07777); + report_failure(NULL); + } + return (0); + } + msg[0] = '\0'; + return (1); +} + +int +test_assert_is_symlink(const char *file, int line, + const char *pathname, const char *contents) +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + // TODO: Vista supports symlinks + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Symlink ``%s'' not supported\n", + file, line, pathname); + report_failure(NULL); + } + return (0); +#else + char buff[300]; + struct stat st; + ssize_t linklen; + int r; + + count_assertion(file, line); + r = lstat(pathname, &st); + if (r != 0) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Symlink ``%s'' doesn't exist\n", + file, line, pathname); + report_failure(NULL); + } + return (0); + } + if (!S_ISLNK(st.st_mode)) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: ``%s'' should be a symlink\n", + file, line, pathname); + report_failure(NULL); + } + return (0); + } + if (contents == NULL) + return (1); + linklen = readlink(pathname, buff, sizeof(buff)); + if (linklen < 0) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: symlink ``%s'' can't be read\n", + file, line, pathname); + report_failure(NULL); + } + return (0); + } + buff[linklen] = '\0'; + if (strcmp(buff, contents) != 0) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Wrong symlink ``%s''\n", + file, line, pathname); + fprintf(stderr, " Expected: %s\n", contents); + fprintf(stderr, " Found: %s\n", buff); + report_failure(NULL); + } + return (0); + } + return (1); +#endif +} + +int +test_assert_is_reg(const char *file, int line, const char *pathname, int mode) +{ + struct stat st; + int r; + + count_assertion(file, line); + r = lstat(pathname, &st); + if (r != 0 || !S_ISREG(st.st_mode)) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: File ``%s'' doesn't exist\n", + file, line, pathname); + report_failure(NULL); + } + return (0); + } + if (mode < 0) + return (1); + if (mode != (st.st_mode & 07777)) { + ++failures; + if (!previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Dir ``%s'' has wrong mode\n", + file, line, pathname); + fprintf(stderr, " Expected: 0%3o\n", mode); + fprintf(stderr, " Found: 0%3o\n", st.st_mode & 07777); + report_failure(NULL); + } + return (0); + } + return (1); +} + int test_assert_make_dir(const char *file, int line, const char *dirname, int mode) { @@ -782,7 +1058,7 @@ test_assert_make_dir(const char *file, int line, const char *dirname, int mode) count_assertion(file, line); #if defined(_WIN32) && !defined(__CYGWIN__) - r = mkdir(dirname); + r = _mkdir(dirname); #else r = mkdir(dirname, mode); #endif @@ -790,7 +1066,7 @@ test_assert_make_dir(const char *file, int line, const char *dirname, int mode) msg[0] = '\0'; return (1); } - failures++; + ++failures; if (!verbose && previous_failures(file, line, 1)) return (0); fprintf(stderr, "%s:%d: Could not create directory\n", @@ -799,6 +1075,75 @@ test_assert_make_dir(const char *file, int line, const char *dirname, int mode) return(0); } +int +test_assert_make_hardlink(const char *file, int line, + const char *newpath, const char *linkto) +{ + int succeeded; + + count_assertion(file, line); +#if HAVE_CREATEHARDLINK + succeeded = CreateHardLink(newpath, linkto, NULL); +#elif HAVE_LINK + succeeded = !link(linkto, newpath); +#else + succeeded = 0; +#endif + if (succeeded) { + msg[0] = '\0'; + return (1); + } + ++failures; + if (verbose || !previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Could not create new hardlink\n", + file, line); + fprintf(stderr, " New link: %s\n", newpath); + fprintf(stderr, " Old name: %s\n", linkto); + } + return(0); +} + + +int +test_assert_make_symlink(const char *file, int line, + const char *newpath, const char *linkto) +{ + int succeeded; + +#if HAVE_CREATESYMBOLICLINK + int targetIsDir = 0; /* TODO: Fix this. */ + count_assertion(file, line); + succeeded = CreateSymbolicLink(newpath, linkto, targetIsDir); +#elif HAVE_SYMLINK + count_assertion(file, line); + succeeded = !symlink(linkto, newpath); +#else + succeeded = 0; +#endif + if (succeeded) { + msg[0] = '\0'; + return (1); + } + ++failures; + if (verbose || !previous_failures(file, line, 1)) { + fprintf(stderr, "%s:%d: Could not create new symlink\n", + file, line); + fprintf(stderr, " New link: %s\n", newpath); + fprintf(stderr, " Old name: %s\n", linkto); + } + return(0); +} + +int +test_assert_umask(const char *file, int line, int mask) +{ + count_assertion(file, line); + (void)file; /* UNUSED */ + (void)line; /* UNUSED */ + umask(mask); + return (1); +} + /* * Call standard system() call, but build up the command line using * sprintf() conventions. @@ -850,13 +1195,13 @@ slurpfile(size_t * sizep, const char *fmt, ...) fclose(f); return (NULL); } - p = malloc(st.st_size + 1); + p = malloc((size_t)st.st_size + 1); if (p == NULL) { fprintf(stderr, "Can't allocate %ld bytes of memory to read file %s\n", (long int)st.st_size, filename); fclose(f); return (NULL); } - bytes_read = fread(p, 1, st.st_size, f); + bytes_read = fread(p, 1, (size_t)st.st_size, f); if (bytes_read < st.st_size) { fprintf(stderr, "Can't read file %s\n", filename); fclose(f); @@ -891,6 +1236,7 @@ struct { void (*func)(void); const char *name; } tests[] = { static int test_run(int i, const char *tmpdir) { int failures_before = failures; + int oldumask; if (!quiet_flag) { printf("%d: %s\n", i, tests[i].name); @@ -901,7 +1247,7 @@ static int test_run(int i, const char *tmpdir) * Always explicitly chdir() in case the last test moved us to * a strange place. */ - if (chdir(tmpdir)) { + if (!assertChdir(tmpdir)) { fprintf(stderr, "ERROR: Couldn't chdir to temp dir %s\n", tmpdir); @@ -915,7 +1261,7 @@ static int test_run(int i, const char *tmpdir) exit(1); } /* Chdir() to that work directory. */ - if (chdir(tests[i].name)) { + if (!assertChdir(tests[i].name)) { fprintf(stderr, "ERROR: Couldn't chdir to temp dir ``%s''\n", tests[i].name); @@ -923,13 +1269,17 @@ static int test_run(int i, const char *tmpdir) } /* Explicitly reset the locale before each test. */ setlocale(LC_ALL, "C"); + /* Record the umask before we run the test. */ + umask(oldumask = umask(0)); /* Run the actual test. */ (*tests[i].func)(); + /* Restore umask */ + umask(oldumask); /* Summarize the results of this test. */ summarize(); /* If there were no failures, we can remove the work dir. */ if (failures == failures_before) { - if (!keep_temp_files && chdir(tmpdir) == 0) { + if (!keep_temp_files && assertChdir(tmpdir)) { #if defined(_WIN32) && !defined(__CYGWIN__) systemf("rmdir /S /Q %s", tests[i].name); #else @@ -1337,7 +1687,7 @@ int main(int argc, char **argv) /* If the final tmpdir is empty, we can remove it. */ /* This should be the usual case when all tests succeed. */ - chdir(".."); + assertChdir(".."); rmdir(tmpdir); return (tests_failed); diff --git a/cpio/test/test.h b/cpio/test/test.h index 1b9f5deed..62763b32f 100644 --- a/cpio/test/test.h +++ b/cpio/test/test.h @@ -45,60 +45,70 @@ #error Oops: No config.h and no pre-built configuration in test.h. #endif -#if !defined(_WIN32) || defined(__CYGWIN__) +#include /* Windows requires this before sys/stat.h */ +#include + +#ifdef USE_DMALLOC +#include +#endif +#if HAVE_DIRENT_H #include #else -#define dirent direct -#include "../cpio_windows.h" #include -#endif -#if defined(__CYGWIN__) -/* In cygwin-1.7.x, the .nlinks field of directories is - * deliberately inaccurate, because to populate it requires - * stat'ing every file in the directory, which is slow. - * So, as an optimization cygwin doesn't do that in newer - * releases; all correct applications on any platform should - * never rely on it being > 1, so this optimization doesn't - * impact the operation of correctly coded applications. - * Therefore, the cpio test should not check its accuracy - */ -# define NLINKS_INACCURATE_FOR_DIRS +#define dirent direct #endif #include #include +#ifdef HAVE_IO_H +#include +#endif #include #include #include -#include -#if !defined(_WIN32) || defined(__CYGWIN__) +#include +#ifdef HAVE_UNISTD_H #include #endif -#include #include - -#ifdef USE_DMALLOC -#include +#ifdef HAVE_WINDOWS_H +#include #endif -#ifdef __FreeBSD__ -#include /* For __FBSDID */ -#else -/* Some non-FreeBSD platforms such as newlib-derived ones like - * cygwin, have __FBSDID, so this definition must be guarded. +/* + * System-specific tweaks. We really want to minimize these + * as much as possible, since they make it harder to understand + * the mainline code. */ -#ifndef __FBSDID -#define __FBSDID(a) struct _undefined_hack -#endif + +/* Windows (including Visual Studio and MinGW but not Cygwin) */ +#if defined(_WIN32) && !defined(__CYGWIN__) +#include "../cpio_windows.h" +#define strdup _strdup +#define LOCALE_DE "deu" +#else +#define LOCALE_DE "de_DE.UTF-8" #endif +/* Visual Studio */ #ifdef _MSC_VER #define snprintf sprintf_s #endif -#if defined(_WIN32) && !defined(__CYGWIN__) -#define LOCALE_DE "deu" +/* 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 + +/* FreeBSD */ +#ifdef __FreeBSD__ +#include /* For __FBSDID */ #else -#define LOCALE_DE "de_DE.UTF-8" +/* Surprisingly, some non-FreeBSD platforms define __FBSDID. */ +#ifndef __FBSDID +#define __FBSDID(a) struct _undefined_hack +#endif #endif /* @@ -109,11 +119,12 @@ /* An implementation of the standard assert() macro */ #define assert(e) test_assert(__FILE__, __LINE__, (e), #e, NULL) - +/* chdir() and error if it fails */ +#define assertChdir(path) \ + test_assert_chdir(__FILE__, __LINE__, path) /* Assert two integers are the same. Reports value of each one if not. */ #define assertEqualInt(v1,v2) \ test_assert_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) \ test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL) @@ -143,11 +154,29 @@ /* Assert that file contents match a string; supports printf-style arguments. */ #define assertFileContents \ test_setup(__FILE__, __LINE__);test_assert_file_contents +#define assertFileHardlinks(path1, path2) \ + test_assert_file_hardlinks(__FILE__, __LINE__, path1, path2) +#define assertFileNLinks(pathname, nlinks) \ + test_assert_file_nlinks(__FILE__, __LINE__, pathname, nlinks) +#define assertFileSize(pathname, size) \ + test_assert_file_size(__FILE__, __LINE__, pathname, size) #define assertTextFileContents \ test_setup(__FILE__, __LINE__);test_assert_text_file_contents +#define assertIsDir(pathname, mode) \ + test_assert_is_dir(__FILE__, __LINE__, pathname, mode) +#define assertIsReg(pathname, mode) \ + test_assert_is_reg(__FILE__, __LINE__, pathname, mode) +#define assertIsSymlink(pathname, contents) \ + test_assert_is_symlink(__FILE__, __LINE__, pathname, contents) /* Create a directory, report error if it fails. */ #define assertMakeDir(dirname, mode) \ test_assert_make_dir(__FILE__, __LINE__, dirname, mode) +#define assertMakeHardlink(newfile, oldfile) \ + test_assert_make_hardlink(__FILE__, __LINE__, newfile, oldfile) +#define assertMakeSymlink(newfile, linkto) \ + test_assert_make_symlink(__FILE__, __LINE__, newfile, linkto) +#define assertUmask(mask) \ + test_assert_umask(__FILE__, __LINE__, mask) /* * This would be simple with C99 variadic macros, but I don't want to @@ -160,21 +189,31 @@ /* Function declarations. These are defined in test_utility.c. */ void failure(const char *fmt, ...); -void test_setup(const char *, int); -void test_skipping(const char *fmt, ...); int test_assert(const char *, int, int, const char *, void *); +int test_assert_chdir(const char *, int, const char *); int test_assert_empty_file(const char *, ...); -int test_assert_non_empty_file(const char *, ...); int test_assert_equal_file(const char *, const char *, ...); -int test_assert_equal_int(const char *, int, int, const char *, int, const char *, void *); +int test_assert_equal_int(const char *, int, long long, const char *, long long, const char *, void *); +int test_assert_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *); int test_assert_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *); 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 void *, const char *, const void *, const char *, size_t, const char *, void *); int test_assert_file_contents(const void *, int, const char *, ...); -int test_assert_text_file_contents(const char *buff, const char *f); int test_assert_file_exists(const char *, ...); +int test_assert_file_hardlinks(const char *, int, const char *, const char *); +int test_assert_file_nlinks(const char *, int, const char *, int); int test_assert_file_not_exists(const char *, ...); +int test_assert_file_size(const char *, int, const char *, long); +int test_assert_is_dir(const char *, int, const char *, int); +int test_assert_is_reg(const char *, int, const char *, int); +int test_assert_is_symlink(const char *, int, const char *, const char *); int test_assert_make_dir(const char *, int, const char *, int); +int test_assert_make_hardlink(const char *, int, const char *newpath, const char *); +int test_assert_make_symlink(const char *, int, const char *newpath, const char *); +int test_assert_non_empty_file(const char *, ...); +int test_assert_text_file_contents(const char *buff, const char *f); +int test_assert_umask(const char *, int, int); +void test_setup(const char *, int); +void test_skipping(const char *fmt, ...); /* Like sprintf, then system() */ int systemf(const char * fmt, ...);