test_big_random_buf()1 fn test_big_random_buf() {
2     let mut buf = Vec::new();
3     buf.resize(1024, 0);
4     unsafe {
5         wasip1::random_get(buf.as_mut_ptr(), 1024).expect("failed to call random_get");
6     }
7     // Chances are pretty good that at least *one* byte will be non-zero in
8     // any meaningful random function producing 1024 u8 values.
9     assert!(buf.iter().any(|x| *x != 0), "random_get returned all zeros");
10 }
11 
main()12 fn main() {
13     // Run the tests.
14     test_big_random_buf()
15 }
16