diff --git a/Cargo.toml b/Cargo.toml index d6784598..397c3ecc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,7 +87,7 @@ proc-macro2 = { version = "1", default-features = false } proc-macro2-diagnostics = { version = "0.10.1", default-features = false } public-api = { version = "0.44.0", default-features = false } quote = { version = "1", default-features = false } -rand = { version = "0.8", default-features = false } +rand = { version = "0.9", default-features = false } rbpf = { version = "0.3.0", default-features = false } rustdoc-json = { version = "0.9.0", default-features = false } rustup-toolchain = { version = "0.1.5", default-features = false } @@ -105,3 +105,7 @@ xdpilone = { version = "1.0.5", default-features = false } [profile.release.package.integration-ebpf] debug = 2 codegen-units = 1 + +[patch.crates-io] +# TODO: Remove when https://github.com/rust-random/getrandom/commit/b75db5cede302bc9734f5bf2b9048a6e05c7f11e appears in a release. +getrandom = { git = "https://github.com/rust-random/getrandom.git#b75db5cede302bc9734f5bf2b9048a6e05c7f11e" } diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml index 4cdeaa28..430268c6 100644 --- a/test/integration-test/Cargo.toml +++ b/test/integration-test/Cargo.toml @@ -22,7 +22,7 @@ libc = { workspace = true } log = { workspace = true } netns-rs = { workspace = true } object = { workspace = true, features = ["elf", "read_core", "std"] } -rand = { workspace = true, features = ["std", "std_rng"] } +rand = { workspace = true, features = ["thread_rng"] } rbpf = { workspace = true } test-case = { workspace = true } test-log = { workspace = true, features = ["log"] } diff --git a/test/integration-test/src/tests/ring_buf.rs b/test/integration-test/src/tests/ring_buf.rs index 515ed421..52affeba 100644 --- a/test/integration-test/src/tests/ring_buf.rs +++ b/test/integration-test/src/tests/ring_buf.rs @@ -77,8 +77,8 @@ struct WithData(RingBufTest, Vec); impl WithData { fn new(n: usize) -> Self { Self(RingBufTest::new(), { - let mut rng = rand::thread_rng(); - std::iter::repeat_with(|| rng.gen()).take(n).collect() + let mut rng = rand::rng(); + std::iter::repeat_with(|| rng.random()).take(n).collect() }) } } @@ -270,13 +270,17 @@ async fn ring_buf_async_no_drop() { ) = WithData::new(RING_BUF_MAX_ENTRIES * 3); let writer = { - let data = data.to_owned(); + let mut rng = rand::rng(); + let data: Vec<_> = data + .iter() + .copied() + .map(|value| (value, Duration::from_nanos(rng.random_range(0..10)))) + .collect(); tokio::spawn(async move { - for value in data { + for (value, duration) in data { // Sleep a tad so we feel confident that the consumer will keep up // and no messages will be dropped. - let dur = Duration::from_nanos(rand::thread_rng().gen_range(0..10)); - sleep(dur).await; + sleep(duration).await; ring_buf_trigger_ebpf_program(value); } })