Commit Graph

120 Commits

Author SHA1 Message Date
Dan Gohman
a71f679453 Update wasi-tests to wasi 0.11. (#5488)
This updates the tests to version 0.11 of the wasi bindings. There
aren't any fundamental changes here; this just syncs up with the latest
version so that it's consistent with other users of the wasi APIs.
2023-01-03 09:43:04 -06:00
Alex Crichton
7b311004b5 Leverage Cargo's workspace inheritance feature (#4905)
* Leverage Cargo's workspace inheritance feature

This commit is an attempt to reduce the complexity of the Cargo
manifests in this repository with Cargo's workspace-inheritance feature
becoming stable in Rust 1.64.0. This feature allows specifying fields in
the root workspace `Cargo.toml` which are then reused throughout the
workspace. For example this PR shares definitions such as:

* All of the Wasmtime-family of crates now use `version.workspace =
  true` to have a single location which defines the version number.
* All crates use `edition.workspace = true` to have one default edition
  for the entire workspace.
* Common dependencies are listed in `[workspace.dependencies]` to avoid
  typing the same version number in a lot of different places (e.g. the
  `wasmparser = "0.89.0"` is now in just one spot.

Currently the workspace-inheritance feature doesn't allow having two
different versions to inherit, so all of the Cranelift-family of crates
still manually specify their version. The inter-crate dependencies,
however, are shared amongst the root workspace.

This feature can be seen as a method of "preprocessing" of sorts for
Cargo manifests. This will help us develop Wasmtime but shouldn't have
any actual impact on the published artifacts -- everything's dependency
lists are still the same.

* Fix wasi-crypto tests
2022-09-26 11:30:01 -05:00
Dan Gohman
918debfe59 Stop returning NOTCAPABLE errors from WASI calls. (#4666)
* Stop returning `NOTCAPABLE` errors from WASI calls.

`ENOTCAPABLE` was an error code that is used as part of the rights
system, from CloudABI. There is a set of flags associated with each file
descriptor listing which operations can be performed with the file
descriptor, and if an attempt is made to perform an operation with a
file descriptor that isn't permitted by its rights flags, it fails with
`ENOTCAPABLE`.

WASI is removing the rights system. For example, WebAssembly/wasi-libc#294
removed support for translating `ENOTCAPABLE` into POSIX error codes, on
the assumption that engines should stop using it.

So as another step to migrating away from the rights system, remove uses
of the `ENOTCAPABLE` error.

* Update crates/wasi-common/src/file.rs

Co-authored-by: Jamey Sharp <jamey@minilop.net>

* Update crates/wasi-common/src/dir.rs

Co-authored-by: Jamey Sharp <jamey@minilop.net>

Co-authored-by: Jamey Sharp <jamey@minilop.net>
2022-08-10 13:44:23 -07:00
Dan Gohman
0e6ffd0243 Don't try to report file size or timestamps for stdio streams. (#4531)
* Don't try to report file size or timestamps for stdio streams.

Calling `File::metadata()` on a stdio stream handle fails on Windows, where
the stdio streams are not files.

This `File::metadata()` call was effectively only being used to add file size
and timestamps to the result of `filestat_get`. It's common for users to
redirect stdio streams to interesting places, and applications
generally shouldn't change their behavior depending on the size or
timestamps of the file, if the streams are redirected to a file, so just
leave these fields to 0, which is commonly understood to represent
"unknown".

Fixes #4497.
2022-07-26 15:53:17 -07:00
Alex Crichton
1321c234e5 Remove dependency on more-asserts (#4408)
* Remove dependency on `more-asserts`

In my recent adventures to do a bit of gardening on our dependencies I
noticed that there's a new major version for the `more-asserts` crate.
Instead of updating to this though I've opted to instead remove the
dependency since I don't think we heavily lean on this crate and
otherwise one-off prints are probably sufficient to avoid the need for
pulling in a whole crate for this.

* Remove exemption for `more-asserts`
2022-07-26 16:47:33 +00:00
Dan Gohman
371ae80ac3 Migrate most of wasmtime from lazy_static to once_cell (#4368)
* Update tracing-core to a version which doesn't depend on lazy-static.

* Update crossbeam-utils to a version that doesn't depend on lazy-static.

* Update crossbeam-epoch to a version that doesn't depend on lazy-static.

* Update clap to a version that doesn't depend on lazy-static.

* Convert Wasmtime's own use of lazy_static to once_cell.

* Make `GDB_REGISTRATION`'s comment a doc comment.

* Fix compilation on Windows.
2022-07-05 10:52:48 -07:00
Alex Crichton
7b5176baea Upgrade all crates to the Rust 2021 edition (#3991)
* Upgrade all crates to the Rust 2021 edition

I've personally started using the new format strings for things like
`panic!("some message {foo}")` or similar and have been upgrading crates
on a case-by-case basis, but I think it probably makes more sense to go
ahead and blanket upgrade everything so 2021 features are always
available.

* Fix compile of the C API

* Fix a warning

* Fix another warning
2022-04-04 12:27:12 -05:00
Dan Gohman
d1fce1e836 Modify the poll_oneoff_files test tolerate OS differences. (#3346)
Modify the `poll_oneoff_files` test to avoid assuming that `poll_oneoff`
returns all pending events, as it may sometimes return only a subset of
events. When multiple events are expected, use a loop, and loop until
all events have been recorded.
2021-09-13 14:59:50 -05:00
Dan Gohman
256e942aa0 Tidy up redundant use declarations. (#3333)
This is just a minor code cleanup.
2021-09-11 12:26:54 -05:00
Dan Gohman
6a5a295019 Port wasi-common from unsafe-io to io-lifetimes (#3049)
* Port wasi-common to io-lifetimes.

This ports wasi-common from unsafe-io to io-lifetimes.

Ambient authority is now indicated via calls to `ambient_authority()`
from the ambient-authority crate, rather than using `unsafe` blocks.

The `GetSetFdFlags::set_fd_flags` function is now split into two phases,
to simplify lifetimes in implementations which need to close and re-open
the underlying file.

* Use posish for errno values instead of libc.

This eliminates one of the few remaining direct libc dependencies.

* Port to posish::io::poll.

Use posish::io::poll instead of calling libc directly. This factors out
more code from Wasmtime, and eliminates the need to manipulate raw file
descriptors directly.

And, this eliminates the last remaining direct dependency on libc in
wasi-common.

* Port wasi-c-api to io-lifetimes.

* Update to posish 0.16.0.

* Embeded NULs in filenames now get `EINVAL` instead of `EILSEQ`.

* Accept either `EILSEQ` or `EINVAL` for embedded NULs.

* Bump the nightly toolchain to 2021-07-12.

This fixes build errors on the semver crate, which as of this writing
builds with latest nightly and stable but not 2021-04-11, the old pinned
version.

* Have cap-std-sync re-export ambient_authority so that users get the same version.
2021-07-14 15:39:09 -07:00
Ulrich Weigand
c881c01cde Increase timeout for poll_oneoff tests
This increases the timeout from 50ms to 200ms, which makes the
tests reliably pass on my machine using the CI scripts againt
the s390x-linux-user qemu target.
2021-06-23 20:04:31 +02:00
Pat Hickey
c81dbe498f try upping 20ms to 50ms timeouts... 2021-05-11 17:12:48 -07:00
Pat Hickey
7ec93cb977 poll_oneoff_stdio test: increase timeout to 20ms 2021-05-11 09:22:12 -07:00
Pat Hickey
74e9b385df lets try 10ms, macos ci timed out with 5ms 2021-05-07 16:07:15 -07:00
Pat Hickey
b450094dad debug 2021-05-07 15:19:17 -07:00
Pat Hickey
ee8a8a2a90 poll_oneoff_stdio test: loosen up contract
permit both readable events to be delivered in very short interval,
rather than simultaneously.
2021-05-07 14:27:23 -07:00
Pat Hickey
9e04c5333c poll oneoff tests: what if we read a non-empty file? 2021-05-05 13:08:33 -07:00
Pat Hickey
3e8ea090c6 ci debugging 2021-05-05 11:24:27 -07:00
Pat Hickey
b7efcbe80f jump through enough hoops for the poll lifetime to work out
you program rust for a few years and you think you're done tearing your
hair out over lifetimes, well, you'll find yourself wrong
2021-04-29 16:50:22 -07:00
Pat Hickey
02581ddda0 poll_oneoff test: don't try to poll same fd for read and write 2021-04-27 17:41:07 -07:00
Dan Gohman
dd7e16762c Arrange for the new test to be called. 2021-03-22 12:50:16 -07:00
Dan Gohman
6b40724d18 Support "sleep" forms of poll_oneoff.
Add support for `poll_oneoff` calls which just sleep on a relative
timeout. This fixes a bug handling code compiled with WASI libc's `sleep`
family of functions, which call `poll_oneoff` with a `CLOCK_REALTIME`
timer, which wasn't previously implemented.
2021-03-22 12:50:16 -07:00
Dan Gohman
2d3f2adf04 Fix nondeterministic failures in poll_oneoff_stdio.
Adjust this test so that it tolerates poll_oneoff returning that both a
timeout occurred and an input is ready for reading, at the same time.
2021-03-15 11:48:19 -07:00
Pat Hickey
9abae356e0 fix! 2021-02-10 16:54:14 -08:00
Pat Hickey
bc95864202 wasi-tests: add path_exists test
this *should* reproduce the report at
https://github.com/bytecodealliance/wasmtime/issues/2642 but it does
not, so the problem has something to do with invoking via wasmtime cli?
2021-02-10 16:54:14 -08:00
Pat Hickey
7a35763d62 collapse two test flags into dangling_filesystem 2021-02-03 14:54:42 -08:00
Pat Hickey
cd02e5a942 path_rename: make more concessions for windows. this shit sucks but oh well 2021-02-02 15:30:02 -08:00
Pat Hickey
80fce7c1c8 unlink behavior on macos... 2021-02-01 19:22:10 -08:00
Pat Hickey
c77a11bd5c tests: macos-specific behavior 2021-02-01 18:30:58 -08:00
Pat Hickey
bb3e391a27 accept fdread event as valid behavior of stdin poll 2021-02-01 15:26:06 -08:00
Pat Hickey
40e541bfc3 test suite: cap-std-sync test environment does not support fdflags sync 2021-02-01 14:25:42 -08:00
Pat Hickey
5ee093e774 Merge remote-tracking branch 'origin/main' into pch/wasi_common_cap_std 2021-02-01 13:21:25 -08:00
Peter Huene
0502cadc62 Stop allowing bufused > BUF_LEN in fd_readdir program.
This commit removes what appears to be a workaround to the bug being fixed by
the change in #2620.
2021-02-01 11:41:29 -08:00
Pat Hickey
bad169dde3 port https://github.com/bytecodealliance/wasmtime/pull/2620 into rewrite 2021-02-01 11:10:26 -08:00
Pat Hickey
1d057af64d notes 2021-01-28 13:20:52 -08:00
Pat Hickey
201a888d92 dirty fuckin' dangles boys
fuck you shorsey
2021-01-28 13:02:48 -08:00
Pat Hickey
11b8222033 missed a dangling symlink 2021-01-28 12:59:44 -08:00
Pat Hickey
34ad8df169 dangling directories are a windows thing 2021-01-28 12:58:41 -08:00
Pat Hickey
4801ea04a1 cool 2021-01-28 12:36:50 -08:00
Pat Hickey
0cedc17246 another one bites the dust 2021-01-28 12:35:13 -08:00
Pat Hickey
79e8f17486 bum bum bum 2021-01-28 12:30:37 -08:00
Pat Hickey
dae022b17f woo 2021-01-28 12:29:30 -08:00
Pat Hickey
1196e216e9 fix macro by denying trailing slashes. also other stuff 2021-01-28 12:23:48 -08:00
Pat Hickey
20e9169cc7 fd_allocate: put meat of test behind a guard 2021-01-28 11:43:42 -08:00
Pat Hickey
f7403acb6f fd_advise test: set size via fd_filestat_set_size and fd_allocate 2021-01-28 11:42:30 -08:00
Pat Hickey
e758318fee wire env variables through test runner to TESTCONFIG 2021-01-28 11:34:18 -08:00
Pat Hickey
7ffe3c72c5 config is lazy_static to amoritze it 2021-01-28 11:20:02 -08:00
Pat Hickey
6f85abd949 itsp ublished 2021-01-28 09:44:17 -08:00
Pat Hickey
03466d04ce temporarily use my branch of the wasi crate 2021-01-27 19:05:52 -08:00
Pat Hickey
be108c7a93 will this work for platform-specific errnos? WIP 2021-01-27 18:18:12 -08:00