From 00b382d1a5854ccefad7378968b1f6df66bf2da9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 22 Jul 2022 20:53:20 -0400 Subject: [PATCH 1/2] add num_cpus crate test --- test_dependencies/Cargo.lock | 1 + test_dependencies/Cargo.toml | 1 + tests/pass/crates/num_cpus.rs | 5 +++++ tests/pass/crates/random.rs | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/pass/crates/num_cpus.rs diff --git a/test_dependencies/Cargo.lock b/test_dependencies/Cargo.lock index a492deba4c5..d4b32e2c29a 100644 --- a/test_dependencies/Cargo.lock +++ b/test_dependencies/Cargo.lock @@ -107,6 +107,7 @@ dependencies = [ "getrandom 0.1.16", "getrandom 0.2.7", "libc", + "num_cpus", "page_size", "rand", "tokio", diff --git a/test_dependencies/Cargo.toml b/test_dependencies/Cargo.toml index 0bf43aefebf..58f731f91d0 100644 --- a/test_dependencies/Cargo.toml +++ b/test_dependencies/Cargo.toml @@ -12,6 +12,7 @@ edition = "2021" tokio = { version = "1.0", features = ["full"] } libc = "0.2" page_size = "0.4.1" +num_cpus = "1.10.1" getrandom_1 = { package = "getrandom", version = "0.1" } getrandom_2 = { package = "getrandom", version = "0.2" } diff --git a/tests/pass/crates/num_cpus.rs b/tests/pass/crates/num_cpus.rs new file mode 100644 index 00000000000..84339feb11e --- /dev/null +++ b/tests/pass/crates/num_cpus.rs @@ -0,0 +1,5 @@ +//@compile-flags: -Zmiri-disable-isolation + +fn main() { + assert_eq!(num_cpus::get(), 1); +} diff --git a/tests/pass/crates/random.rs b/tests/pass/crates/random.rs index 808d1006d4f..5eccf3b0ea1 100644 --- a/tests/pass/crates/random.rs +++ b/tests/pass/crates/random.rs @@ -1,6 +1,6 @@ -use rand::{rngs::SmallRng, Rng, SeedableRng}; // mac-os `getrandom_1` does some pointer shenanigans //@compile-flags: -Zmiri-permissive-provenance +use rand::{rngs::SmallRng, Rng, SeedableRng}; fn main() { // Test `getrandom` directly (in multiple different versions). From 34922be8013235f37de66cf79573ed2bd2678d85 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 22 Jul 2022 20:53:31 -0400 Subject: [PATCH 2/2] remove num_cpus test from test-cargo-miri --- test-cargo-miri/Cargo.lock | 27 +-------------------------- test-cargo-miri/subcrate/Cargo.toml | 2 +- test-cargo-miri/subcrate/test.rs | 6 ++++-- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/test-cargo-miri/Cargo.lock b/test-cargo-miri/Cargo.lock index 3f61fb3d540..38bfb2ac620 100644 --- a/test-cargo-miri/Cargo.lock +++ b/test-cargo-miri/Cargo.lock @@ -48,15 +48,6 @@ dependencies = [ name = "exported_symbol_dep" version = "0.1.0" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "issue_1567" version = "0.1.0" @@ -83,22 +74,6 @@ version = "0.1.0" name = "issue_rust_86261" version = "0.1.0" -[[package]] -name = "libc" -version = "0.2.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" - -[[package]] -name = "num_cpus" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "proc-macro2" version = "1.0.40" @@ -132,7 +107,7 @@ dependencies = [ name = "subcrate" version = "0.1.0" dependencies = [ - "num_cpus", + "byteorder 1.4.3", ] [[package]] diff --git a/test-cargo-miri/subcrate/Cargo.toml b/test-cargo-miri/subcrate/Cargo.toml index ea2936d52a0..06b1ce1cba4 100644 --- a/test-cargo-miri/subcrate/Cargo.toml +++ b/test-cargo-miri/subcrate/Cargo.toml @@ -18,4 +18,4 @@ path = "test.rs" harness = false [dev-dependencies] -num_cpus = "1.10.1" +byteorder = "1.0" diff --git a/test-cargo-miri/subcrate/test.rs b/test-cargo-miri/subcrate/test.rs index fdab9402813..77e3c2878ca 100644 --- a/test-cargo-miri/subcrate/test.rs +++ b/test-cargo-miri/subcrate/test.rs @@ -1,5 +1,7 @@ use std::env; +use byteorder::{ByteOrder, LittleEndian}; + fn main() { println!("subcrate testing"); @@ -11,6 +13,6 @@ fn main() { let crate_dir = crate_dir.to_string_lossy().replace("\\", "/"); assert_eq!(env_dir, crate_dir); - // Make sure we can call `num_cpus`. - num_cpus::get(); + // Make sure we can call dev-dependencies. + let _n = ::read_u32(&[1, 2, 3, 4]); }