Skip to content

Commit

Permalink
Auto merge of rust-lang#2687 - RalfJung:getrandom, r=RalfJung
Browse files Browse the repository at this point in the history
ensure current getrandom works with strict provenance
  • Loading branch information
bors committed Nov 22, 2022
2 parents 435faf0 + c2f872e commit b655795
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 49 deletions.
94 changes: 54 additions & 40 deletions test_dependencies/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test_dependencies/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ edition = "2021"
# all dependencies (and their transitive ones) listed here can be used in `tests/`.
tokio = { version = "1.0", features = ["full"] }
libc = "0.2"
page_size = "0.4.1"
page_size = "0.5"
num_cpus = "1.10.1"

getrandom_1 = { package = "getrandom", version = "0.1" }
getrandom_2 = { package = "getrandom", version = "0.2" }
getrandom = { version = "0.2" }
rand = { version = "0.8", features = ["small_rng"] }

[workspace]
4 changes: 2 additions & 2 deletions tests/fail/crates/tokio_mvp.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: unsupported operation: can't call foreign function: epoll_create1
--> CARGO_REGISTRY/.../epoll.rs:LL:CC
|
LL | syscall!(epoll_create1(flag)).map(|ep| Selector {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function: epoll_create1
LL | let res = syscall!(epoll_create1(libc::EPOLL_CLOEXEC));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function: epoll_create1
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
= note: BACKTRACE:
Expand Down
8 changes: 8 additions & 0 deletions tests/pass-dep/getrandom_1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// mac-os `getrandom_1` does some pointer shenanigans
//@compile-flags: -Zmiri-permissive-provenance

/// Test old version of `getrandom`.
fn main() {
let mut data = vec![0; 16];
getrandom_1::getrandom(&mut data).unwrap();
}
8 changes: 3 additions & 5 deletions tests/pass-dep/random.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// mac-os `getrandom_1` does some pointer shenanigans
//@compile-flags: -Zmiri-permissive-provenance
//@compile-flags: -Zmiri-strict-provenance
use rand::{rngs::SmallRng, Rng, SeedableRng};

fn main() {
// Test `getrandom` directly (in multiple different versions).
// Test `getrandom` directly.
let mut data = vec![0; 16];
getrandom_1::getrandom(&mut data).unwrap();
getrandom_2::getrandom(&mut data).unwrap();
getrandom::getrandom(&mut data).unwrap();

// Try seeding with "real" entropy.
let mut rng = SmallRng::from_entropy();
Expand Down
File renamed without changes.

0 comments on commit b655795

Please sign in to comment.