diff --git a/src/runtime/tests.rs b/src/runtime/tests.rs index 660e6da4fef7a9dd59b1ff8b040ff9bd66e741d9..e758c82a34f270a78d78d1574f131a6c9a574246 100644 --- a/src/runtime/tests.rs +++ b/src/runtime/tests.rs @@ -1059,65 +1059,65 @@ fn sequencer3_prim() { } } -// #[test] -// fn sequencer3_comp() { -// let test_log_path = Path::new("./logs/sequencer3_comp"); -// let pdl = b" -// primitive fifo1_init(msg m, in a, out b) { -// while(true) synchronous { -// if(m != null && fires(b)) { -// put(b, m); -// m = null; -// } else if (m == null && fires(a)) { -// m = get(a); -// } -// } -// } -// composite fifo1_full(in a, out b) { -// new fifo1_init(create(0), a, b); -// } -// composite fifo1(in a, out b) { -// new fifo1_init(null, a, b); -// } -// composite seq3composite(out a, out b, out c) { -// channel d -> e; -// channel f -> g; -// channel h -> i; -// channel j -> k; -// channel l -> m; -// channel n -> o; +#[test] +fn sequencer3_comp() { + let test_log_path = Path::new("./logs/sequencer3_comp"); + let pdl = b" + primitive fifo1_init(msg m, in a, out b) { + while(true) synchronous { + if(m != null && fires(b)) { + put(b, m); + m = null; + } else if (m == null && fires(a)) { + m = get(a); + } + } + } + composite fifo1_full(in a, out b) { + new fifo1_init(create(0), a, b); + } + composite fifo1(in a, out b) { + new fifo1_init(null, a, b); + } + composite seq3composite(out a, out b, out c) { + channel d -> e; + channel f -> g; + channel h -> i; + channel j -> k; + channel l -> m; + channel n -> o; -// new fifo1_full(o, d); -// new replicator2(e, f, a); -// new fifo1(g, h); -// new replicator2(i, j, b); -// new fifo1(k, l); -// new replicator2(m, n, c); -// } -// "; -// let pd = reowolf::ProtocolDescription::parse(pdl).unwrap(); -// let mut c = file_logged_configured_connector(0, test_log_path, Arc::new(pd)); + new fifo1_full(o, d); + new replicator2(e, f, a); + new fifo1(g, h); + new replicator2(i, j, b); + new fifo1(k, l); + new replicator2(m, n, c); + } + "; + let pd = reowolf::ProtocolDescription::parse(pdl).unwrap(); + let mut c = file_logged_configured_connector(0, test_log_path, Arc::new(pd)); -// // setup a session between (a) native, and (b) composite sequencer3, connected by 3 ports. -// let [p0, g0] = c.new_port_pair(); -// let [p1, g1] = c.new_port_pair(); -// let [p2, g2] = c.new_port_pair(); -// c.add_component(b"seq3composite", &[p0, p1, p2]).unwrap(); -// c.connect(None).unwrap(); + // setup a session between (a) native, and (b) composite sequencer3, connected by 3 ports. + let [p0, g0] = c.new_port_pair(); + let [p1, g1] = c.new_port_pair(); + let [p2, g2] = c.new_port_pair(); + c.add_component(b"seq3composite", &[p0, p1, p2]).unwrap(); + c.connect(None).unwrap(); -// let mut which_of_three = move || { -// // setup three sync batches. sync. return which succeeded -// c.get(g0).unwrap(); -// c.next_batch().unwrap(); -// c.get(g1).unwrap(); -// c.next_batch().unwrap(); -// c.get(g2).unwrap(); -// c.sync(None).unwrap() -// }; + let mut which_of_three = move || { + // setup three sync batches. sync. return which succeeded + c.get(g0).unwrap(); + c.next_batch().unwrap(); + c.get(g1).unwrap(); + c.next_batch().unwrap(); + c.get(g2).unwrap(); + c.sync(None).unwrap() + }; -// const TEST_ROUNDS: usize = 50; -// // check that the batch index for rounds 0..TEST_ROUNDS are [0, 1, 2, 0, 1, 2, ...] -// for expected_batch_idx in (0..=2).cycle().take(TEST_ROUNDS) { -// assert_eq!(expected_batch_idx, which_of_three()); -// } -// } + const TEST_ROUNDS: usize = 50; + // check that the batch index for rounds 0..TEST_ROUNDS are [0, 1, 2, 0, 1, 2, ...] + for expected_batch_idx in (0..=2).cycle().take(TEST_ROUNDS) { + assert_eq!(expected_batch_idx, which_of_three()); + } +}