Skip to content

Commit ede8318

Browse files
committed
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.
1 parent 442d11d commit ede8318

File tree

4 files changed

+32
-22
lines changed

4 files changed

+32
-22
lines changed

test/task.h

+10
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
# define TEST_PIPENAME_2 "/tmp/uv-test-sock2"
4444
#endif
4545

46+
#ifdef _WIN32
47+
# include <io.h>
48+
# ifndef S_IRUSR
49+
# define S_IRUSR _S_IREAD
50+
# endif
51+
# ifndef S_IWUSR
52+
# define S_IWUSR _S_IWRITE
53+
# endif
54+
#endif
55+
4656
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
4757

4858
#define container_of(ptr, type, member) \

test/test-fs-event.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void create_file(uv_loop_t* loop, const char* name) {
5656
uv_fs_t req;
5757

5858
r = uv_fs_open(loop, &req, name, O_WRONLY | O_CREAT,
59-
S_IWRITE | S_IREAD, NULL);
59+
S_IWUSR | S_IRUSR, NULL);
6060
ASSERT(r != -1);
6161
file = r;
6262
uv_fs_req_cleanup(&req);

test/test-fs.c

+20-20
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ TEST_IMPL(fs_file_async) {
600600
loop = uv_default_loop();
601601

602602
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
603-
S_IREAD | S_IWRITE, create_cb);
603+
S_IRUSR | S_IWUSR, create_cb);
604604
ASSERT(r == 0);
605605
uv_run(loop, UV_RUN_DEFAULT);
606606

@@ -663,7 +663,7 @@ TEST_IMPL(fs_file_sync) {
663663
loop = uv_default_loop();
664664

665665
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
666-
S_IWRITE | S_IREAD, NULL);
666+
S_IWUSR | S_IRUSR, NULL);
667667
ASSERT(r != -1);
668668
ASSERT(open_req1.result != -1);
669669
uv_fs_req_cleanup(&open_req1);
@@ -756,15 +756,15 @@ TEST_IMPL(fs_async_dir) {
756756

757757
/* Create 2 files synchronously. */
758758
r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT,
759-
S_IWRITE | S_IREAD, NULL);
759+
S_IWUSR | S_IRUSR, NULL);
760760
ASSERT(r != -1);
761761
uv_fs_req_cleanup(&open_req1);
762762
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
763763
ASSERT(r == 0);
764764
uv_fs_req_cleanup(&close_req);
765765

766766
r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT,
767-
S_IWRITE | S_IREAD, NULL);
767+
S_IWUSR | S_IRUSR, NULL);
768768
ASSERT(r != -1);
769769
uv_fs_req_cleanup(&open_req1);
770770
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
@@ -840,7 +840,7 @@ TEST_IMPL(fs_async_sendfile) {
840840
unlink("test_file");
841841
unlink("test_file2");
842842

843-
f = open("test_file", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD);
843+
f = open("test_file", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
844844
ASSERT(f != -1);
845845

846846
r = write(f, "begin\n", 6);
@@ -862,7 +862,7 @@ TEST_IMPL(fs_async_sendfile) {
862862
uv_fs_req_cleanup(&open_req1);
863863

864864
r = uv_fs_open(loop, &open_req2, "test_file2", O_WRONLY | O_CREAT,
865-
S_IWRITE | S_IREAD, NULL);
865+
S_IWUSR | S_IRUSR, NULL);
866866
ASSERT(r != -1);
867867
ASSERT(open_req2.result != -1);
868868
uv_fs_req_cleanup(&open_req2);
@@ -909,7 +909,7 @@ TEST_IMPL(fs_fstat) {
909909
loop = uv_default_loop();
910910

911911
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
912-
S_IWRITE | S_IREAD, NULL);
912+
S_IWUSR | S_IRUSR, NULL);
913913
ASSERT(r != -1);
914914
ASSERT(req.result != -1);
915915
file = req.result;
@@ -1003,7 +1003,7 @@ TEST_IMPL(fs_chmod) {
10031003
loop = uv_default_loop();
10041004

10051005
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1006-
S_IWRITE | S_IREAD, NULL);
1006+
S_IWUSR | S_IRUSR, NULL);
10071007
ASSERT(r != -1);
10081008
ASSERT(req.result != -1);
10091009
file = req.result;
@@ -1100,7 +1100,7 @@ TEST_IMPL(fs_chown) {
11001100
loop = uv_default_loop();
11011101

11021102
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1103-
S_IWRITE | S_IREAD, NULL);
1103+
S_IWUSR | S_IRUSR, NULL);
11041104
ASSERT(r != -1);
11051105
ASSERT(req.result != -1);
11061106
file = req.result;
@@ -1166,7 +1166,7 @@ TEST_IMPL(fs_link) {
11661166
loop = uv_default_loop();
11671167

11681168
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1169-
S_IWRITE | S_IREAD, NULL);
1169+
S_IWUSR | S_IRUSR, NULL);
11701170
ASSERT(r != -1);
11711171
ASSERT(req.result != -1);
11721172
file = req.result;
@@ -1274,7 +1274,7 @@ TEST_IMPL(fs_symlink) {
12741274
loop = uv_default_loop();
12751275

12761276
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT,
1277-
S_IWRITE | S_IREAD, NULL);
1277+
S_IWUSR | S_IRUSR, NULL);
12781278
ASSERT(r != -1);
12791279
ASSERT(req.result != -1);
12801280
file = req.result;
@@ -1439,15 +1439,15 @@ TEST_IMPL(fs_symlink_dir) {
14391439
uv_fs_req_cleanup(&req);
14401440

14411441
r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT,
1442-
S_IWRITE | S_IREAD, NULL);
1442+
S_IWUSR | S_IRUSR, NULL);
14431443
ASSERT(r != -1);
14441444
uv_fs_req_cleanup(&open_req1);
14451445
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
14461446
ASSERT(r == 0);
14471447
uv_fs_req_cleanup(&close_req);
14481448

14491449
r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT,
1450-
S_IWRITE | S_IREAD, NULL);
1450+
S_IWUSR | S_IRUSR, NULL);
14511451
ASSERT(r != -1);
14521452
uv_fs_req_cleanup(&open_req1);
14531453
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
@@ -1504,7 +1504,7 @@ TEST_IMPL(fs_utime) {
15041504
loop = uv_default_loop();
15051505
unlink(path);
15061506
r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT,
1507-
S_IWRITE | S_IREAD, NULL);
1507+
S_IWUSR | S_IRUSR, NULL);
15081508
ASSERT(r != -1);
15091509
ASSERT(req.result != -1);
15101510
uv_fs_req_cleanup(&req);
@@ -1589,7 +1589,7 @@ TEST_IMPL(fs_futime) {
15891589
loop = uv_default_loop();
15901590
unlink(path);
15911591
r = uv_fs_open(loop, &req, path, O_RDWR | O_CREAT,
1592-
S_IWRITE | S_IREAD, NULL);
1592+
S_IWUSR | S_IRUSR, NULL);
15931593
ASSERT(r != -1);
15941594
ASSERT(req.result != -1);
15951595
uv_fs_req_cleanup(&req);
@@ -1747,7 +1747,7 @@ TEST_IMPL(fs_file_open_append) {
17471747
loop = uv_default_loop();
17481748

17491749
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
1750-
S_IWRITE | S_IREAD, NULL);
1750+
S_IWUSR | S_IRUSR, NULL);
17511751
ASSERT(r != -1);
17521752
ASSERT(open_req1.result != -1);
17531753
uv_fs_req_cleanup(&open_req1);
@@ -1779,7 +1779,7 @@ TEST_IMPL(fs_file_open_append) {
17791779
ASSERT(close_req.result != -1);
17801780
uv_fs_req_cleanup(&close_req);
17811781

1782-
r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, S_IREAD, NULL);
1782+
r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, S_IRUSR, NULL);
17831783
ASSERT(r != -1);
17841784
ASSERT(open_req1.result != -1);
17851785
uv_fs_req_cleanup(&open_req1);
@@ -1817,7 +1817,7 @@ TEST_IMPL(fs_rename_to_existing_file) {
18171817
loop = uv_default_loop();
18181818

18191819
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
1820-
S_IWRITE | S_IREAD, NULL);
1820+
S_IWUSR | S_IRUSR, NULL);
18211821
ASSERT(r != -1);
18221822
ASSERT(open_req1.result != -1);
18231823
uv_fs_req_cleanup(&open_req1);
@@ -1834,7 +1834,7 @@ TEST_IMPL(fs_rename_to_existing_file) {
18341834
uv_fs_req_cleanup(&close_req);
18351835

18361836
r = uv_fs_open(loop, &open_req1, "test_file2", O_WRONLY | O_CREAT,
1837-
S_IWRITE | S_IREAD, NULL);
1837+
S_IWUSR | S_IRUSR, NULL);
18381838
ASSERT(r != -1);
18391839
ASSERT(open_req1.result != -1);
18401840
uv_fs_req_cleanup(&open_req1);
@@ -1885,7 +1885,7 @@ TEST_IMPL(fs_read_file_eof) {
18851885
loop = uv_default_loop();
18861886

18871887
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
1888-
S_IWRITE | S_IREAD, NULL);
1888+
S_IWUSR | S_IRUSR, NULL);
18891889
ASSERT(r != -1);
18901890
ASSERT(open_req1.result != -1);
18911891
uv_fs_req_cleanup(&open_req1);

test/test-spawn.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ TEST_IMPL(spawn_stdout_to_file) {
222222
init_process_options("spawn_helper2", exit_cb);
223223

224224
r = uv_fs_open(uv_default_loop(), &fs_req, "stdout_file", O_CREAT | O_RDWR,
225-
S_IREAD | S_IWRITE, NULL);
225+
S_IRUSR | S_IWUSR, NULL);
226226
ASSERT(r != -1);
227227
uv_fs_req_cleanup(&fs_req);
228228

0 commit comments

Comments
 (0)