* Reduce duplication in error messages
This commit removes duplication in error messages where the same text
would show up multiple times in a fully rendered error message.
When using `derive(Error)` when the `#[from]` attribute is used there's
no need to also render that payload into the error string because the
`#[from]` establishes a "backtrace" which means that when the full
context of an error is rendered it will include the `#[from]` in the
lower frames of the backtrace anyway.
This commit audits the `derive(Error)` implementations to avoid
duplication in the rendered error messages, ensuring that if `#[from]`
is used then the `#[from]` field isn't also rendered in the textual
description.
* Search the full error in wast assertions
Don't just search the top error, but search the whole backtrace by using
the `{:?}` format instead of `{}`.
A small amount of cleanup for the top-level of this repository, where
the `installer` directory just had one misc file for the Windows
installer which we can put elsewhere inside of `ci`, another misc folder
but one that already has a few files in it.
* General Cargo.toml cleanup.
- Remove travis-ci attributes.
- Remove "experimental" badges from actively-developed crates.
- Reflow some long lines.
- Use dependency features consistently.
- Add readme attributes
* Update WASI to the latest trunk.
This notably adds a .gitignore file for the WASI directory.
* Refactor Lightbeam's tests.
This refactors Lightbeam's tests.rs file into several pieces, separating
quickcheck tests into their own file, and moving tests which can be run as
wast tests into `tests/misc_testsuite`, and creating a tests directory
for the rest.
* Remove the old filetests tests.
These are all covered by misc_testsuite and spec_testsuite tests.
* rustfmt
* Remove the "bench" feature.
This commit fixes a subtle bug in `fd_readdir` implementation on
BSD-style nixes. In particular, the bug only resurfaced when testing in
release mode, and I can only assume it was due to a unlucky combination
of compiler optimizations and at first sight correct casting of `d_name`
pointer from `const* i8` to `const* u8`. This is now fixed by first
converting `d_name` to `std::str` by using `std::ffi::CStr::to_str`, and
then using the resultant `std::str` to copy the properly validated `u8`
contents into the Wasm buffer.
Furthermore, this commit fixes incorrect handling of the `readdir` loop
break condition. Although undocumented in BSD man pages, the signalling
is the same as on Linux where a null ptr returned by `readdir` signals
the end of the dir stream when the errno code has not changed since
before calling `readdir` inside a loop. Upon a fault such as an invalid
file descriptor, the errno *will* change after executing `readdir`.
* Update the top-level README.md and embedding documentation.
wasmtime-api is now the primary external API crate, so recommend that
instead of wasmtime-jit.
Also, enable wasmtime-api's C API by default, so that it shows up on
docs.rs, and to make it easier to use.
And, add basic embedding documentation and link to it from the
README.md. Credit to @yurydelendik for the content.
* Use the new wasm-c-api URL.
* Don't pass --features wasm-c-api, as it is now on by default.
This commit simplifies the build script slightly for generating tests by
doing a few dull refactorings:
* Leaves formatting to `rustfmt`
* Extract bulk of code execution into a top-level shared `run_wast`
function so each test is a one-liner
* Use `anyhow` for errors both in the script and in tests
Some wasi-common tests assume that stdin is never ready to be read, but
on CI stdin is closed so it's always ready to be read. Work around this
by guaranteeing that wasi-common tests always have an unreadable stdin
pipe by creating our own pipe.
This commit switches the beta/nightly tests to happen on Ubuntu instead
of macOS. Turns out GitHub Actions has scheduling limitations on macOS
that limit repositories to 5 concurrent jobs per repository, so let's
reduce the load a bit by running more builds on Linux than mac.
We needed a workaround when using wabt on old Linux distros due to using
old versions of `strtof`. With the switch to `wat`, we no longer need
these workarounds.
This commit merges [CraneStation/wasi-common] repo as a subdir of
this repo while preserving **all** of git history. There is an
initiative to pull `wasi-common` into [CraneStation/wasmtime], and
[CraneStation/wasmtime] becoming a monorepo. This came about for
several reasons with a common theme of convenience, namely,
having a monorepo:
1. cleans up the problem of dependencies (as we have seen first
hand with dependabot enabled, it can cause some grief)
2. completely removes the problem of syncing the closely dependent
repos (e.g., updating `wasi-common` with say a bugfix generally
implies creating a "sync" commit for pulling in the changes into
the "parent" repo, in this case, `wasmtime`)
3. mainly for the two reasons above, makes publishing to crates.io
easier
4. hopefully streamlines the process of getting the community
involved in contributing to `wasi-common` as now everything
is one place
[CraneStation/wasi-common]: https://github.com/CraneStation/wasi-common
[CraneStation/wasmtime]: https://github.com/CraneStation/wasmtime
* Initial checkin.
* Update to rust-lang libc.
* Add a .gitignore file.
* Factor out functions for cleaning up files and directories.
* Fix a typo in a comment.
* Print a "Success!" message if all tests passed.
* Factor out code for creating directories.
* Add wrappers around WASI functions.
These wrappers handle converting from &str to pointer+length and handle
unsafe.
* More refactoring.
* Refactor a fd_close helper.
* Move utility functions into a separate file.
* cargo update
* Add a basic test for random_get.
* Test that directories aren't resizable.
* Test clearing __WASI_RIGHT_PATH_FILESTAT_SET_SIZE.
Ensure that clearing __WASI_RIGHT_PATH_FILESTAT_SET_SIZE succeeds before
testing file truncation.
* cargo update
* Modularise tests for easier use with wasi-common crate
* Add a Code of Conduct and CONTRIBUTING.md.
* Fix typo
* Add testcase for fd_allocate
* Add positive test for fd_renumber
* Assert bufused in readlink_no_buffer testcase
* Add positive readlink testcase
* Add testcase for fd_seek and fd_tell
* Add fd_p{read, write} test
* Add README
* Add cases with trailing slashes to interesting_paths
* Split nofollow_errors testcase into two
* nofollow_errors now operators on symlinks to existing resources
* dangling_symlink covers danling symlinks tests
* Factor out a `create_file` helper function.
* Switch from the error crate to `std::io::Error::last_os_error()`.
* Use `create_file` in the readlink test too.
* Add a test for fd_filestat_set_*
* Minor refactoring
Add missing cleanup_file calls to file_pread_pwrite and
file_seek_tell.
* Add testcase for unbuffered fd_write; fixes#11
* Add testcase for path_rename
* Use the wasi crate.
Switch from depending on libc to depending on the new wasi crate to provide
the low-level WASI interfaces.
See also https://github.com/rust-lang/libc/pull/1461.
* Add a test for path_filestat_*
* Add a test for fd_readdir
* Use expect instead of unwrap
* Add a check for ino.
* Fix the build
* Don't assume a specific order of dirents
* Better test
* Test cookie value
* Fix file types
* Fix the test
* Fix the test
* Fix the test
* Cleanup
* Minor formatting tidying in README.md.
* Fix miscellaneous clippy warnings.
* Rename the crate to wasi-misc-tests.
* Update to wasi 0.7.0.
This switches from using the libc wasi bindings to using the wasi
crate's bindings. This eliminates a git dependency on libc, updates
to the new-style bindings which use Result where possible, and treats
functions that operate on raw file descriptors as unsafe.
* Add various tests for trailing-slash behavior.
* Sync new testcases with latest upstream
* Fix path_filestat testcase
* Add smoke test for fd_advise
This test is a true smoke test as it only tests whether issuing
an advise call to the host's kernel doesn't yield an error. The
consequence of issuing such a syscall is not tested.
* Check if CLOCK_MONOTONIC is actually monotonic
* Refactor the inequality assertions for more debuggable errors.
* Bump libc from 0.2.62 to 0.2.65
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.62 to 0.2.65.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.62...0.2.65)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
* Fix compilation error
* Enable Actions and add rust.yml (#35)
* Enable Actions and add rust.yml
This commit enables Github Actions and adds corresponding configuration in rust.yml file.
* Update rust.yml
* Fix formatting
* Add empty .rustfmt.toml config file
* Add badge to README
* Update README
* Clean up Github Actions and README
* Add test case for `poll_oneoff` syscall (#38)
* Add test case for `poll_oneoff` syscall
This commit adds a test case for `poll_oneoff` syscall. In particular,
it builds on the excellent test use case provided by @dunnock in their
repo [poll_oneoff_tests] (thanks!), and tests:
* simple timeout
* stdin read with timeout
* fd read and fd write polls
[poll_oneoff_tests]: https://github.com/dunnock/poll_oneoff_tests
* Apply suggestions and negative test for bad fd
Co-authored-by: Maxim Vorobjov <maxim.vorobjov@gmail.com>
* Add smoke test for STDOUT/ERR readwrite poll
* Add comment on stdin/out/err
* Add a test for `*at`-style functions returning `ENOTDIR` when `dirfd` is not a dir.
* Remove misc_testsuite submodule
* Add "publish=false" to Cargo.toml; remove LICENSE