-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0004-std-not-for-upstreaming-customize-tests-for-Xous.patch
140 lines (126 loc) · 5.47 KB
/
0004-std-not-for-upstreaming-customize-tests-for-Xous.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
From 84acc1fc34bcbf9b791c820d92075c5b72c5c655 Mon Sep 17 00:00:00 2001
From: Sean Cross <[email protected]>
Date: Sun, 24 Dec 2023 15:15:01 +0800
Subject: [PATCH 4/4] std: (not for upstreaming) customize tests for Xous
Signed-off-by: Sean Cross <[email protected]>
---
library/std/src/collections/hash/map/tests.rs | 4 ++--
library/std/src/io/tests.rs | 1 +
library/std/src/sync/mpsc/sync_tests.rs | 12 ++++++------
library/std/src/sync/mpsc/tests.rs | 4 ++--
library/std/src/time/tests.rs | 2 +-
5 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/library/std/src/collections/hash/map/tests.rs b/library/std/src/collections/hash/map/tests.rs
index a275488a556..de39d521d36 100644
--- a/library/std/src/collections/hash/map/tests.rs
+++ b/library/std/src/collections/hash/map/tests.rs
@@ -270,11 +270,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) { 66 } else { 1001 };
+ let count = if cfg!(miri) || cfg!(target_os = "xous") { 66 } else { 1001 };
for i in 1..count {
assert!(m.insert(i, i).is_none());
diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs
index 226cc6011bc..42d015fd13f 100644
--- a/library/std/src/io/tests.rs
+++ b/library/std/src/io/tests.rs
@@ -358,6 +358,7 @@ fn chain_zero_length_read_is_not_eof() {
}
#[bench]
+#[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(|| {
diff --git a/library/std/src/sync/mpsc/sync_tests.rs b/library/std/src/sync/mpsc/sync_tests.rs
index 49b65c8efe6..650cb310587 100644
--- a/library/std/src/sync/mpsc/sync_tests.rs
+++ b/library/std/src/sync/mpsc/sync_tests.rs
@@ -120,7 +120,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 {
@@ -134,7 +134,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 || {
@@ -160,7 +160,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);
@@ -200,7 +200,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);
@@ -447,7 +447,7 @@ fn recv(rx: Receiver<Box<i32>>, i: i32) {
#[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 {
@@ -461,7 +461,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 || {
diff --git a/library/std/src/sync/mpsc/tests.rs b/library/std/src/sync/mpsc/tests.rs
index 13892fa0d18..40cb5cb060d 100644
--- a/library/std/src/sync/mpsc/tests.rs
+++ b/library/std/src/sync/mpsc/tests.rs
@@ -465,7 +465,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();
@@ -537,7 +537,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 || {
diff --git a/library/std/src/time/tests.rs b/library/std/src/time/tests.rs
index e88f2d5e806..ae9b48e4b7e 100644
--- a/library/std/src/time/tests.rs
+++ b/library/std/src/time/tests.rs
@@ -34,7 +34,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);
--
2.47.0