Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit d936a74

Browse files
committed
Spinloop instead of exit by default in test processes
1 parent 67dd0dc commit d936a74

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

lumen_runtime/src/process.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use liblumen_alloc::erts::exception::system::Alloc;
1111
use liblumen_alloc::erts::process::code::stack::frame::{Frame, Placement};
1212
use liblumen_alloc::erts::process::code::Code;
1313
use liblumen_alloc::erts::process::{self, ProcessControlBlock};
14-
#[cfg(test)]
15-
use liblumen_alloc::erts::term::atom_unchecked;
1614
use liblumen_alloc::erts::term::{AsTerm, Atom, Term, TypedTerm};
1715
use liblumen_alloc::erts::ModuleFunctionArity;
1816
use liblumen_alloc::CloneToProcess;
@@ -190,11 +188,19 @@ pub fn test_init() -> Arc<ProcessControlBlock> {
190188
pub fn test(parent_process: &ProcessControlBlock) -> Arc<ProcessControlBlock> {
191189
let heap_size = process::next_heap_size(16_000);
192190
let heap = process::heap(heap_size).unwrap();
193-
let erlang = Atom::try_from_str("erlang").unwrap();
194-
let exit = Atom::try_from_str("exit").unwrap();
195-
196-
let normal = atom_unchecked("normal");
197-
let arguments = parent_process.list_from_slice(&[normal]).unwrap();
191+
let module = test::r#loop::module();
192+
let function = test::r#loop::function();
193+
let arguments = vec![];
194+
let code = test::r#loop::code;
198195

199-
Scheduler::spawn_apply_3(parent_process, erlang, exit, arguments, heap, heap_size).unwrap()
196+
Scheduler::spawn(
197+
parent_process,
198+
module,
199+
function,
200+
arguments,
201+
code,
202+
heap,
203+
heap_size,
204+
)
205+
.unwrap()
200206
}

lumen_runtime/src/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pub mod r#loop;
2+
13
// wasm32 proptest cannot be compiled at the same time as non-wasm32 proptest, so disable tests that
24
// use proptest completely for wasm32
35
//

lumen_runtime/src/test/loop.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::sync::Arc;
2+
3+
use liblumen_alloc::erts::process::code;
4+
use liblumen_alloc::erts::process::ProcessControlBlock;
5+
use liblumen_alloc::erts::term::Atom;
6+
7+
pub fn code(arc_process: &Arc<ProcessControlBlock>) -> code::Result {
8+
arc_process.reduce();
9+
10+
ProcessControlBlock::call_code(arc_process)
11+
}
12+
13+
pub fn function() -> Atom {
14+
Atom::try_from_str("loop").unwrap()
15+
}
16+
17+
pub fn module() -> Atom {
18+
Atom::try_from_str("test").unwrap()
19+
}

0 commit comments

Comments
 (0)