diff --git a/src/runtime2/tests/mod.rs b/src/runtime2/tests/mod.rs index 85572c586c717aafef2405f6d35172c9dfe4b791..b3988d25db7fc32e3077a29ad6b0d4589e2ade98 100644 --- a/src/runtime2/tests/mod.rs +++ b/src/runtime2/tests/mod.rs @@ -6,6 +6,7 @@ use crate::runtime2::component::{CompCtx, CompPDL}; mod messaging; mod error_handling; mod transfer_ports; +mod internet; const LOG_LEVEL: LogLevel = LogLevel::Debug; const NUM_THREADS: u32 = 1; @@ -13,7 +14,7 @@ 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()) .expect("successful compilation"); - let runtime = Runtime::new(NUM_THREADS, LOG_LEVEL, protocol) + let runtime = Runtime::new(NUM_THREADS, LogLevel::None, protocol) .expect("successful runtime startup"); create_component(&runtime, "", routine_name, args); } @@ -34,7 +35,7 @@ pub(crate) fn no_args() -> ValueGroup { ValueGroup::new_stack(Vec::new()) } #[test] fn test_component_creation() { let pd = ProtocolDescription::parse(b" - primitive nothing_at_all() { + comp nothing_at_all() { s32 a = 5; auto b = 5 + a; } @@ -54,7 +55,7 @@ fn test_simple_select() { return (); } - primitive receiver(in in_a, in in_b, u32 num_sends) { + comp receiver(in in_a, in in_b, u32 num_sends) { auto num_from_a = 0; auto num_from_b = 0; while (num_from_a + num_from_b < 2 * num_sends) { @@ -73,7 +74,7 @@ fn test_simple_select() { } } - primitive sender(out tx, u32 num_sends) { + comp sender(out tx, u32 num_sends) { auto index = 0; while (index < num_sends) { sync { @@ -83,7 +84,7 @@ fn test_simple_select() { } } - composite constructor() { + comp constructor() { auto num_sends = 1; channel tx_a -> rx_a; channel tx_b -> rx_b; @@ -99,7 +100,7 @@ fn test_simple_select() { #[test] fn test_unguarded_select() { let pd = ProtocolDescription::parse(b" - primitive constructor_outside_select() { + comp constructor_outside_select() { u32 index = 0; while (index < 5) { sync select { auto v = () -> print(\"hello\"); } @@ -107,7 +108,7 @@ fn test_unguarded_select() { } } - primitive constructor_inside_select() { + comp constructor_inside_select() { u32 index = 0; while (index < 5) { sync select { auto v = () -> index += 1; } @@ -122,7 +123,7 @@ fn test_unguarded_select() { #[test] fn test_empty_select() { let pd = ProtocolDescription::parse(b" - primitive constructor() { + comp constructor() { u32 index = 0; while (index < 5) { sync select {} @@ -139,7 +140,7 @@ fn test_random_u32_temporary_thingo() { let pd = ProtocolDescription::parse(b" import std.random::random_u32; - primitive random_taker(in generator, u32 num_values) { + comp random_taker(in generator, u32 num_values) { auto i = 0; while (i < num_values) { sync { @@ -149,7 +150,7 @@ fn test_random_u32_temporary_thingo() { } } - composite constructor() { + comp constructor() { channel tx -> rx; auto num_values = 25; new random_u32(tx, 1, 100, num_values); @@ -165,17 +166,17 @@ fn test_tcp_socket_http_request() { let _pd = ProtocolDescription::parse(b" import std.internet::*; - primitive requester(out cmd_tx, in data_rx) { + comp requester(out cmd_tx, in data_rx) { print(\"*** TCPSocket: Sending request\"); sync { - put(cmd_tx, Cmd::Send(b\"GET / HTTP/1.1\\r\\n\\r\\n\")); + put(cmd_tx, ClientCmd::Send(b\"GET / HTTP/1.1\\r\\n\\r\\n\")); } print(\"*** TCPSocket: Receiving response\"); auto buffer = {}; auto done_receiving = false; sync while (!done_receiving) { - put(cmd_tx, Cmd::Receive); + put(cmd_tx, ClientCmd::Receive); auto data = get(data_rx); buffer @= data; @@ -200,7 +201,7 @@ fn test_tcp_socket_http_request() { c5 == cast('m') && c6 == cast('l') && c7 == cast('>') ) { print(\"*** TCPSocket: Detected \"); - put(cmd_tx, Cmd::Finish); + put(cmd_tx, ClientCmd::Finish); done_receiving = true; } } @@ -210,11 +211,11 @@ fn test_tcp_socket_http_request() { print(\"*** TCPSocket: Requesting shutdown\"); sync { - put(cmd_tx, Cmd::Shutdown); + put(cmd_tx, ClientCmd::Shutdown); } } - composite main() { + comp main() { channel cmd_tx -> cmd_rx; channel data_tx -> data_rx; new tcp_client({142, 250, 179, 163}, 80, cmd_rx, data_tx); // port 80 of google @@ -223,7 +224,7 @@ fn test_tcp_socket_http_request() { ").expect("compilation"); // This test is disabled because it performs a HTTP request to google. - // let rt = Runtime::new(1, true, pd).unwrap(); + // let rt = Runtime::new(1, LOG_LEVEL, _pd).unwrap(); // create_component(&rt, "", "main", no_args()); } @@ -236,7 +237,7 @@ fn test_sending_receiving_union() { Shutdown, } - primitive database(in rx, out tx) { + comp database(in rx, out tx) { auto stored = {}; auto done = false; while (!done) { @@ -256,7 +257,7 @@ fn test_sending_receiving_union() { } } - primitive client(out tx, in rx, u32 num_rounds) { + comp client(out tx, in rx, u32 num_rounds) { auto round = 0; while (round < num_rounds) { auto set_value = b\"hello there\"; @@ -278,7 +279,7 @@ fn test_sending_receiving_union() { sync put(tx, Cmd::Shutdown); } - composite main() { + comp main() { auto num_rounds = 5; channel cmd_tx -> cmd_rx; channel data_tx -> data_rx;