From ede83188f333f2adb45cb3db9d32f94f4f0aef70 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 31 May 2013 12:31:39 +0200 Subject: [PATCH] test: don't use S_IREAD and S_IWRITE They're BSD-isms and obsolete ones at that. Replace with S_IRUSR and S_IWUSR. Alias as _S_IREAD and _S_IWRITE on Windows because the '90s never ended in Redmond, WA. --- test/task.h | 10 ++++++++++ test/test-fs-event.c | 2 +- test/test-fs.c | 40 ++++++++++++++++++++-------------------- test/test-spawn.c | 2 +- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/test/task.h b/test/task.h index 308201e5..1e3f8df8 100644 --- a/test/task.h +++ b/test/task.h @@ -43,6 +43,16 @@ # define TEST_PIPENAME_2 "/tmp/uv-test-sock2" #endif +#ifdef _WIN32 +# include +# ifndef S_IRUSR +# define S_IRUSR _S_IREAD +# endif +# ifndef S_IWUSR +# define S_IWUSR _S_IWRITE +# endif +#endif + #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #define container_of(ptr, type, member) \ diff --git a/test/test-fs-event.c b/test/test-fs-event.c index 37f9cf2e..e9895115 100644 --- a/test/test-fs-event.c +++ b/test/test-fs-event.c @@ -56,7 +56,7 @@ static void create_file(uv_loop_t* loop, const char* name) { uv_fs_t req; r = uv_fs_open(loop, &req, name, O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); file = r; uv_fs_req_cleanup(&req); diff --git a/test/test-fs.c b/test/test-fs.c index 6459d125..1ab958f1 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -600,7 +600,7 @@ TEST_IMPL(fs_file_async) { loop = uv_default_loop(); r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IREAD | S_IWRITE, create_cb); + S_IRUSR | S_IWUSR, create_cb); ASSERT(r == 0); uv_run(loop, UV_RUN_DEFAULT); @@ -663,7 +663,7 @@ TEST_IMPL(fs_file_sync) { loop = uv_default_loop(); r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); @@ -756,7 +756,7 @@ TEST_IMPL(fs_async_dir) { /* Create 2 files synchronously. */ r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(loop, &close_req, open_req1.result, NULL); @@ -764,7 +764,7 @@ TEST_IMPL(fs_async_dir) { uv_fs_req_cleanup(&close_req); r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(loop, &close_req, open_req1.result, NULL); @@ -840,7 +840,7 @@ TEST_IMPL(fs_async_sendfile) { unlink("test_file"); unlink("test_file2"); - f = open("test_file", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD); + f = open("test_file", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR); ASSERT(f != -1); r = write(f, "begin\n", 6); @@ -862,7 +862,7 @@ TEST_IMPL(fs_async_sendfile) { uv_fs_req_cleanup(&open_req1); r = uv_fs_open(loop, &open_req2, "test_file2", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(open_req2.result != -1); uv_fs_req_cleanup(&open_req2); @@ -909,7 +909,7 @@ TEST_IMPL(fs_fstat) { loop = uv_default_loop(); r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(req.result != -1); file = req.result; @@ -1003,7 +1003,7 @@ TEST_IMPL(fs_chmod) { loop = uv_default_loop(); r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(req.result != -1); file = req.result; @@ -1100,7 +1100,7 @@ TEST_IMPL(fs_chown) { loop = uv_default_loop(); r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(req.result != -1); file = req.result; @@ -1166,7 +1166,7 @@ TEST_IMPL(fs_link) { loop = uv_default_loop(); r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(req.result != -1); file = req.result; @@ -1274,7 +1274,7 @@ TEST_IMPL(fs_symlink) { loop = uv_default_loop(); r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(req.result != -1); file = req.result; @@ -1439,7 +1439,7 @@ TEST_IMPL(fs_symlink_dir) { uv_fs_req_cleanup(&req); r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(loop, &close_req, open_req1.result, NULL); @@ -1447,7 +1447,7 @@ TEST_IMPL(fs_symlink_dir) { uv_fs_req_cleanup(&close_req); r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(loop, &close_req, open_req1.result, NULL); @@ -1504,7 +1504,7 @@ TEST_IMPL(fs_utime) { loop = uv_default_loop(); unlink(path); r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(req.result != -1); uv_fs_req_cleanup(&req); @@ -1589,7 +1589,7 @@ TEST_IMPL(fs_futime) { loop = uv_default_loop(); unlink(path); r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(req.result != -1); uv_fs_req_cleanup(&req); @@ -1747,7 +1747,7 @@ TEST_IMPL(fs_file_open_append) { loop = uv_default_loop(); r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); @@ -1779,7 +1779,7 @@ TEST_IMPL(fs_file_open_append) { ASSERT(close_req.result != -1); uv_fs_req_cleanup(&close_req); - r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, S_IREAD, NULL); + r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, S_IRUSR, NULL); ASSERT(r != -1); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); @@ -1817,7 +1817,7 @@ TEST_IMPL(fs_rename_to_existing_file) { loop = uv_default_loop(); r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); @@ -1834,7 +1834,7 @@ TEST_IMPL(fs_rename_to_existing_file) { uv_fs_req_cleanup(&close_req); r = uv_fs_open(loop, &open_req1, "test_file2", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); @@ -1885,7 +1885,7 @@ TEST_IMPL(fs_read_file_eof) { loop = uv_default_loop(); r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, - S_IWRITE | S_IREAD, NULL); + S_IWUSR | S_IRUSR, NULL); ASSERT(r != -1); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); diff --git a/test/test-spawn.c b/test/test-spawn.c index 56eca9c5..afa8d918 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -222,7 +222,7 @@ TEST_IMPL(spawn_stdout_to_file) { init_process_options("spawn_helper2", exit_cb); r = uv_fs_open(uv_default_loop(), &fs_req, "stdout_file", O_CREAT | O_RDWR, - S_IREAD | S_IWRITE, NULL); + S_IRUSR | S_IWUSR, NULL); ASSERT(r != -1); uv_fs_req_cleanup(&fs_req);