Skip to content

Commit 9a90871

Browse files
sarskojorajeevbkragl
committed
Add shuttle-tokio
Co-authored-by: Rajeev Joshi <jorajeev@amazon.com> Co-authored-by: Bernhard Kragl <kraglb@amazon.com>
1 parent 251084a commit 9a90871

File tree

127 files changed

+18978
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+18978
-1
lines changed

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ members = [
33
"shuttle",
44
"wrappers/shuttle_rand_0.8",
55
"wrappers/shuttle_sync",
6+
"wrappers/tokio/impls/tokio",
7+
"wrappers/tokio/impls/tokio-macros",
8+
"wrappers/tokio/impls/tokio-stream",
9+
"wrappers/tokio/impls/tokio-test",
10+
"wrappers/tokio/impls/tokio-util",
11+
"wrappers/tokio/wrappers/shuttle-tokio",
12+
"wrappers/tokio/wrappers/shuttle-tokio-stream",
613
]
714

8-
resolver = "2"
15+
resolver = "2"

wrappers/tokio/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ShuttleTokio
2+
3+
This folder contains the implementation and wrapper for ShuttleTokio, which provides [tokio](https://crates.io/crates/tokio) support to Shuttle.
4+
5+
## How to use
6+
7+
To use it, do something akin to the following in your Cargo.toml:
8+
9+
```
10+
[features]
11+
shuttle = [
12+
"tokio/shuttle",
13+
]
14+
15+
[dependencies]
16+
tokio = { package = "shuttle-tokio", version = "VERSION_NUMBER" }
17+
```
18+
19+
The code will then behave as before when the `shuttle` feature flag is not provided, and will run with Shuttle-compatible primitives when the `shuttle` feature flag is provided.
20+
21+
## Limitations
22+
23+
The development of ShuttleTokio has come as a consequence of teams at Amazon needing support for model checking code using tokio. What has driven development is the functionality needed by these teams, meaning there are parts of tokio which have not been implemented or which have not been modeled faithfully. This is something to keep in mind if you want to use ShuttleTokio, and there is some likelihood that there will be functionality that will need to be added. We are happy to review PRs if there is functionality you'd like to add to ShuttleTokio.
24+
25+
A non-exhaustive look of current limitations:
26+
27+
- `fs`, `net`, `io`: All of these are currently simply forwarded to tokio in order to make code which uses this functionality compile, though it will not work if one actually tries to use it under Shuttle. This will probably remain the case for `fs` and `io`, though there is a case to be made for adding functionality from `net`. We have thus far done network simulation by building atop of `sync::mpsc`, but it would be nice to have TCP/UDP support out of the box.
28+
- tokio `Runtime` modelling. Our modelling of tokio runtimes is not faithful, and this will be a gap for applications which utilize multiple runtimes or which have some particular runtime setup. **When running under ShuttleTokio, a task is modelled as a thread**, and we do no modeling of task to worker thread mapping (aka it's as if every task has its own worker thread).
29+
- `tokio::test` macro parameters: All of these are allowed to make things compile, but do not do anything when run under Shuttle.
30+
- time modelling (aka `start_paused`). ShuttleTokio does not do anything with regards to modelling of time, apart from providing the primitives, and a very simple built in time model. The plan is to merge https://github.com/awslabs/shuttle/pull/217 and then have ShuttleTokio provide better time modelling via the underlying Shuttle functionality. This also means that the "explicit time management" offered in tokio via `time::advance` will most likely never be the preferred solution for time modelling with ShuttleTokio.
31+
- TODO: ShuttleTokio needs to be updated to have better out of the box support for time modelling once [#217](https://github.com/awslabs/shuttle/pull/217) is merged.
32+
- `sync::broadcast`. In general `sync` is pretty well supported, but there has yet to be anyone needing `broadcast`, so it has remained unimplemented.
33+
- `RuntimeMetrics`: All of these functions return 0. It would be nice to return correct information. Shuttle should be updated to accommodate.
34+
- Cooperative scheduling. There are some stubs that exist in order to make code which uses it compile, but in general cooperative scheduling is poorly supported, and any usage of it pretends that it doesn't exist.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "shuttle-tokio-macros-impl"
3+
version = "0.1.0" # Forked from "2.2.0"
4+
edition = "2021"
5+
6+
[lib]
7+
proc-macro = true
8+
9+
[features]
10+
11+
[dependencies]
12+
proc-macro2 = "1.0.60"
13+
quote = "1"
14+
syn = { version = "2.0", features = ["full"] }
15+
shuttle = { path = "../../../../shuttle" }
16+
proc-macro-crate = "3.1.0"
17+
18+
[dev-dependencies]
19+
shuttle-tokio = { package = "shuttle-tokio-impl", path = "../tokio", version = "*" }
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Copyright (c) 2023 Tokio Contributors
2+
3+
Permission is hereby granted, free of charge, to any
4+
person obtaining a copy of this software and associated
5+
documentation files (the "Software"), to deal in the
6+
Software without restriction, including without
7+
limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software
10+
is furnished to do so, subject to the following
11+
conditions:
12+
13+
The above copyright notice and this permission notice
14+
shall be included in all copies or substantial portions
15+
of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
DEALINGS IN THE SOFTWARE.
26+
27+
The MIT License (MIT)
28+
29+
Copyright (c) 2019 Yoshua Wuyts
30+
31+
Permission is hereby granted, free of charge, to any person obtaining a copy
32+
of this software and associated documentation files (the "Software"), to deal
33+
in the Software without restriction, including without limitation the rights
34+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35+
copies of the Software, and to permit persons to whom the Software is
36+
furnished to do so, subject to the following conditions:
37+
38+
The above copyright notice and this permission notice shall be included in all
39+
copies or substantial portions of the Software.
40+
41+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47+
SOFTWARE.

0 commit comments

Comments
 (0)