From 3ddfb4a9cc73fc9fc11576a83da9449630f6f634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 11 Feb 2015 22:07:11 +0100 Subject: [PATCH] windows: fix setting dirent types on uv_fs_scandir_next Also make the tests more strict. PR-URL: https://github.com/libuv/libuv/pull/201 Reviewed-By: Tim Caswell Reviewed-By: Bert Belder --- include/uv-win.h | 1 + test/test-fs.c | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/uv-win.h b/include/uv-win.h index b744d624..24b22b31 100644 --- a/include/uv-win.h +++ b/include/uv-win.h @@ -294,6 +294,7 @@ typedef struct uv__dirent_s { char d_name[1]; } uv__dirent_t; +#define HAVE_DIRENT_TYPES #define UV__DT_DIR UV_DIRENT_DIR #define UV__DT_FILE UV_DIRENT_FILE #define UV__DT_LINK UV_DIRENT_LINK diff --git a/test/test-fs.c b/test/test-fs.c index 2c392251..cc5dc744 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -436,7 +436,11 @@ static void scandir_cb(uv_fs_t* req) { while (UV_EOF != uv_fs_scandir_next(req, &dent)) { ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); - ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN); +#ifdef HAVE_DIRENT_TYPES + ASSERT(dent.type == UV_DIRENT_FILE); +#else + ASSERT(dent.type == UV_DIRENT_UNKNOWN); +#endif } scandir_cb_count++; ASSERT(req->path); @@ -875,7 +879,11 @@ TEST_IMPL(fs_async_dir) { ASSERT(scandir_req.ptr); while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); - ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN); +#ifdef HAVE_DIRENT_TYPES + ASSERT(dent.type == UV_DIRENT_FILE); +#else + ASSERT(dent.type == UV_DIRENT_UNKNOWN); +#endif } uv_fs_req_cleanup(&scandir_req); ASSERT(!scandir_req.ptr); @@ -1695,7 +1703,11 @@ TEST_IMPL(fs_symlink_dir) { ASSERT(scandir_req.ptr); while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); - ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN); +#ifdef HAVE_DIRENT_TYPES + ASSERT(dent.type == UV_DIRENT_FILE); +#else + ASSERT(dent.type == UV_DIRENT_UNKNOWN); +#endif } uv_fs_req_cleanup(&scandir_req); ASSERT(!scandir_req.ptr); @@ -1715,7 +1727,11 @@ TEST_IMPL(fs_symlink_dir) { ASSERT(scandir_req.ptr); while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); - ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN); +#ifdef HAVE_DIRENT_TYPES + ASSERT(dent.type == UV_DIRENT_FILE); +#else + ASSERT(dent.type == UV_DIRENT_UNKNOWN); +#endif } uv_fs_req_cleanup(&scandir_req); ASSERT(!scandir_req.ptr);