on Haiku (which doesn't support atime).
SVN-Revision: 1552
/* Record another failure for this line. */
++failures;
- test_filename = filename;
+ /* test_filename = filename; */
failed_lines[line].count++;
/* Determine whether to log header to console. */
static void strdump(const char *e, const char *p)
{
+ const char *q = p;
+
logprintf(" %s = ", e);
if (p == NULL) {
- logprintf("(null)");
+ logprintf("NULL");
return;
}
logprintf("\"");
}
}
logprintf("\"");
- logprintf(" (length %d)\n", p == NULL ? 0 : (int)strlen(p));
+ logprintf(" (length %d)\n", q == NULL ? -1 : (int)strlen(q));
}
/* Verify two strings are equal, dump them if not. */
void *extra)
{
assertion_count(file, line);
- if (v1 == v2 || strcmp(v1, v2) == 0)
+ if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
return (1);
failure_start(file, line, "%s != %s", e1, e2);
strdump(e1, v1);
size_t i, j;
char sep;
+ if (p == NULL) {
+ logprintf("(null)\n");
+ return;
+ }
for(i=0; i < l; i+=16) {
logprintf("%04x", (unsigned)(i + offset));
sep = ' ';
size_t offset;
assertion_count(file, line);
- if (v1 == v2 || memcmp(v1, v2, l) == 0)
+ if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0))
return (1);
failure_start(file, line, "%s != %s", e1, e2);
failure_start(test_filename, test_line, "File contents don't match");
logprintf(" file=\"%s\"\n", fn);
if (n > 0)
- hexdump(contents, buff, n > 512 ? 512 : 0, 0);
+ hexdump(contents, buff, n > 512 ? 512 : n, 0);
else {
logprintf(" File empty, contents should be:\n");
- hexdump(buff, NULL, s > 512 ? 512 : 0, 0);
+ hexdump(buff, NULL, s > 512 ? 512 : n, 0);
}
failure_finish(test_extra);
free(contents);
#else
filet_nsec = nsec = 0; /* Generic POSIX only has whole seconds. */
if (type == 'b') return (1); /* Generic POSIX doesn't have birthtime */
+#if defined(__HAIKU__)
+ if (type == 'a') return (1); /* Haiku doesn't have atime. */
+#endif
#endif
#endif
if (recent) {
{
#if defined(_WIN32) && !defined(__CYGWIN__)
assertion_count(file, line);
+ /* Windows sort-of has real symlinks, but they're only usable
+ * by privileged users and are crippled even then, so there's
+ * really not much point in bothering with this. */
return (0);
#else
char buff[300];
* for tests to use in deciding whether to bother testing symlink
* support; if the platform doesn't support symlinks, there's no point
* in checking whether the program being tested can create them.
+ *
+ * Note that the first time this test is called, we actually go out to
+ * disk to create and verify a symlink. This is necessary because
+ * symlink support is actually a property of a particular filesystem
+ * and can thus vary between directories on a single system. After
+ * the first call, this returns the cached result from memory, so it's
+ * safe to call it as often as you wish.
*/
int
canSymlink(void)
++tested;
assertion_make_file(__FILE__, __LINE__, "canSymlink.0", 0644, "a");
+ /* Note: Cygwin has its own symlink() emulation that does not
+ * use the Win32 CreateSymbolicLink() function. */
#if defined(_WIN32) && !defined(__CYGWIN__)
value = my_CreateSymbolicLinkA("canSymlink.1", "canSymlink.0", 0)
&& is_symlink(__FILE__, __LINE__, "canSymlink.1", "canSymlink.0");
#define rmdir _rmdir
#define strdup _strdup
#define umask _umask
+#define int64_t __int64
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
HANDLE h;
int r;
+ memset(bhfi, 0, sizeof(*bhfi));
h = CreateFile(path, FILE_READ_ATTRIBUTES, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE)
/* Record another failure for this line. */
++failures;
- test_filename = filename;
+ /* test_filename = filename; */
failed_lines[line].count++;
/* Determine whether to log header to console. */
static void strdump(const char *e, const char *p)
{
+ const char *q = p;
+
logprintf(" %s = ", e);
if (p == NULL) {
- logprintf("(null)\n");
+ logprintf("NULL");
return;
}
logprintf("\"");
}
}
logprintf("\"");
- logprintf(" (length %d)\n", p == NULL ? 0 : (int)strlen(p));
+ logprintf(" (length %d)\n", q == NULL ? -1 : (int)strlen(q));
}
/* Verify two strings are equal, dump them if not. */
failure_start(test_filename, test_line, "File contents don't match");
logprintf(" file=\"%s\"\n", fn);
if (n > 0)
- hexdump(contents, buff, n > 512 ? 512 : 0, 0);
+ hexdump(contents, buff, n > 512 ? 512 : n, 0);
else {
logprintf(" File empty, contents should be:\n");
- hexdump(buff, NULL, s > 512 ? 512 : 0, 0);
+ hexdump(buff, NULL, s > 512 ? 512 : n, 0);
}
failure_finish(test_extra);
free(contents);
failure_finish(NULL);
return (0);
}
- return (bhfi1.nFileIndexHigh == bhfi2.nFileIndexHigh
+ return (bhfi1.dwVolumeSerialNumber == bhfi2.dwVolumeSerialNumber
+ && bhfi1.nFileIndexHigh == bhfi2.nFileIndexHigh
&& bhfi1.nFileIndexLow == bhfi2.nFileIndexLow);
#else
struct stat st1, st2;
#else
filet_nsec = nsec = 0; /* Generic POSIX only has whole seconds. */
if (type == 'b') return (1); /* Generic POSIX doesn't have birthtime */
+#if defined(__HAIKU__)
+ if (type == 'a') return (1); /* Haiku doesn't have atime. */
+#endif
#endif
#endif
if (recent) {
int
assertion_file_size(const char *file, int line, const char *pathname, long size)
{
- struct stat st;
+ int64_t filesize;
int r;
assertion_count(file, line);
- r = lstat(pathname, &st);
- if (r == 0 && st.st_size == size)
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ {
+ BY_HANDLE_FILE_INFORMATION bhfi;
+ r = !my_GetFileInformationByName(pathname, &bhfi);
+ filesize = ((int64_t)bhfi.nFileSizeHigh << 32) + bhfi.nFileSizeLow;
+ }
+#else
+ {
+ struct stat st;
+ r = lstat(pathname, &st);
+ filesize = st.st_size;
+ }
+#endif
+ if (r == 0 && filesize == size)
return (1);
failure_start(file, line, "File %s has size %ld, expected %ld",
- pathname, (long)st.st_size, (long)size);
+ pathname, (long)filesize, (long)size);
failure_finish(NULL);
return (0);
}
{
#if defined(_WIN32) && !defined(__CYGWIN__)
assertion_count(file, line);
+ /* Windows sort-of has real symlinks, but they're only usable
+ * by privileged users and are crippled even then, so there's
+ * really not much point in bothering with this. */
return (0);
#else
char buff[300];
* for tests to use in deciding whether to bother testing symlink
* support; if the platform doesn't support symlinks, there's no point
* in checking whether the program being tested can create them.
+ *
+ * Note that the first time this test is called, we actually go out to
+ * disk to create and verify a symlink. This is necessary because
+ * symlink support is actually a property of a particular filesystem
+ * and can thus vary between directories on a single system. After
+ * the first call, this returns the cached result from memory, so it's
+ * safe to call it as often as you wish.
*/
int
canSymlink(void)
++tested;
assertion_make_file(__FILE__, __LINE__, "canSymlink.0", 0644, "a");
+ /* Note: Cygwin has its own symlink() emulation that does not
+ * use the Win32 CreateSymbolicLink() function. */
#if defined(_WIN32) && !defined(__CYGWIN__)
value = my_CreateSymbolicLinkA("canSymlink.1", "canSymlink.0", 0)
&& is_symlink(__FILE__, __LINE__, "canSymlink.1", "canSymlink.0");
#define S_ISREG(m) ((m) & _S_IFREG)
#endif
#define access _access
+#define chdir _chdir
#ifndef fileno
#define fileno _fileno
#endif
#define rmdir _rmdir
#define strdup _strdup
#define umask _umask
+#define int64_t __int64
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
HANDLE h;
int r;
+ memset(bhfi, 0, sizeof(*bhfi));
h = CreateFile(path, FILE_READ_ATTRIBUTES, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE)
void *extra)
{
assertion_count(file, line);
- if (v1 == v2 || strcmp(v1, v2) == 0)
+ if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
return (1);
failure_start(file, line, "%s != %s", e1, e2);
strdump(e1, v1);
size_t i, j;
char sep;
+ if (p == NULL) {
+ logprintf("(null)\n");
+ return;
+ }
for(i=0; i < l; i+=16) {
logprintf("%04x", (unsigned)(i + offset));
sep = ' ';
size_t offset;
assertion_count(file, line);
- if (v1 == v2 || memcmp(v1, v2, l) == 0)
+ if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0))
return (1);
failure_start(file, line, "%s != %s", e1, e2);
failure_finish(NULL);
return (0);
}
- return (bhfi1.nFileIndexHigh == bhfi2.nFileIndexHigh
+ return (bhfi1.dwVolumeSerialNumber == bhfi2.dwVolumeSerialNumber
+ && bhfi1.nFileIndexHigh == bhfi2.nFileIndexHigh
&& bhfi1.nFileIndexLow == bhfi2.nFileIndexLow);
#else
struct stat st1, st2;
#else
filet_nsec = nsec = 0; /* Generic POSIX only has whole seconds. */
if (type == 'b') return (1); /* Generic POSIX doesn't have birthtime */
+#if defined(__HAIKU__)
+ if (type == 'a') return (1); /* Haiku doesn't have atime. */
+#endif
#endif
#endif
if (recent) {
int
assertion_file_size(const char *file, int line, const char *pathname, long size)
{
- struct stat st;
+ int64_t filesize;
int r;
assertion_count(file, line);
- r = lstat(pathname, &st);
- if (r == 0 && st.st_size == size)
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ {
+ BY_HANDLE_FILE_INFORMATION bhfi;
+ r = !my_GetFileInformationByName(pathname, &bhfi);
+ filesize = ((int64_t)bhfi.nFileSizeHigh << 32) + bhfi.nFileSizeLow;
+ }
+#else
+ {
+ struct stat st;
+ r = lstat(pathname, &st);
+ filesize = st.st_size;
+ }
+#endif
+ if (r == 0 && filesize == size)
return (1);
failure_start(file, line, "File %s has size %ld, expected %ld",
- pathname, (long)st.st_size, (long)size);
+ pathname, (long)filesize, (long)size);
failure_finish(NULL);
return (0);
}