Skip to content

Commit 5a0c6c8

Browse files
authored
Fix test_unistd_access. NFC (#23011)
This test was not correctly verifying the file access modes after chmod/lchmod. Fixing the checks required disabling the lchmod test since that simply doesn't work under node (or on linux).
1 parent f028aa1 commit 5a0c6c8

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/unistd/access.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,34 @@ int main() {
6666
printf("F_OK(%s): %d\n", "renamedfile", faccessat(AT_FDCWD, "renamedfile", F_OK, 0));
6767
printf("errno: %d\n", errno);
6868

69+
chmod("fchmodtest", 0666);
6970
struct stat fileStats;
7071
stat("fchmodtest", &fileStats);
71-
chmod("fchmodtest", 0666);
72-
assert(fileStats.st_mode & 0666);
73-
72+
assert((fileStats.st_mode & 0777) == 0666);
73+
7474
EM_ASM(
7575
var fchmodstream = FS.open("fchmodtest", "r");
7676
FS.fchmod(fchmodstream.fd, 0777);
7777
);
7878
stat("fchmodtest", &fileStats);
79-
assert(fileStats.st_mode & 0777);
79+
assert((fileStats.st_mode & 0777) == 0777);
8080

81+
#if !defined(NODEFS) && !defined(NODERAWFS)
82+
// Node (and indeed linux) does not support lchmod
83+
// so skip this part of the test.
8184
EM_ASM(
8285
FS.symlink('writeable', 'symlinkfile');
8386
FS.lchmod('symlinkfile', 0777);
8487
);
85-
88+
8689
struct stat symlinkStats;
8790

8891
lstat("symlinkfile", &symlinkStats);
89-
assert(symlinkStats.st_mode & 0777);
92+
assert((symlinkStats.st_mode & 0777) == 0777);
9093

9194
stat("writeable", &fileStats);
92-
assert(fileStats.st_mode & 0222);
95+
assert((fileStats.st_mode & 0777) == 0222);
96+
#endif
9397

9498
EM_ASM(
9599
var ex;
@@ -99,7 +103,7 @@ int main() {
99103
ex = err;
100104
}
101105
assert(ex.name === "ErrnoError" && ex.errno === 44 /* ENOENT */);
102-
106+
103107
try {
104108
FS.fchmod(99, 0777);
105109
} catch (err) {
@@ -114,7 +118,7 @@ int main() {
114118
}
115119
assert(ex.name === "ErrnoError" && ex.errno === 44 /* ENOENT */);
116120
);
117-
121+
118122

119123
// Restore full permissions on all created files so that python test runner rmtree
120124
// won't have problems on deleting the files. On Windows, calling shutil.rmtree()

0 commit comments

Comments
 (0)