1 use rand::{rngs::SmallRng, Rng, SeedableRng};
3 // Having more than 1 test does seem to make a difference
4 // (i.e., this calls ptr::swap which having just one test does not).
15 // A test that won't work on miri (tests disabling tests).
17 #[cfg_attr(miri, ignore)]
18 fn does_not_work_on_miri() {
20 assert!(&x as *const _ as usize % 4 < 4);
23 // We also use this to test some external crates, that we cannot depend on in the compiletest suite.
27 // Test `getrandom` directly (in multiple different versions).
28 let mut data = vec![0; 16];
29 getrandom_1::getrandom(&mut data).unwrap();
30 getrandom_2::getrandom(&mut data).unwrap();
32 // Try seeding with "real" entropy.
33 let mut rng = SmallRng::from_entropy();
34 let _val = rng.gen::<i32>();
35 let _val = rng.gen::<isize>();
36 let _val = rng.gen::<i128>();
38 // Also try per-thread RNG.
39 let mut rng = rand::thread_rng();
40 let _val = rng.gen::<i32>();
41 let _val = rng.gen::<isize>();
42 let _val = rng.gen::<i128>();
47 assert_eq!(env!("CARGO_PKG_NAME"), "cargo-miri-test");
48 env!("CARGO_BIN_EXE_cargo-miri-test"); // Asserts that this exists.
52 #[should_panic(expected = "Explicit panic")]
53 fn do_panic() // In large, friendly letters :)
55 panic!("Explicit panic from test!");
59 #[allow(unconditional_panic)]
60 #[should_panic(expected = "the len is 0 but the index is 42")]
61 fn fail_index_check() {
67 let page_size = page_size::get();
69 // In particular, this checks that it is not 0.
71 page_size.next_power_of_two() == page_size,
72 "page size not a power of two: {}",