A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
p3_big_random_buf test (#12817)
Ralph Squillace2a08713aed72
diff --git a/crates/test-programs/src/bin/p3_big_random_buf.rs b/crates/test-programs/src/bin/p3_big_random_buf.rsnew file mode 100644index 0000000000..e59fa9247c--- /dev/null+++ b/crates/test-programs/src/bin/p3_big_random_buf.rs@@ -0,0 +1,23 @@+use test_programs::p3::wasi::random;++struct Component;++test_programs::p3::export!(Component);++impl test_programs::p3::exports::wasi::cli::run::Guest for Component {+ async fn run() -> Result<(), ()> {+ test_big_random_buf().await;+ Ok(())+ }+}++fn main() {+ unreachable!()+}++async fn test_big_random_buf() {+ let buf = random::random::get_random_bytes(1024);+ // Chances are pretty good that at least *one* byte will be non-zero in+ // any meaningful random function producing 1024 u8 values.+ assert!(buf.iter().any(|x| *x != 0), "random_get returned all zeros");+}diff --git a/crates/wasi/tests/all/p3/mod.rs b/crates/wasi/tests/all/p3/mod.rsindex 3d6436c9d2..10998cb1c6 100644--- a/crates/wasi/tests/all/p3/mod.rs+++ b/crates/wasi/tests/all/p3/mod.rs@@ -45,6 +45,11 @@ async fn run_allow_blocking_current_thread(foreach_p3!(assert_test_exists);+#[test_log::test(tokio::test(flavor = "multi_thread"))]+async fn p3_big_random_buf() -> wasmtime::Result<()> {+ run(P3_BIG_RANDOM_BUF_COMPONENT).await+}+#[test_log::test(tokio::test(flavor = "multi_thread"))]async fn p3_cli() -> wasmtime::Result<()> {run(P3_CLI_COMPONENT).await