Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
test: don't use S_IREAD and S_IWRITE
Browse files Browse the repository at this point in the history
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 31c6abf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
10 changes: 10 additions & 0 deletions test/task.h
Expand Up @@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion test/test-fs-event.c
Expand Up @@ -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);
Expand Down
42 changes: 21 additions & 21 deletions test/test-fs.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/test-spawn.c
Expand Up @@ -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);

Expand Down

0 comments on commit 31c6abf

Please sign in to comment.