Skip to content

[WasmFS] Add testcases for absolute path handling with NODERAWFS #24733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -10474,15 +10474,39 @@ def test_noderawfs_disables_embedding(self):
err = self.expect_fail(base + ['--embed-file', 'somefile'])
self.assertContained(expected, err)

def test_noderawfs_access_abspath(self):
@crossplatform
@parameterized({
'': ([],),
'wasmfs': (['-sWASMFS'],),
})
def test_noderawfs_access_abspath(self, args):
create_file('foo', 'bar')
create_file('access.c', r'''
#include <unistd.h>
int main(int argc, char** argv) {
return access(argv[1], F_OK);
}
''')
self.run_process([EMCC, 'access.c', '-sNODERAWFS'])
self.run_process([EMCC, 'access.c', '-sNODERAWFS'] + args)
self.run_js('a.out.js', args=[os.path.abspath('foo')])

@crossplatform
@parameterized({
'': ([],),
'wasmfs': (['-sWASMFS'],),
})
def test_noderawfs_open_abspath(self, args):
create_file('foo', 'bar')
create_file('open.c', r'''
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char** argv) {
int fd = open(argv[1], O_RDONLY, 0644);
if (fd == -1) return 1;
return close(fd) == -1;
}
''')
self.run_process([EMCC, 'open.c', '-sNODERAWFS'] + args)
self.run_js('a.out.js', args=[os.path.abspath('foo')])

def test_noderawfs_readfile_prerun(self):
Expand Down