diff --git a/core/src/main/resources/lib/cpp/reactor-cpp b/core/src/main/resources/lib/cpp/reactor-cpp index fa685f1db9..3b25ffe3e2 160000 --- a/core/src/main/resources/lib/cpp/reactor-cpp +++ b/core/src/main/resources/lib/cpp/reactor-cpp @@ -1 +1 @@ -Subproject commit fa685f1db99b1652e39a5cf3c6356a8db26b52bb +Subproject commit 3b25ffe3e270ab10181552a7e08ba37a471d8868 diff --git a/test/Cpp/src/ReactionOrder.lf b/test/Cpp/src/ReactionOrder.lf new file mode 100644 index 0000000000..0427423d49 --- /dev/null +++ b/test/Cpp/src/ReactionOrder.lf @@ -0,0 +1,34 @@ +target Cpp + +reactor Src { + output out: unsigned + + reaction(startup) -> out {= + out.set(42); + =} +} + +reactor Sink { + input in: unsigned + + reaction(startup) in {= + if (!in.is_present()) { + reactor::log::Error() << "Received no value"; + exit(1); + } + if(*in.get() != 42) { + reactor::log::Error() << "Received an unexpected value"; + exit(1); + } + =} + + reaction(shutdown) {= + reactor::log::Info() << "Success!"; + =} +} + +main reactor ReactionOrder { + src = new Src() + sink = new Sink() + src.out -> sink.in +} diff --git a/test/Cpp/src/enclave/EnclaveCommunicationHierarchy.lf b/test/Cpp/src/enclave/EnclaveCommunicationHierarchy.lf new file mode 100644 index 0000000000..05556839f9 --- /dev/null +++ b/test/Cpp/src/enclave/EnclaveCommunicationHierarchy.lf @@ -0,0 +1,52 @@ +target Cpp { + timeout: 1 s, + workers: 1 +} + +reactor Src { + timer t(0, 100 ms) + output out: int + state counter: int = 0 + + reaction(t) -> out {= + out.set(counter++); + =} +} + +reactor Sink { + input in: int + state received: bool = false + + reaction(in) {= + received = true; + auto value = *in.get(); + reactor::log::Info() << "Received " << value; + auto expected = 100ms * value; + if (get_elapsed_logical_time() != expected) { + reactor::log::Error() << "Expecded value at " << expected << " but received it at " << get_elapsed_logical_time(); + exit(1); + } + =} + + reaction(shutdown) {= + if(!received) { + reactor::log::Error() << "Nothing received."; + exit(1); + } + =} +} + +reactor WrappedSink { + input in: int + sinkinner = new Sink() + in -> sinkinner.in +} + +main reactor { + @enclave + src = new Src() + @enclave + sink = new WrappedSink() + + src.out -> sink.in +} diff --git a/test/Cpp/src/enclave/EnclaveCommunicationPhysicalHierarchy.lf b/test/Cpp/src/enclave/EnclaveCommunicationPhysicalHierarchy.lf new file mode 100644 index 0000000000..b294a49509 --- /dev/null +++ b/test/Cpp/src/enclave/EnclaveCommunicationPhysicalHierarchy.lf @@ -0,0 +1,52 @@ +target Cpp { + timeout: 1 s, + workers: 1 +} + +reactor Src { + timer t(0, 100 ms) + output out: int + state counter: int = 0 + + reaction(t) -> out {= + out.set(counter++); + =} +} + +reactor Sink { + input in: int + state received: bool = false + + reaction(in) {= + received = true; + auto value = *in.get(); + reactor::log::Info() << "Received " << value << " at " << get_elapsed_logical_time(); + auto expected = 100ms * value; + if (get_elapsed_logical_time() < expected) { + reactor::log::Error() << "Expecded value not before " << expected; + exit(1); + } + =} + + reaction(shutdown) {= + if(!received) { + reactor::log::Error() << "Nothing received."; + exit(1); + } + =} +} + +reactor WrappedSrc { + output out: int + @enclave + src = new Src() + src.out ~> out +} + +main reactor { + src = new WrappedSrc() + @enclave + sink = new Sink() + + src.out -> sink.in +} diff --git a/test/Cpp/src/enclave/EnclaveReactionOrder.lf b/test/Cpp/src/enclave/EnclaveReactionOrder.lf new file mode 100644 index 0000000000..765959ff39 --- /dev/null +++ b/test/Cpp/src/enclave/EnclaveReactionOrder.lf @@ -0,0 +1,14 @@ +target Cpp + +import Src, Sink from "../ReactionOrder.lf" + +reactor ReactionOrder { + src = new Src() + sink = new Sink() + src.out -> sink.in +} + +main reactor { + @enclave + test = new ReactionOrder() +}