Skip to content

Commit

Permalink
std: (not for upstreaming) customize tests for Xous
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Cross <sean@xobs.io>
  • Loading branch information
xobs committed Dec 24, 2023
1 parent 3fced2a commit fff1f15
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions library/std/src/collections/hash/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ fn test_lots_of_insertions() {

// Try this a few times to make sure we never screw up the hashmap's
// internal state.
let loops = if cfg!(miri) { 2 } else { 10 };
let loops = if cfg!(miri) || cfg!(target_os = "xous") { 2 } else { 10 };
for _ in 0..loops {
assert!(m.is_empty());

let count = if cfg!(miri) { 101 } else { 1001 };
let count = if cfg!(miri) || cfg!(target_os = "xous") { 101 } else { 1001 };

for i in 1..count {
assert!(m.insert(i, i).is_none());
Expand Down
1 change: 1 addition & 0 deletions library/std/src/io/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ fn chain_zero_length_read_is_not_eof() {

#[bench]
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg_attr(target_os = "xous", ignore)]
#[cfg_attr(miri, ignore)] // Miri isn't fast...
fn bench_read_to_end(b: &mut test::Bencher) {
b.iter(|| {
Expand Down
12 changes: 6 additions & 6 deletions library/std/src/sync/mpsc/sync_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn chan_gone_concurrent() {

#[test]
fn stress() {
let count = if cfg!(miri) { 100 } else { 10000 };
let count = if cfg!(miri) || cfg!(target_os = "xous") { 100 } else { 10000 };
let (tx, rx) = sync_channel::<i32>(0);
thread::spawn(move || {
for _ in 0..count {
Expand All @@ -136,7 +136,7 @@ fn stress() {

#[test]
fn stress_recv_timeout_two_threads() {
let count = if cfg!(miri) { 100 } else { 10000 };
let count = if cfg!(miri) || cfg!(target_os = "xous") { 100 } else { 10000 };
let (tx, rx) = sync_channel::<i32>(0);

thread::spawn(move || {
Expand All @@ -162,7 +162,7 @@ fn stress_recv_timeout_two_threads() {

#[test]
fn stress_recv_timeout_shared() {
const AMT: u32 = if cfg!(miri) { 100 } else { 1000 };
const AMT: u32 = if cfg!(miri) || cfg!(target_os = "xous") { 100 } else { 1000 };
const NTHREADS: u32 = 8;
let (tx, rx) = sync_channel::<i32>(0);
let (dtx, drx) = sync_channel::<()>(0);
Expand Down Expand Up @@ -202,7 +202,7 @@ fn stress_recv_timeout_shared() {

#[test]
fn stress_shared() {
const AMT: u32 = if cfg!(miri) { 100 } else { 1000 };
const AMT: u32 = if cfg!(miri) || cfg!(target_os = "xous") { 100 } else { 1000 };
const NTHREADS: u32 = 8;
let (tx, rx) = sync_channel::<i32>(0);
let (dtx, drx) = sync_channel::<()>(0);
Expand Down Expand Up @@ -449,7 +449,7 @@ fn stream_send_recv_stress() {

#[test]
fn recv_a_lot() {
let count = if cfg!(miri) { 1000 } else { 10000 };
let count = if cfg!(miri) || cfg!(target_os = "xous") { 1000 } else { 10000 };
// Regression test that we don't run out of stack in scheduler context
let (tx, rx) = sync_channel(count);
for _ in 0..count {
Expand All @@ -463,7 +463,7 @@ fn recv_a_lot() {
#[test]
fn shared_chan_stress() {
let (tx, rx) = sync_channel(0);
let total = stress_factor() + 100;
let total = stress_factor() + if cfg!(target_os = "xous") { 20 } else { 100 };
for _ in 0..total {
let tx = tx.clone();
thread::spawn(move || {
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sync/mpsc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ fn recv_timeout_upgrade() {
#[test]
fn stress_recv_timeout_shared() {
let (tx, rx) = channel();
let stress = stress_factor() + 100;
let stress = stress_factor() + if cfg!(target_os = "xous") { 10 } else { 100 };

for i in 0..stress {
let tx = tx.clone();
Expand Down Expand Up @@ -539,7 +539,7 @@ fn shared_recv_timeout() {
#[test]
fn shared_chan_stress() {
let (tx, rx) = channel();
let total = stress_factor() + 100;
let total = stress_factor() + if cfg!(target_os = "xous") { 20 } else { 100 };
for _ in 0..total {
let tx = tx.clone();
thread::spawn(move || {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/time/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn instant_monotonic_concurrent() -> crate::thread::Result<()> {
.map(|_| {
crate::thread::spawn(|| {
let mut old = Instant::now();
let count = if cfg!(miri) { 1_000 } else { 5_000_000 };
let count = if cfg!(miri) || cfg!(target_os = "xous") { 1_000 } else { 5_000_000 };
for _ in 0..count {
let new = Instant::now();
assert!(new >= old);
Expand Down

0 comments on commit fff1f15

Please sign in to comment.