From 5e5cd299229d58373aeef8d16df7a6a79f80fa48 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 15:05:33 +0000 Subject: [PATCH] build(deps): update rand requirement Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. Updates `rand` to 0.8.5 - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.8.0...0.8.5) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production dependency-group: cargo-crates ... Signed-off-by: dependabot[bot] --- Cargo.toml | 6 +++++- test/integration-test/Cargo.toml | 2 +- test/integration-test/src/tests/ring_buf.rs | 16 ++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) 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); } })