diff --git a/test/test-fs.c b/test/test-fs.c index 4b5051df..75cefe32 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -1323,6 +1323,25 @@ TEST_IMPL(fs_fstat) { file = req.result; uv_fs_req_cleanup(&req); +#ifndef _WIN32 + ASSERT(0 == fstat(file, &t)); + ASSERT(0 == uv_fs_fstat(NULL, &req, file, NULL)); + ASSERT(req.result == 0); + s = req.ptr; +# if defined(__APPLE__) + ASSERT(s->st_birthtim.tv_sec == t.st_birthtimespec.tv_sec); + ASSERT(s->st_birthtim.tv_nsec == t.st_birthtimespec.tv_nsec); +# elif defined(__linux__) + /* If statx() is supported, the birth time should be equal to the change time + * because we just created the file. On older kernels, it's set to zero. + */ + ASSERT(s->st_birthtim.tv_sec == 0 || + s->st_birthtim.tv_sec == t.st_ctim.tv_sec); + ASSERT(s->st_birthtim.tv_nsec == 0 || + s->st_birthtim.tv_nsec == t.st_ctim.tv_nsec); +# endif +#endif + iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); ASSERT(r == sizeof(test_buf)); @@ -1357,10 +1376,6 @@ TEST_IMPL(fs_fstat) { ASSERT(s->st_mtim.tv_nsec == t.st_mtimespec.tv_nsec); ASSERT(s->st_ctim.tv_sec == t.st_ctimespec.tv_sec); ASSERT(s->st_ctim.tv_nsec == t.st_ctimespec.tv_nsec); - ASSERT(s->st_birthtim.tv_sec == t.st_birthtimespec.tv_sec); - ASSERT(s->st_birthtim.tv_nsec == t.st_birthtimespec.tv_nsec); - ASSERT(s->st_flags == t.st_flags); - ASSERT(s->st_gen == t.st_gen); #elif defined(_AIX) ASSERT(s->st_atim.tv_sec == t.st_atime); ASSERT(s->st_atim.tv_nsec == 0); @@ -1395,8 +1410,6 @@ TEST_IMPL(fs_fstat) { defined(__NetBSD__) ASSERT(s->st_birthtim.tv_sec == t.st_birthtim.tv_sec); ASSERT(s->st_birthtim.tv_nsec == t.st_birthtim.tv_nsec); - ASSERT(s->st_flags == t.st_flags); - ASSERT(s->st_gen == t.st_gen); # endif #else ASSERT(s->st_atim.tv_sec == t.st_atime); @@ -1408,14 +1421,10 @@ TEST_IMPL(fs_fstat) { #endif #endif -#if defined(__linux__) - /* If statx() is supported, the birth time should be equal to the change time - * because we just created the file. On older kernels, it's set to zero. - */ - ASSERT(s->st_birthtim.tv_sec == 0 || - s->st_birthtim.tv_sec == t.st_ctim.tv_sec); - ASSERT(s->st_birthtim.tv_nsec == 0 || - s->st_birthtim.tv_nsec == t.st_ctim.tv_nsec); +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) + ASSERT(s->st_flags == t.st_flags); + ASSERT(s->st_gen == t.st_gen); +#else ASSERT(s->st_flags == 0); ASSERT(s->st_gen == 0); #endif