Skip to content
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

Implements stat device/inode on WASI and GOOS=js #1041

Merged
merged 1 commit into from
Jan 17, 2023
Merged

Conversation

codefromthecrypt
Copy link
Contributor

@codefromthecrypt codefromthecrypt commented Jan 16, 2023

This implements stat device and inode for WASI and GOOS=js, though it does not implement the host side for windows, yet. Doing windows requires plumbing as the values needed aren't exposed in Go. When we re-do the syscallfs file type to have a stat method, we can address that glitch. Meanwhile, I can find no Go sourcebase that does any better, though the closest is the implementation details of os.SameFile.

I verified this with wasi-testsuite which now passes all but 1 case which is unrelated (we haven't yet implemented fd_tell).

$ python3 test-runner/wasi_test_runner.py -t ./tests/assemblyscript/testsuite/  ./tests/c/testsuite/ -r adapters/wazero.sh
Test environ_get-multiple-variables passed
Test fd_write-to-invalid-fd passed
Test environ_sizes_get-multiple-variables passed
Test args_sizes_get-no-arguments passed
Test proc_exit-success passed
Test proc_exit-failure passed
Test args_get-multiple-arguments passed
Test args_sizes_get-multiple-arguments passed
Test fd_write-to-stdout passed
Test random_get-non-zero-length passed
Test environ_sizes_get-no-variables passed
Test random_get-zero-length passed
Test lseek failed
  [exit_code] 0 == 1
STDOUT:

STDERR:
+ exec wazero run -hostlogging=filesystem -mount=/Users/adrian/oss/wasi-testsuite/tests/c/testsuite:/ /Users/adrian/oss/wasi-testsuite/tests/c/testsuite/lseek.wasm
==> wasi_snapshot_preview1.fd_prestat_get(fd=3)
<== (prestat={pr_name_len=1},errno=ESUCCESS)
==> wasi_snapshot_preview1.fd_prestat_dir_name(fd=3)
<== (path=/,errno=ESUCCESS)
==> wasi_snapshot_preview1.fd_prestat_get(fd=4)
<== (prestat=,errno=EBADF)
==> wasi_snapshot_preview1.fd_fdstat_get(fd=3)
<== (stat={filetype=DIRECTORY,fdflags=,fs_rights_base=,fs_rights_inheriting=},errno=ESUCCESS)
==> wasi_snapshot_preview1.path_open(fd=3,dirflags=SYMLINK_FOLLOW,path=fs-tests.dir/lseek.txt,oflags=,fs_rights_base=,fs_rights_inheriting=,fdflags=)
<== (opened_fd=4,errno=ESUCCESS)
==> wasi_snapshot_preview1.fd_read(fd=4,iovs=69712,iovs_len=2)
<== (nread=8,errno=ESUCCESS)
==> wasi_snapshot_preview1.fd_seek(fd=4,offset=-4,whence=1,result.newoffset=69720)
<== errno=ESUCCESS
--> wasi_snapshot_preview1.fd_tell(fd=4,result.offset=69720)
<-- errno=ENOSYS
Assertion failed: lseek(fd, 0, SEEK_CUR) == 4 (testsuite/lseek.c: main: 22)
error instantiating wasm binary: module[] function[_start] failed: wasm error: unreachable
wasm stack trace:
	.abort()
	.__assert_fail(i32,i32,i32,i32)
	.__original_main() i32
	._start()

Test clock_getres-realtime passed
Test clock_gettime-monotonic passed
Test clock_getres-monotonic passed
Test fopen-with-access passed
Test stat-dev-ino passed
Test fdopendir-with-access passed
Test clock_gettime-realtime passed
Test pwrite-with-access passed
Test fopen-with-no-access passed
Test pread-with-access passed

===== Test results =====
Runtime: wazero v0.0.0
Suite: WASI Assemblyscript tests
  Total: 12
  Passed:  12
  Failed:  0

Suite: WASI C tests
  Total: 11
  Passed:  10
  Failed:  1

Test suites: 1 failed, 1 passed, 0 total
Tests:       1 failed, 22 passed, 0 total

This implements stat device and inode for WASI and GOOS=js, though it
does not implement the host side for windows, yet. Doing windows
requires plumbing as the values needed aren't exposed in Go. When we
re-do the syscallfs file type to have a stat method, we can address that
glitch. Meanwhile, I can find no Go sourcebase that does any better,
though the closest is the implementation details of os.SameFile.

I verified this with wasi-testsuite which now passes all but 1 case
which is unrelated (we haven't yet implemented `lseek`).

Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt codefromthecrypt marked this pull request as ready for review January 16, 2023 23:36
@codefromthecrypt codefromthecrypt mentioned this pull request Jan 16, 2023
5 tasks
@codefromthecrypt codefromthecrypt merged commit 3609d74 into main Jan 17, 2023
@codefromthecrypt codefromthecrypt deleted the inodes branch January 17, 2023 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants