diff --git a/src/runtime2/tests/mod.rs b/src/runtime2/tests/mod.rs index 6baa362a0c2dd9fc572b89a4c7b005151ed2f6ac..85572c586c717aafef2405f6d35172c9dfe4b791 100644 --- a/src/runtime2/tests/mod.rs +++ b/src/runtime2/tests/mod.rs @@ -3,10 +3,12 @@ use crate::protocol::eval::*; use crate::runtime2::runtime::*; use crate::runtime2::component::{CompCtx, CompPDL}; +mod messaging; mod error_handling; +mod transfer_ports; const LOG_LEVEL: LogLevel = LogLevel::Debug; -const NUM_THREADS: u32 = 4; +const NUM_THREADS: u32 = 1; pub(crate) fn compile_and_create_component(source: &str, routine_name: &str, args: ValueGroup) { let protocol = ProtocolDescription::parse(source.as_bytes()) @@ -20,10 +22,10 @@ pub(crate) fn create_component(rt: &Runtime, module_name: &str, routine_name: &s let prompt = rt.inner.protocol.new_component( module_name.as_bytes(), routine_name.as_bytes(), args ).expect("create prompt"); - let reserved = rt.inner.start_create_pdl_component(); + let reserved = rt.inner.start_create_component(); let ctx = CompCtx::new(&reserved); let component = Box::new(CompPDL::new(prompt, 0)); - let (key, _) = rt.inner.finish_create_pdl_component(reserved, component, ctx, false); + let (key, _) = rt.inner.finish_create_component(reserved, component, ctx, false); rt.inner.enqueue_work(key); } @@ -44,109 +46,6 @@ fn test_component_creation() { } } -#[test] -fn test_component_communication() { - let pd = ProtocolDescription::parse(b" - primitive sender(out o, u32 outside_loops, u32 inside_loops) { - u32 outside_index = 0; - while (outside_index < outside_loops) { - u32 inside_index = 0; - sync while (inside_index < inside_loops) { - put(o, inside_index); - inside_index += 1; - } - outside_index += 1; - } - } - - primitive receiver(in i, u32 outside_loops, u32 inside_loops) { - u32 outside_index = 0; - while (outside_index < outside_loops) { - u32 inside_index = 0; - sync while (inside_index < inside_loops) { - auto val = get(i); - while (val != inside_index) {} // infinite loop if incorrect value is received - inside_index += 1; - } - outside_index += 1; - } - } - - composite constructor() { - channel o_orom -> i_orom; - channel o_mrom -> i_mrom; - channel o_ormm -> i_ormm; - channel o_mrmm -> i_mrmm; - - // one round, one message per round - new sender(o_orom, 1, 1); - new receiver(i_orom, 1, 1); - - // multiple rounds, one message per round - new sender(o_mrom, 5, 1); - new receiver(i_mrom, 5, 1); - - // one round, multiple messages per round - new sender(o_ormm, 1, 5); - new receiver(i_ormm, 1, 5); - - // multiple rounds, multiple messages per round - new sender(o_mrmm, 5, 5); - new receiver(i_mrmm, 5, 5); - }").expect("compilation"); - let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap(); - create_component(&rt, "", "constructor", no_args()); -} - -#[test] -fn test_intermediate_messenger() { - let pd = ProtocolDescription::parse(b" - primitive receiver(in rx, u32 num) { - auto index = 0; - while (index < num) { - sync { auto v = get(rx); } - index += 1; - } - } - - primitive middleman(in rx, out tx, u32 num) { - auto index = 0; - while (index < num) { - sync { put(tx, get(rx)); } - index += 1; - } - } - - primitive sender(out tx, u32 num) { - auto index = 0; - while (index < num) { - sync put(tx, 1337); - index += 1; - } - } - - composite constructor_template() { - auto num = 0; - channel tx_a -> rx_a; - channel tx_b -> rx_b; - new sender(tx_a, 3); - new middleman(rx_a, tx_b, 3); - new receiver(rx_b, 3); - } - - composite constructor() { - new constructor_template(); - new constructor_template(); - new constructor_template(); - new constructor_template(); - new constructor_template(); - new constructor_template(); - } - ").expect("compilation"); - let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap(); - create_component(&rt, "", "constructor", no_args()); -} - #[test] fn test_simple_select() { let pd = ProtocolDescription::parse(b"