Skip to content

Commit 9362274

Browse files
hoodmanedschuff
andauthored
Merge test_fs_open_no_permissions with test_fcntl_open. NFC (emscripten-core#23231)
Co-authored-by: Derek Schuff <[email protected]>
1 parent 25dea46 commit 9362274

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

test/fcntl/test_fcntl_open.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,18 @@ void test() {
151151
errno = 0;
152152
}
153153

154+
void test_open_create_no_permissions() {
155+
int res = open("a", O_CREAT, 0);
156+
printf("error: %s\n", strerror(errno));
157+
assert(res >= 0);
158+
struct stat st;
159+
assert(stat("a", &st) == 0);
160+
assert((st.st_mode & 0777) == 0);
161+
}
162+
154163
int main() {
155164
setup();
156165
test();
166+
test_open_create_no_permissions();
157167
return 0;
158168
}

test/fs/test_fs_open_no_permissions.c

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/test_core.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5544,9 +5544,13 @@ def test_fcntl(self):
55445544
self.add_pre_run("FS.createDataFile('/', 'test', 'abcdef', true, true, false);")
55455545
self.do_run_in_out_file_test('fcntl/test_fcntl.c')
55465546

5547+
@crossplatform
55475548
@also_with_nodefs_both
55485549
@crossplatform
55495550
def test_fcntl_open(self):
5551+
nodefs = '-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args
5552+
if nodefs and WINDOWS:
5553+
self.skipTest('Stat mode behavior does not match on Windows')
55505554
if '-DNODERAWFS' in self.emcc_args and not LINUX:
55515555
self.skipTest('noderawfs fails here under non-linux')
55525556
self.do_run_in_out_file_test('fcntl/test_fcntl_open.c')
@@ -5869,13 +5873,6 @@ def test_fs_rename_on_existing(self):
58695873
def test_fs_readdir_ino_matches_stat_ino(self):
58705874
self.do_runf('fs/test_fs_readdir_ino_matches_stat_ino.c', 'success')
58715875

5872-
@also_with_nodefs_both
5873-
@crossplatform
5874-
def test_fs_open_no_permissions(self):
5875-
if ('-DNODEFS' in self.emcc_args or '-DNODERAWFS' in self.emcc_args) and WINDOWS:
5876-
self.skipTest('fs_open_no_permissions fails on windows')
5877-
self.do_runf('fs/test_fs_open_no_permissions.c', 'success')
5878-
58795876
@also_with_nodefs_both
58805877
@crossplatform
58815878
@no_windows('https://github.com/emscripten-core/emscripten/issues/8882')

0 commit comments

Comments
 (0)