forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasi): add support for
wasi:[email protected]
Signed-off-by: Roman Volosatovs <[email protected]>
- Loading branch information
1 parent
a1e2bfc
commit 630e330
Showing
19 changed files
with
865 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,10 @@ make_vendor "wasi/src/p2" " | |
[email protected] | ||
" | ||
|
||
make_vendor "wasi/src/p3" " | ||
random@[email protected] | ||
" | ||
|
||
make_vendor "wasi-http/src/p2" " | ||
[email protected] | ||
[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use test_programs::wasi::random0_3_0 as random; | ||
|
||
fn main() { | ||
let mut bytes = [0_u8; 256]; | ||
getrandom::getrandom(&mut bytes).unwrap(); | ||
|
||
assert!(bytes.iter().any(|x| *x != 0)); | ||
|
||
// Acquired random bytes should be of the expected length. | ||
let array = random::random::get_random_bytes(100); | ||
assert_eq!(array.len(), 100); | ||
|
||
// It shouldn't take 100+ tries to get a nonzero random integer. | ||
for i in 0.. { | ||
if random::random::get_random_u64() == 0 { | ||
continue; | ||
} | ||
assert!(i < 100); | ||
break; | ||
} | ||
|
||
// The `insecure_seed` API should return the same result each time. | ||
let (a1, b1) = random::insecure_seed::insecure_seed(); | ||
let (a2, b2) = random::insecure_seed::insecure_seed(); | ||
assert_eq!(a1, a2); | ||
assert_eq!(b1, b2); | ||
|
||
// Acquired random bytes should be of the expected length. | ||
let array = random::insecure::get_insecure_random_bytes(100); | ||
assert_eq!(array.len(), 100); | ||
|
||
// It shouldn't take 100+ tries to get a nonzero random integer. | ||
for i in 0.. { | ||
if random::insecure::get_insecure_random_u64() == 0 { | ||
continue; | ||
} | ||
assert!(i < 100); | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,12 @@ wit_bindgen::generate!({ | |
include wasi:http/[email protected]; | ||
include wasi:config/[email protected]; | ||
include wasi:keyvalue/[email protected]; | ||
include wasi:random/[email protected]; | ||
} | ||
", | ||
path: [ | ||
"../wasi/src/p3/wit", | ||
"../wasi-http/src/p2/wit", | ||
"../wasi-config/src/p2/wit", | ||
"../wasi-keyvalue/src/p2/wit", | ||
|
@@ -33,7 +36,7 @@ pub mod proxy { | |
with: { | ||
"wasi:http/[email protected]": crate::wasi::http::types, | ||
"wasi:http/[email protected]": crate::wasi::http::outgoing_handler, | ||
"wasi:random/[email protected]": crate::wasi::random::random, | ||
"wasi:random/[email protected]": crate::wasi::random0_2_3::random, | ||
"wasi:io/[email protected]": crate::wasi::io::error, | ||
"wasi:io/[email protected]": crate::wasi::io::poll, | ||
"wasi:io/[email protected]": crate::wasi::io::streams, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ default = [ "preview1"] | |
preview1 = [ | ||
"dep:wiggle", | ||
] | ||
p3 = [] | ||
|
||
[[test]] | ||
name = "process_stdin" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.