-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0003-std-not-for-upstreaming-customize-tests-for-Xous.patch
140 lines (126 loc) · 5.42 KB
/
0003-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 0dc145e29fd85e505e00aa2440dc2020aaaf3032 Mon Sep 17 00:00:00 2001
From: Sean Cross <[email protected]>
Date: Tue, 11 Mar 2025 23:08:29 +0800
Subject: [PATCH 3/3] 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/tests/sync/mpsc.rs | 4 ++--
library/std/tests/sync/mpsc_sync.rs | 12 ++++++------
library/std/tests/time.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 f64f034cce7..248e52108e8 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/tests/sync/mpsc.rs b/library/std/tests/sync/mpsc.rs
index 1d8edfde44b..377256df70e 100644
--- a/library/std/tests/sync/mpsc.rs
+++ b/library/std/tests/sync/mpsc.rs
@@ -466,7 +466,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();
@@ -538,7 +538,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/tests/sync/mpsc_sync.rs b/library/std/tests/sync/mpsc_sync.rs
index a7f326d201b..fd64e60a22b 100644
--- a/library/std/tests/sync/mpsc_sync.rs
+++ b/library/std/tests/sync/mpsc_sync.rs
@@ -121,7 +121,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 {
@@ -135,7 +135,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 || {
@@ -161,7 +161,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);
@@ -201,7 +201,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);
@@ -448,7 +448,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 {
@@ -462,7 +462,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/tests/time.rs b/library/std/tests/time.rs
index 40709eae37c..cca14bd946e 100644
--- a/library/std/tests/time.rs
+++ b/library/std/tests/time.rs
@@ -32,7 +32,7 @@ fn instant_monotonic_concurrent() -> std::thread::Result<()> {
.map(|_| {
std::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.34.1