Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

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.
  • Loading branch information...
bnoordhuis committed May 31, 2013
1 parent 442d11d commit 31c6abf217906e7b23145ecf7ba4f4f855dad43f
Showing with 33 additions and 23 deletions.
  1. +10 −0 test/task.h
  2. +1 −1 test/test-fs-event.c
  3. +21 −21 test/test-fs.c
  4. +1 −1 test/test-spawn.c
@@ -43,6 +43,16 @@
# define TEST_PIPENAME_2 "/tmp/uv-test-sock2"
#endif

#ifdef _WIN32
# include <io.h>
# 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) \
@@ -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);
@@ -116,7 +116,7 @@ static void check_permission(const char* filename, int mode) {
s = &req.statbuf;
#ifdef _WIN32
/*
* On Windows, chmod can only modify S_IWUSR (_S_IWRITE) bit,
* On Windows, chmod can only modify S_IWUSR (_S_IWUSR) bit,
* so only testing for the specified flags.
*/
ASSERT((s->st_mode & 0777) & mode);
@@ -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,15 +756,15 @@ 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);
ASSERT(r == 0);
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,15 +1439,15 @@ 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);
ASSERT(r == 0);
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);
@@ -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);

0 comments on commit 31c6abf

Please sign in to comment.
You can’t perform that action at this time.