From 391565779bfaefbc403e0647086a2d7f848401a9 2020-08-21 11:43:40 From: Christopher Esterhuyse Date: 2020-08-21 11:43:40 Subject: [PATCH] fifo full test --- diff --git a/examples/README.md b/examples/README.md index 293f0aa6eae88cf2ec0bdd29807db33fb519f7e3..e5566219bbd73b2721400e85bf191f919722ba3d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,7 +4,7 @@ This directory contains a set of programs for demonstrating the use of connector ## Setting up and running First, ensure that the Reowolf has been compiled, such that a dylib is present in `reowolf/target/release/`; see the parent directory for instructions on compiling the library. -The examples are designed to be run with the examples folder as your working directory (`reowolf/examples`), containing a local copy of the dylic. Two convenience scripts are made available for copying the library: `cpy_dll.sh` and `cpy_so.sh` for platforms Linux and Windows respectively. +The examples are designed to be run with the examples folder as your working directory (`reowolf/examples`), containing a local copy of the dylib. Two convenience scripts are made available for copying the library: `cpy_dll.sh` and `cpy_so.sh` for platforms Linux and Windows respectively. Compiling the example programs is done using Python 3, with `python3 ./make.py`, which will crawl the example directory's children and compiling any C source files. diff --git a/src/runtime/tests.rs b/src/runtime/tests.rs index 4aa4e18a2842205889cc59da398bdcf8a8aae677..1ed4560aa473cd51f2028731dbdae864d73ece92 100644 --- a/src/runtime/tests.rs +++ b/src/runtime/tests.rs @@ -924,3 +924,65 @@ fn many_rounds_mem() { c.sync(SEC1).unwrap(); } } + +#[test] +fn pdl_reo_lossy() { + let pdl = b" + primitive lossy(in a, out b) { + while(true) synchronous { + msg m = null; + if(fires(a)) { + m = get(a); + if(fires(b)) { + put(b, m); + } + } + } + } + "; + reowolf::ProtocolDescription::parse(pdl).unwrap(); +} + +#[test] +fn pdl_reo_fifo1() { + let pdl = b" + primitive fifo1(in a, out b) { + msg m = null; + while(true) synchronous { + if(m == null) { + if(fires(a)) m=get(a); + } else { + if(fires(b)) put(b, m); + m = null; + } + } + } + "; + reowolf::ProtocolDescription::parse(pdl).unwrap(); +} + +#[test] +fn pdl_reo_fifo1_full() { + let pdl = b" + primitive fifo1_full(in a, out b) { + msg m = create(0); + while(true) synchronous { + if(m == null) { + if(fires(a)) m=get(a); + } else { + if(fires(b)) put(b, m); + m = null; + } + } + } + "; + let pd = reowolf::ProtocolDescription::parse(pdl).unwrap(); + let mut c = Connector::new(Box::new(DummyLogger), Arc::new(pd), 0); + let [_p0, g0] = c.new_port_pair(); + let [p1, g1] = c.new_port_pair(); + c.add_component(b"fifo1_full", &[g0, p1]).unwrap(); + c.connect(None).unwrap(); + c.get(g1).unwrap(); + c.sync(None).unwrap(); + assert_eq!(0, c.gotten(g1).unwrap().len()); +}