Skip to content

Commit 2b9f32e

Browse files
committed
Fix testing of the standard library with Emscripten
This does need EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" avoid several OOMs.
1 parent 1b48955 commit 2b9f32e

File tree

8 files changed

+30
-3
lines changed

8 files changed

+30
-3
lines changed

alloc/benches/btree/map.rs

+1
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ pub fn iter_10k(b: &mut Bencher) {
353353
}
354354

355355
#[bench]
356+
#[cfg_attr(target_os = "emscripten", ignore)] // hits an OOM
356357
pub fn iter_1m(b: &mut Bencher) {
357358
bench_iter(b, 1_000, 1_000_000);
358359
}

alloc/benches/slice.rs

+11
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,25 @@ rotate!(rotate_medium_half, gen_random, 9158, 9158 / 2);
366366
rotate!(rotate_medium_half_plus_one, gen_random, 9158, 9158 / 2 + 1);
367367

368368
// Intended to use more RAM than the machine has cache
369+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
369370
rotate!(rotate_huge_by1, gen_random, 5 * 1024 * 1024, 1);
371+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
370372
rotate!(rotate_huge_by9199_u64, gen_random, 5 * 1024 * 1024, 9199);
373+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
371374
rotate!(rotate_huge_by9199_bytes, gen_random_bytes, 5 * 1024 * 1024, 9199);
375+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
372376
rotate!(rotate_huge_by9199_strings, gen_strings, 5 * 1024 * 1024, 9199);
377+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
373378
rotate!(rotate_huge_by9199_big, gen_big_random, 5 * 1024 * 1024, 9199);
379+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
374380
rotate!(rotate_huge_by1234577_u64, gen_random, 5 * 1024 * 1024, 1234577);
381+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
375382
rotate!(rotate_huge_by1234577_bytes, gen_random_bytes, 5 * 1024 * 1024, 1234577);
383+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
376384
rotate!(rotate_huge_by1234577_strings, gen_strings, 5 * 1024 * 1024, 1234577);
385+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
377386
rotate!(rotate_huge_by1234577_big, gen_big_random, 5 * 1024 * 1024, 1234577);
387+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
378388
rotate!(rotate_huge_half, gen_random, 5 * 1024 * 1024, 5 * 1024 * 1024 / 2);
389+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
379390
rotate!(rotate_huge_half_plus_one, gen_random, 5 * 1024 * 1024, 5 * 1024 * 1024 / 2 + 1);

alloc/benches/vec.rs

+5
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,11 @@ fn bench_in_place_collect_droppable(b: &mut Bencher) {
547547
})
548548
}
549549

550+
// node.js gives out of memory error to use with length 1_100_000
551+
#[cfg(target_os = "emscripten")]
552+
const LEN: usize = 4096;
553+
554+
#[cfg(not(target_os = "emscripten"))]
550555
const LEN: usize = 16384;
551556

552557
#[bench]

alloc/tests/sort/tests.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ use crate::sort::{Sort, known_good_stable_sort, patterns};
1111
#[cfg(miri)]
1212
const TEST_LENGTHS: &[usize] = &[2, 3, 4, 7, 10, 15, 20, 24, 33, 50, 100, 171, 300];
1313

14-
#[cfg(not(miri))]
14+
// node.js gives out of memory error to use with length 1_100_000
15+
#[cfg(all(not(miri), target_os = "emscripten"))]
16+
const TEST_LENGTHS: &[usize] = &[
17+
2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 20, 24, 30, 32, 33, 35, 50, 100, 200, 500, 1_000,
18+
2_048, 5_000, 10_000, 100_000,
19+
];
20+
21+
#[cfg(all(not(miri), not(target_os = "emscripten")))]
1522
const TEST_LENGTHS: &[usize] = &[
1623
2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 20, 24, 30, 32, 33, 35, 50, 100, 200, 500, 1_000,
1724
2_048, 5_000, 10_000, 100_000, 1_100_000,

alloc/tests/sync.rs

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ fn try_unwrap() {
128128
}
129129

130130
#[test]
131+
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
131132
fn into_inner() {
132133
for _ in 0..100
133134
// ^ Increase chances of hitting potential race conditions

std/src/io/copy/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ mod io_benches {
126126
use crate::io::prelude::*;
127127

128128
#[bench]
129+
#[cfg_attr(target_os = "emscripten", ignore)] // no /dev
129130
fn bench_copy_buf_reader(b: &mut Bencher) {
130131
let mut file_in = File::open("/dev/zero").expect("opening /dev/zero failed");
131132
// use dyn to avoid specializations unrelated to readbuf

std/tests/pipe_subprocess.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(anonymous_pipe)]
22

33
fn main() {
4-
#[cfg(all(not(miri), any(unix, windows)))]
4+
#[cfg(all(not(miri), any(unix, windows), not(target_os = "emscripten")))]
55
{
66
use std::io::{Read, pipe};
77
use std::{env, process};

std/tests/process_spawning.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use std::{env, fs, process, str};
55
mod common;
66

77
#[test]
8-
#[cfg_attr(any(miri, target_os = "wasi"), ignore)] // Process spawning not supported by Miri and wasi
8+
// Process spawning not supported by Miri, Emscripten and wasi
9+
#[cfg_attr(any(miri, target_os = "emscripten", target_os = "wasi"), ignore)]
910
fn issue_15149() {
1011
// If we're the parent, copy our own binary to a new directory.
1112
let my_path = env::current_exe().unwrap();

0 commit comments

Comments
 (0)