From ca879b9f2ff4329ac8536ac1835888c35b392a93 Mon Sep 17 00:00:00 2001 From: Rodario Date: Tue, 31 Aug 2021 11:13:33 +0200 Subject: [PATCH 01/29] Adds working ActionIsPresent Test --- test/Cpp/src/ActionIsPresent.lf | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/Cpp/src/ActionIsPresent.lf diff --git a/test/Cpp/src/ActionIsPresent.lf b/test/Cpp/src/ActionIsPresent.lf new file mode 100644 index 0000000000..17409bd8a3 --- /dev/null +++ b/test/Cpp/src/ActionIsPresent.lf @@ -0,0 +1,27 @@ +// Tests the is_present variable for actions in cpp +target Cpp; + +main reactor ActionIsPresent(offset:time(1 nsec), period:time(500 msec)) { + logical action a; + state success:bool(false); + state zero:time(0 nsec); + reaction(startup, a) -> a {= + if (!a.is_present()) { + if (offset == zero) { + std::cout << "Hello World!" << '\n'; + success = true; + } else { + a.schedule(offset); + } + } else { + std::cout << "Hello World 2!" << '\n'; + success = true; + } + =} + reaction(shutdown) {= + if (!success) { + std::cerr << "Failed to print 'Hello World!'" << '\n'; + exit(1); + } + =} +} \ No newline at end of file From 065bf0f7189f0014d1b70f98607c6695db9f5240 Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 2 Sep 2021 09:49:18 +0200 Subject: [PATCH 02/29] Starts the Alignment test for cpp --- test/Cpp/src/Alignment.lf | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/Cpp/src/Alignment.lf diff --git a/test/Cpp/src/Alignment.lf b/test/Cpp/src/Alignment.lf new file mode 100644 index 0000000000..b4dc9899fb --- /dev/null +++ b/test/Cpp/src/Alignment.lf @@ -0,0 +1,27 @@ +// This test checks that the downstream reaction is not invoked more +// than once at a logical time. +target Cpp { + logging: LOG, + timeout: 1 sec +} + +reactor Source { + output out:int; + state count:int(1); + timer t(0, 100 msec); + reaction(t) -> out {= + count++; + out.set(count); + =} +} + +reactor Sieve { + input in:int; + output out:bool; + state primes:int*({= nullptr =}); + state last_prime:int(0); + reaction(startup) {= + // There are 1229 primes between 1 and 10,000. + // VECTOR HERE + =} +} \ No newline at end of file From ec1f52e36408eaa843c3e20a6bfdb9537010e0cf Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 22 Sep 2021 15:28:19 +0200 Subject: [PATCH 03/29] Adds Alignment test --- test/Cpp/src/Alignment.lf | 81 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/test/Cpp/src/Alignment.lf b/test/Cpp/src/Alignment.lf index b4dc9899fb..c86eaec00c 100644 --- a/test/Cpp/src/Alignment.lf +++ b/test/Cpp/src/Alignment.lf @@ -2,7 +2,8 @@ // than once at a logical time. target Cpp { logging: LOG, - timeout: 1 sec + timeout: 1 sec, + build-type: Debug } reactor Source { @@ -16,12 +17,86 @@ reactor Source { } reactor Sieve { + //TODO Floating point exception (core dumped) ab hier! + private preamble {= + #include "reactor-cpp/logging.hh" + =} input in:int; output out:bool; - state primes:int*({= nullptr =}); + state primes:std::vector; state last_prime:int(0); reaction(startup) {= // There are 1229 primes between 1 and 10,000. - // VECTOR HERE + // Primes 1 and 2 are not on the list. + primes.push_back(3); + =} + reaction(in) -> out {= + // Reject out of bounds inputs + if(*in.get() <= 0 || *in.get() > 10000) { + reactor::log::Warn() << "Sieve: Input value out of range: " << *in.get(); + } + // Primes 1 and 2 are not on the list. + if (*in.get() == 1 || *in.get() == 2) { + out.set(true); + return; + } + // If the input is greater than the last found prime, then + // we have to expand the list of primes before checking to + // see whether this is prime. + int candidate = primes.back(); + reactor::log::Info() << "Sieve: Checking prime: " << candidate; + while (*in.get() > primes.back()) { + candidate += 2; + bool prime = true; + for (auto i : primes) { + if(candidate % i == 0) { + // Candidate is not prime. Break and add 2 by starting the loop again + prime = false; + break; + } + } + // If the candidate is not divisible by any prime in the list, it is prime + if (prime) { + primes.push_back(candidate); + reactor::log::Info() << "Sieve: Found prime: " << candidate; + } + } + + // We are now assured that the input is less than or + // equal to the last prime on the list. + // See whether the input is an already found prime. + // Search the primes from the end, where they are sparser. + for (auto i = primes.rbegin(); i != primes.rend(); ++i) { + if(*i == *in.get()) { + out.set(true); + return; + } + } =} +} + +reactor Destination { + input ok:bool; + input in:int; + state last_invoked:{=std::chrono::time_point=}({=std::chrono::system_clock::now()=}); + reaction(ok, in) {= + if (ok.is_present() && in.is_present()) { + reactor::log::Info() << "Destination: Input " << *in.get() << " is a prime at tag ( " + << last_invoked << " )"; + } + if( get_logical_time() <= last_invoked) { + reactor::log::Error() << "Invoked at tag (" << get_logical_time() << ") " + << "but previously invoked at tag (" << last_invoked << ")"; + } + + last_invoked = get_logical_time(); + =} +} +main reactor { + source = new Source(); + sieve = new Sieve(); + destination = new Destination(); + source.out -> sieve.in; + sieve.out -> destination.ok; + source.out -> destination.in; } \ No newline at end of file From d5f03a053277ad3fbae30355a94e48d8e83af49d Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 22 Sep 2021 18:01:43 +0200 Subject: [PATCH 04/29] Adds CompositionGain Test --- test/Cpp/src/CompositionGain.lf | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/Cpp/src/CompositionGain.lf diff --git a/test/Cpp/src/CompositionGain.lf b/test/Cpp/src/CompositionGain.lf new file mode 100644 index 0000000000..b37208ae42 --- /dev/null +++ b/test/Cpp/src/CompositionGain.lf @@ -0,0 +1,30 @@ +// This tests send data through a contained reactor +target Cpp; +reactor Gain { + input gainin:int; + output y:int; + reaction(gainin) -> y {= + reactor::log::Info() << "Gain received " << *gainin.get(); + y.set(*gainin.get()*2); + =} +} +reactor Wrapper { + input x:int; + output y:int; + gain = new Gain(); + x -> gain.gainin; + gain.y -> y; +} +main reactor CompositionGain { + wrapper = new Wrapper(); + reaction(startup) -> wrapper.x {= + wrapper.x.set(42); + =} + reaction(wrapper.y) {= + reactor::log::Info() << "Received " << *wrapper.y.get(); + if (*wrapper.y.get() != 42*2) { + reactor::log::Error() << "Received value should have been " << 42 * 2; + exit(2); + } + =} +} \ No newline at end of file From 134c59b8dbb6c7652e3ecd4abe2f99881fbd809e Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 22 Sep 2021 18:28:45 +0200 Subject: [PATCH 05/29] Adds DoubleInvocation test and small cleanup in Alignment test --- test/Cpp/src/Alignment.lf | 1 - test/Cpp/src/DoubleInvocation.lf | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/Cpp/src/DoubleInvocation.lf diff --git a/test/Cpp/src/Alignment.lf b/test/Cpp/src/Alignment.lf index c86eaec00c..9c3ab159bb 100644 --- a/test/Cpp/src/Alignment.lf +++ b/test/Cpp/src/Alignment.lf @@ -24,7 +24,6 @@ reactor Sieve { input in:int; output out:bool; state primes:std::vector; - state last_prime:int(0); reaction(startup) {= // There are 1229 primes between 1 and 10,000. // Primes 1 and 2 are not on the list. diff --git a/test/Cpp/src/DoubleInvocation.lf b/test/Cpp/src/DoubleInvocation.lf new file mode 100644 index 0000000000..25d8e2e0b7 --- /dev/null +++ b/test/Cpp/src/DoubleInvocation.lf @@ -0,0 +1,54 @@ +// This illustrates a very strange bug that showed up +// and has now been fixed. This test ensures it does +// not reappear. +// At logical time zero, the two Print reactors used to be +// fired twice each at the same logical time. +// They should only be fired once. +// This behavior was oddly eliminated by either of the following +// actions, neither of which should affect this behavior: +// * Removing the startup reaction in Print. +// * Sending only position, not velocity from Ball. +// (copied from the c version of the test) + +target Cpp{ + timeout: 5 sec, + fast: true +} +reactor Ball { + output position:int; + output velocity:int; + state p:int(200); + timer trigger(0, 1 sec); + reaction(trigger) -> position, velocity {= + position.set(p); + velocity.set(-1); + p -= 1; + =} +} +reactor Print { + input velocity:int; + input position:int; + state previous:int(-1); + reaction (startup) {= + reactor::log::Info() << "####### Print startup"; + =} + reaction (position, velocity) {= + if (position.is_present()) { + reactor::log::Info() << "Position: " << *position.get(); + } + if (*position.get() == previous) { + reactor::log::Error() << "Multiple firings at the same logical time!"; + exit(1); + } + =} + +} +main reactor DoubleInvocation { + b1 = new Ball(); + p = new Print(); + plot = new Print(); + b1.position -> p.position; + b1.velocity -> p.velocity; + b1.position -> plot.position; + b1.velocity -> plot.velocity; +} \ No newline at end of file From 00536062a70d420db8b4dc92ad4aca37a83c8b1c Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 22 Sep 2021 18:43:58 +0200 Subject: [PATCH 06/29] Cleanup of TODO msg --- test/Cpp/src/Alignment.lf | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Cpp/src/Alignment.lf b/test/Cpp/src/Alignment.lf index 9c3ab159bb..92aacd50ca 100644 --- a/test/Cpp/src/Alignment.lf +++ b/test/Cpp/src/Alignment.lf @@ -17,7 +17,6 @@ reactor Source { } reactor Sieve { - //TODO Floating point exception (core dumped) ab hier! private preamble {= #include "reactor-cpp/logging.hh" =} From 9a6e93a39dc75e1de9d126a8881186ad77928cb9 Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 24 Sep 2021 14:12:31 +0200 Subject: [PATCH 07/29] Adds DoublePort Test, not functional. --- test/Cpp/src/DoublePort.lf | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/Cpp/src/DoublePort.lf diff --git a/test/Cpp/src/DoublePort.lf b/test/Cpp/src/DoublePort.lf new file mode 100644 index 0000000000..b5ee869cd7 --- /dev/null +++ b/test/Cpp/src/DoublePort.lf @@ -0,0 +1,57 @@ +/** + * Test the case where two upstream reactors + * pass messages to a downstream reactor on two + * different ports. One message carries + * a microstep delay relative to the other. + * + * @author Maiko Brants + */ +target Cpp { + timeout: 900 msec, + fast: true +}; + +import Count from "lib/Count.lf"; + +reactor CountMicrostep { + state count:int(1); + output out:int; + logical action act:int; + timer t(0, 1 sec); + reaction(t) -> act {= + act.schedule( count); + count++; + =} + + reaction(act) -> out {= + out.set(act.get()); + =} +} + +reactor Print { + input in:int; + input in2:int; + reaction(in, in2) {= + auto elapsed_time = get_elapsed_logical_time(); + + reactor::log::Info() << "At tag (" << elapsed_time << ", " << get_logical_time() + << "), received in = " << *in2.get() << " and in2 = " << *in2.get(); + + if ( in.is_present() && in2.is_present()) { + reactor::log::Error() << "ERROR: invalid logical simultaneity."; + exit(1); + } + =} + + reaction(shutdown) {= + reactor::log::Info() << "SUCCESS: messages were at least one microstep apart."; + =} +} + +main reactor DoublePort { + c = new Count(); + cm = new CountMicrostep(); + p = new Print(); + c.c -> p.in; + cm.out -> p.in2; +} \ No newline at end of file From 956c4fd8b408a9272ea8a6c9cf1fee205dde9c27 Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 27 Oct 2021 12:30:50 +0200 Subject: [PATCH 08/29] Adds DoublePort test with checks for precense --- test/Cpp/src/DoublePort.lf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/Cpp/src/DoublePort.lf b/test/Cpp/src/DoublePort.lf index b5ee869cd7..33109244df 100644 --- a/test/Cpp/src/DoublePort.lf +++ b/test/Cpp/src/DoublePort.lf @@ -33,9 +33,14 @@ reactor Print { input in2:int; reaction(in, in2) {= auto elapsed_time = get_elapsed_logical_time(); + if(in.is_present()){ + reactor::log::Info() << "At tag (" << elapsed_time << ", " << get_logical_time() + << "), received in = " << *in.get(); + } else if (in2.is_present()){ + reactor::log::Info() << "At tag (" << elapsed_time << ", " << get_logical_time() + << "), received in2 = " << *in2.get(); + } - reactor::log::Info() << "At tag (" << elapsed_time << ", " << get_logical_time() - << "), received in = " << *in2.get() << " and in2 = " << *in2.get(); if ( in.is_present() && in2.is_present()) { reactor::log::Error() << "ERROR: invalid logical simultaneity."; From 64f88cb008bfb4770a12fb20c57eac4b7562a4b8 Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 28 Oct 2021 10:37:03 +0200 Subject: [PATCH 09/29] Adds ImportedComposition Test with needed import file --- test/Cpp/src/ImportComposition.lf | 42 +++++++++++++++++++++++++ test/Cpp/src/lib/ImportedComposition.lf | 27 ++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 test/Cpp/src/ImportComposition.lf create mode 100644 test/Cpp/src/lib/ImportedComposition.lf diff --git a/test/Cpp/src/ImportComposition.lf b/test/Cpp/src/ImportComposition.lf new file mode 100644 index 0000000000..5786693b00 --- /dev/null +++ b/test/Cpp/src/ImportComposition.lf @@ -0,0 +1,42 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* This tests the ability to import a reactor definition +* that itself imports a reactor definition. +* +* modeled after the C version of this test +**/ +target Cpp; +import ImportedComposition from "lib/ImportedComposition.lf"; + +main reactor ImportComposition { + public preamble {= + #include "reactor-cpp/logging.hh" + =} + + imp_comp = new ImportedComposition(); + state received:bool(false); + reaction(startup) -> imp_comp.x {= + imp_comp.x.set(42); + =} + reaction(imp_comp.y) {= + auto receive_time = get_elapsed_logical_time(); + reactor::log::Info() << "Received " << *imp_comp.y.get() << " at time " << receive_time; + received = true; + if(receive_time.count() != 55000000LL) { + reactor::log::Error() << "ERROR: Received time should have been: 55,000,000."; + exit(1); + } + if(*imp_comp.y.get() != 42*2*2) { + reactor::log::Error() << "ERROR: Received value should have been: " << 42*2*2 << "."; + exit(2); + } + =} + reaction(shutdown) {= + if(!received){ + reactor::log::Error() << "ERROR: Nothing received."; + exit(3); + } + =} +} \ No newline at end of file diff --git a/test/Cpp/src/lib/ImportedComposition.lf b/test/Cpp/src/lib/ImportedComposition.lf new file mode 100644 index 0000000000..67902fc9c9 --- /dev/null +++ b/test/Cpp/src/lib/ImportedComposition.lf @@ -0,0 +1,27 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* This is used by the test for the ability to import a reactor definition +* that itself imports a reactor definition. +* +* modeled after the C version of this test +**/ +target Cpp; + +reactor Gain { + input x:int; + output y:int; + reaction(x) -> y {= + y.set(*x.get() * 2); + =} +} +reactor ImportedComposition { + input x:int; + output y:int; + g1 = new Gain(); + g2 = new Gain(); + x -> g1.x after 10 msec; + g1.y -> g2.x after 30 msec; + g2.y -> y after 15 msec; +} \ No newline at end of file From 70074eb1d3eae8226bae3e2d62817a85957fe17c Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 28 Oct 2021 10:51:32 +0200 Subject: [PATCH 10/29] Adds test ImportRenamed --- test/Cpp/src/ImportRenamed.lf | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/Cpp/src/ImportRenamed.lf diff --git a/test/Cpp/src/ImportRenamed.lf b/test/Cpp/src/ImportRenamed.lf new file mode 100644 index 0000000000..f66864b1ed --- /dev/null +++ b/test/Cpp/src/ImportRenamed.lf @@ -0,0 +1,23 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* This tests the ability to import a reactor definition +* that itself imports a reactor definition. +* +* modeled after the C version of this test +**/ +target Cpp; +import Imported as X from "lib/Imported.lf" +import Imported as Y from "lib/Imported.lf" +import ImportedAgain as Z from "lib/ImportedAgain.lf" +main reactor { + timer t; + a = new X(); + b = new Y(); + c = new Z(); + + reaction(t) -> a.x {= + a.x.set(42); + =} +} \ No newline at end of file From b835b499e77173136ed618d2ebe1068eecad5072 Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 28 Oct 2021 11:09:53 +0200 Subject: [PATCH 11/29] Adds test ParameterHierarchy --- test/Cpp/src/ParameterHierarchy.lf | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/Cpp/src/ParameterHierarchy.lf diff --git a/test/Cpp/src/ParameterHierarchy.lf b/test/Cpp/src/ParameterHierarchy.lf new file mode 100644 index 0000000000..9d094ca699 --- /dev/null +++ b/test/Cpp/src/ParameterHierarchy.lf @@ -0,0 +1,28 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* Test that parameter values pass down a deep hierarchy. +* +* modeled after the C version of this test +**/ +target Cpp; +reactor Deep(p:int(0)) { + reaction(startup) {= + if(p != 42) { + reactor::log::Error() << "Parameter value is: " << p << ". Should have been 42."; + exit(1); + } else { + reactor::log::Info() << "Success."; + } + =} +} +reactor Intermediate(p:int(10)) { + a = new Deep(p = p); +} +reactor Another(p:int(20)) { + a = new Intermediate(p = p); +} +main reactor ParameterHierarchy { + a = new Intermediate(p = 42); +} \ No newline at end of file From cd29e30e7c7f9862dabb3ab79267f1461a84657e Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 28 Oct 2021 11:26:09 +0200 Subject: [PATCH 12/29] Adds test PhysicalConnection --- test/Cpp/src/PhysicalConnection.lf | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/Cpp/src/PhysicalConnection.lf diff --git a/test/Cpp/src/PhysicalConnection.lf b/test/Cpp/src/PhysicalConnection.lf new file mode 100644 index 0000000000..fef3ec9b3f --- /dev/null +++ b/test/Cpp/src/PhysicalConnection.lf @@ -0,0 +1,31 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* Test physical connections. +* +* Modeled after the C version of this test. +**/ +target Cpp; +reactor Source { + output out:int; + reaction(startup) -> out {= + out.set(42); + =} +} +reactor Destination { + input in:int; + reaction(in) {= + auto time{get_elapsed_physical_time()}; + reactor::log::Info() << "Received " << *in.get() << " at logical time " << time.count() << "."; + if(time.count() <= 0LL) { + reactor::log::Error() << "ERROR: Logical time should have been greater than zero."; + exit(1); + } + =} +} +main reactor PhysicalConnection { + source = new Source(); + destination = new Destination(); + source.out ~> destination.in; +} \ No newline at end of file From d3f3f81b26f2914dfc1f5699edfb00d860218df4 Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 28 Oct 2021 17:19:33 +0200 Subject: [PATCH 13/29] Adds ScheduleLogicalAction --- test/Cpp/src/ScheduleLogicalAction.lf | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/Cpp/src/ScheduleLogicalAction.lf diff --git a/test/Cpp/src/ScheduleLogicalAction.lf b/test/Cpp/src/ScheduleLogicalAction.lf new file mode 100644 index 0000000000..afe9f66d16 --- /dev/null +++ b/test/Cpp/src/ScheduleLogicalAction.lf @@ -0,0 +1,51 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* This checks that a logical action is scheduled the specified +* logical time after the current logical time. +* +* Modeled after the C version of this test. +**/ +target Cpp { + fast: true, + timeout: 3 sec +}; +reactor foo { + input x:int; + output y:int; + logical action a:void; + reaction(x) -> y, a {= + y.set( 2*(*x.get())); + // The following uses physical time, incorrectly. + a.schedule(500ms); + =} + reaction(a) -> y {= + y.set(-42); + =} +} + +reactor print { + state expected_time:time(0); + input x:int; + reaction(x) {= + auto elapsed_time = get_elapsed_logical_time(); + reactor::log::Info() << "Result is " << *x.get(); + reactor::log::Info() << "Current logical time is: " << elapsed_time.count(); + reactor::log::Info() << "Current physical time is: " << get_elapsed_physical_time().count(); + if(elapsed_time != expected_time) { + reactor::log::Error() << "ERROR: Expected logical time to be " << expected_time; + exit(1); + } + expected_time += 500ms; + =} +} +main reactor { + f = new foo(); + p = new print(); + timer t(0, 1 sec); + reaction(t) -> f.x {= + f.x.set(42); + =} + f.y -> p.x; +} \ No newline at end of file From 90644544e05e7cbfe279c54999b301fc1c311fb7 Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 28 Oct 2021 17:45:09 +0200 Subject: [PATCH 14/29] Adds Test SelfLoop --- test/Cpp/src/SelfLoop.lf | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/Cpp/src/SelfLoop.lf diff --git a/test/Cpp/src/SelfLoop.lf b/test/Cpp/src/SelfLoop.lf new file mode 100644 index 0000000000..9a7ee29dbd --- /dev/null +++ b/test/Cpp/src/SelfLoop.lf @@ -0,0 +1,42 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* Modeled after the C version of this test. +**/ +target Cpp { + timeout: 1 sec, + fast: true +}; +reactor Self { + input x:int; + output y:int; + logical action a:int; + state expected:int(43); + reaction(a) -> y {= + reactor::log::Info() << "a = " << *a.get(); + y.set(*a.get()+1); + =} + reaction(x) -> a {= + reactor::log::Info() << "x = " << *x.get(); + if(*x.get() != expected){ + reactor::log::Error() << "Expected " << expected; + exit(1); + } + expected++; + a.schedule(x.get(), 100ms); + =} + reaction(startup) -> a {= + a.schedule(42, 0ns); + =} + reaction(shutdown) {= + if(expected <= 43) { + reactor::log::Error() << "Received no data."; + exit(2); + } + =} +} +main reactor SelfLoop { + u = new Self(); + u.y -> u.x; +} \ No newline at end of file From ae40d667a7b1527cc52440fc021a5ade628e91aa Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 29 Oct 2021 10:04:40 +0200 Subject: [PATCH 15/29] Adds Test SlowingClock --- test/Cpp/src/SlowingClock.lf | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/Cpp/src/SlowingClock.lf diff --git a/test/Cpp/src/SlowingClock.lf b/test/Cpp/src/SlowingClock.lf new file mode 100644 index 0000000000..5ad97d9fca --- /dev/null +++ b/test/Cpp/src/SlowingClock.lf @@ -0,0 +1,42 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* Events are scheduled with increasing additional delays of 0, 100, 300, 600 +* msec on a logical action with a minimum delay of 100 msec. +* The use of the logical action ensures the elapsed time jumps exactly from +* 0 to 100, 300, 600, and 1000 msec. +* +* Modeled after the C version of this test. +**/ +target Cpp { + timeout: 1 sec, + fast: true, +}; +main reactor SlowingClock { + logical action a(100 msec); + state interval:time(100 msec); + state expected_time:time(100 msec); + reaction(startup) -> a {= + a.schedule(0ns); + =} + reaction(a) -> a {= + auto elapsed_logical_time = get_elapsed_logical_time(); + reactor::log::Info() << "Logical time since start: " << elapsed_logical_time.count() << " nsec."; + if(elapsed_logical_time != expected_time) { + reactor::log::Error() << "Expected time to be: " << expected_time; + exit(1); + } + a.schedule(interval); + expected_time += 100ms + interval; + interval += 100ms; + =} + reaction(shutdown) {= + if(expected_time != 1500ms){ + reactor::log::Error() << "Expected the next expected time to be: 1500000000 nsec."; + reactor::log::Error() << "It was: " << expected_time; + } else { + reactor::log::Info() << "Test passes."; + } + =} +} From 48a1d0c4c91860be44876cbe40cff255ab0180a0 Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 29 Oct 2021 12:28:48 +0200 Subject: [PATCH 16/29] Adds Test for SlowingClockPhysical Altered from c-version because of differing support for physical actions in cpp --- test/Cpp/src/SlowingClockPhysical.lf | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/Cpp/src/SlowingClockPhysical.lf diff --git a/test/Cpp/src/SlowingClockPhysical.lf b/test/Cpp/src/SlowingClockPhysical.lf new file mode 100644 index 0000000000..c9c9ec15f7 --- /dev/null +++ b/test/Cpp/src/SlowingClockPhysical.lf @@ -0,0 +1,43 @@ +/** +* +* @author Maiko Brants TU Dresden +* + * Events are scheduled with increasing additional delays of 0, 100, 300, 600 + * msec on a physical action with a minimum delay of 100 msec. + * The use of the physical action makes the elapsed time jumps from 0 to + * approximately 100 msec, to approximatly 300 msec thereafter, drifting away + * further with each new event. +* +* Modeled after the C version of this test. +**/ +target Cpp { + timeout: 1500 msec +}; +main reactor SlowingClockPhysical { + physical action a; + state interval:time(100 msec); + state expected_time:time(100 msec); + reaction(startup) -> a {= + expected_time=100ms; + a.schedule(100ms); + =} + reaction(a) -> a {= + auto elapsed_logical_time{get_elapsed_logical_time()}; + reactor::log::Info() << "Logical time since start: " << elapsed_logical_time; + if(elapsed_logical_time < expected_time){ + reactor::log::Error() << "Expected logical time to be at least: " << expected_time; + exit(1); + } + interval += 100ms; + expected_time = 100ms + interval; + a.schedule(interval); + reactor::log::Info() << "Scheduling next to occur approximately after: " << interval; + =} + reaction(shutdown) {= + if(expected_time < 500ms){ + reactor::log::Error() << "Expected the next expected time to be at least: 500000000 nsec."; + reactor::log::Error() << "It was: " << expected_time; + exit(2); + } + =} +} \ No newline at end of file From cf1647b769eb83ceb6356a4409bb88f4fe301387 Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 29 Oct 2021 14:04:09 +0200 Subject: [PATCH 17/29] Adds StartupOutFromInside test --- test/Cpp/src/StartupOutFromInside.lf | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/Cpp/src/StartupOutFromInside.lf diff --git a/test/Cpp/src/StartupOutFromInside.lf b/test/Cpp/src/StartupOutFromInside.lf new file mode 100644 index 0000000000..6ed2ac938b --- /dev/null +++ b/test/Cpp/src/StartupOutFromInside.lf @@ -0,0 +1,19 @@ +target Cpp; + +reactor Bar { + output out:int; + reaction(startup) -> out {= + out.set(42); + =} +} + +main reactor StartupOutFromInside { + bar = new Bar(); + reaction(startup) bar.out {= + reactor::log::Info() << "Output from bar: " << *bar.out.get(); + if(*bar.out.get() != 42) { + reactor::log::Error() << "Expected 42!"; + exit(1); + } + =} +} \ No newline at end of file From 8e51ef2696d799f724088fb32ff85c344e31284c Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 29 Oct 2021 14:08:15 +0200 Subject: [PATCH 18/29] Adds author annotation --- test/Cpp/src/StartupOutFromInside.lf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/Cpp/src/StartupOutFromInside.lf b/test/Cpp/src/StartupOutFromInside.lf index 6ed2ac938b..219c9cc703 100644 --- a/test/Cpp/src/StartupOutFromInside.lf +++ b/test/Cpp/src/StartupOutFromInside.lf @@ -1,3 +1,9 @@ +/** +* +* @author Maiko Brants TU Dresden +* +* Modeled after the C version of this test. +**/ target Cpp; reactor Bar { From ee471d2148676976661007c7430b1c93439cefad Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 3 Nov 2021 15:32:53 +0100 Subject: [PATCH 19/29] Adds the timeout test with needed lib class The naming collides with a timeout parameter in the MainGenerator of the cpp target so the test is named differently from c. --- test/Cpp/src/Timeout_Test.lf | 45 ++++++++++++++++++++++++++ test/Cpp/src/lib/LoopedActionSender.lf | 32 ++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 test/Cpp/src/Timeout_Test.lf create mode 100644 test/Cpp/src/lib/LoopedActionSender.lf diff --git a/test/Cpp/src/Timeout_Test.lf b/test/Cpp/src/Timeout_Test.lf new file mode 100644 index 0000000000..e2f4e7086f --- /dev/null +++ b/test/Cpp/src/Timeout_Test.lf @@ -0,0 +1,45 @@ +/** +* +* A test for the timeout functionality in Lingua Franca. +* +* @author Maiko Brants TU Dresden +* +* Modeled after the C version of this test. +**/ +target Cpp{ + timeout: 11 msec +} + +import Sender from "lib/LoopedActionSender.lf" + +reactor Consumer { + input in:int; + state success:bool(false); + reaction(in) {= + auto current{get_elapsed_logical_time()}; + if(current > 11ms ){ + reactor::log::Error() << "Received at: " << current.count() << ". Failed to enforce timeout."; + exit(1); + } else { + success{true}; // Successfully invoked the reaction at (timeout, 0) + } + =} + + reaction(shutdown) {= + reactor::log::Info() << "Shutdown invoked at " << get_elapsed_logical_time(); + if((get_elapsed_logical_time() == 11ms ) && (success == true)){ + reactor::log::Info() << "SUCCESS: successfully enforced timeout."; + } else { + reactor::log::Error() << "Shutdown invoked at: " << get_elapsed_logical_time() << ". Failed to enforce timeout."; + exit(1); + } + + =} +} + +main reactor Timeout_Test { + consumer = new Consumer(); + producer = new Sender(break_interval = 1 msec); + + producer.out -> consumer.in; +} \ No newline at end of file diff --git a/test/Cpp/src/lib/LoopedActionSender.lf b/test/Cpp/src/lib/LoopedActionSender.lf new file mode 100644 index 0000000000..0611f429d3 --- /dev/null +++ b/test/Cpp/src/lib/LoopedActionSender.lf @@ -0,0 +1,32 @@ +/** + * A sender reactor that outputs integers + * in superdense time. + * + * Modeled after the C version of this file. + * + * @author Maiko Brants + */ + target Cpp; + + /** + * @param take_a_break_after: Indicates how many messages are sent + * in consecutive superdense time + * @param break_interval: Determines how long the reactor should take + * a break after sending take_a_break_after messages. + */ + reactor Sender(take_a_break_after:int(10), break_interval:time(400 msec)) { + output out:int; + logical action act; + state sent_messages:int(0); + reaction(startup, act) -> act, out {= + out.set(sent_messages); + sent_messages++; + if(sent_messages < take_a_break_after){ + act.schedule(0ns); + } else { + // Take a break + sent_messages=0; + act.schedule(break_interval); + } + =} + } \ No newline at end of file From ac47da072e0da1657282efa5989d28a92351f493 Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 4 Nov 2021 15:45:06 +0100 Subject: [PATCH 20/29] Cleanup of timeout_test --- test/Cpp/src/Timeout_Test.lf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/Cpp/src/Timeout_Test.lf b/test/Cpp/src/Timeout_Test.lf index e2f4e7086f..1ec45272ca 100644 --- a/test/Cpp/src/Timeout_Test.lf +++ b/test/Cpp/src/Timeout_Test.lf @@ -1,5 +1,4 @@ /** -* * A test for the timeout functionality in Lingua Franca. * * @author Maiko Brants TU Dresden @@ -20,8 +19,8 @@ reactor Consumer { if(current > 11ms ){ reactor::log::Error() << "Received at: " << current.count() << ". Failed to enforce timeout."; exit(1); - } else { - success{true}; // Successfully invoked the reaction at (timeout, 0) + } else if(current == 11ms) { + success=true; } =} From 9bbe5d60c212d510a7fce5e1d2f162892bcdf701 Mon Sep 17 00:00:00 2001 From: Rodario Date: Thu, 4 Nov 2021 15:46:08 +0100 Subject: [PATCH 21/29] Adds faulty TimeoutZero test it seems logically equivalent to the C version but does not terminate after 0 secs --- test/Cpp/src/TimeoutZero.lf | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/Cpp/src/TimeoutZero.lf diff --git a/test/Cpp/src/TimeoutZero.lf b/test/Cpp/src/TimeoutZero.lf new file mode 100644 index 0000000000..0927582405 --- /dev/null +++ b/test/Cpp/src/TimeoutZero.lf @@ -0,0 +1,46 @@ +/** +* A test for the timeout functionality in Lingua Franca. +* This variant tests timeout at (0,0). +* +* @author Maiko Brants TU Dresden +* +* Modeled after the C version of this test. +**/ +target Cpp { + timeout: 1 sec +}; + +import Sender from "lib/LoopedActionSender.lf" + +reactor Consumer { + input in:int; + state success:bool(false); + + reaction(in) {= + auto current{get_elapsed_logical_time()}; + if(current > 0ms ){ + reactor::log::Error() << "Received at: " << current << ". Failed to enforce timeout."; + exit(1); + } else { + success=true; + } + =} + + reaction(shutdown) {= + reactor::log::Info() << "Shutdown invoked at " << get_elapsed_logical_time(); + if((get_elapsed_logical_time() == 0ns ) && (success == true)){ + reactor::log::Info() << "SUCCESS: successfully enforced timeout."; + } else { + reactor::log::Error() << "Shutdown invoked at: " << get_elapsed_logical_time() << ". Failed to enforce timeout."; + exit(1); + } + + =} +} + +main reactor TimeoutZero { + consumer = new Consumer(); + producer = new Sender(break_interval = 1 msec); + + producer.out -> consumer.in; +} \ No newline at end of file From d079e1942943f1150ec45db67f00bcc6cd14819a Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 5 Nov 2021 11:17:56 +0100 Subject: [PATCH 22/29] Adds ToReactionNested test --- test/Cpp/src/ToReactionNested.lf | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/Cpp/src/ToReactionNested.lf diff --git a/test/Cpp/src/ToReactionNested.lf b/test/Cpp/src/ToReactionNested.lf new file mode 100644 index 0000000000..dbacf94b67 --- /dev/null +++ b/test/Cpp/src/ToReactionNested.lf @@ -0,0 +1,36 @@ +target Cpp { + timeout: 5 sec, + fast: true +}; + +import Count from "lib/Count.lf"; + +reactor CountContainer { + output out:int; + c1 = new Count(); + c1.c -> out; +} + +main reactor { + state count:int(1); + state received:bool(false); + + s = new CountContainer(); + + reaction(s.out) {= + if (s.out.is_present()){ + reactor::log::Info() << "Received " << *s.out.get(); + if(count != *s.out.get()){ + reactor::log::Error() << "Expected " << count; + } + received = true; + } + count++; + =} + reaction(shutdown) {= + if(!received) { + reactor::log::Error() << "No inputs present."; + exit(1); + } + =} +} \ No newline at end of file From 2e322deeaaba6d6725d8061561ce7c9326df5829 Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 5 Nov 2021 13:24:40 +0100 Subject: [PATCH 23/29] Adds the TriggerDownstreamOnlyIfPresent2 test and fixes a part of TimeoutZero --- test/Cpp/src/TimeoutZero.lf | 2 +- .../src/TriggerDownstreamOnlyIfPresent2.lf | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/Cpp/src/TriggerDownstreamOnlyIfPresent2.lf diff --git a/test/Cpp/src/TimeoutZero.lf b/test/Cpp/src/TimeoutZero.lf index 0927582405..cf4609d8e2 100644 --- a/test/Cpp/src/TimeoutZero.lf +++ b/test/Cpp/src/TimeoutZero.lf @@ -7,7 +7,7 @@ * Modeled after the C version of this test. **/ target Cpp { - timeout: 1 sec + timeout: 0 sec }; import Sender from "lib/LoopedActionSender.lf" diff --git a/test/Cpp/src/TriggerDownstreamOnlyIfPresent2.lf b/test/Cpp/src/TriggerDownstreamOnlyIfPresent2.lf new file mode 100644 index 0000000000..5a443d28c3 --- /dev/null +++ b/test/Cpp/src/TriggerDownstreamOnlyIfPresent2.lf @@ -0,0 +1,38 @@ +/** +* This test checks that a downstream reaction is triggered only if its trigger is present. +* +* @author Maiko Brants TU Dresden +* +* Modeled after the C version of this test. +**/ +target Cpp { + timeout: 1 sec, + fast: true +}; +reactor Source { + output[2] out:int; + state count:int(0); + timer t(0, 200 msec); + reaction(t) -> out {= + if(count++ % 2 == 0) { + out[0].set(count); + } else { + out[1].set(count); + } + =} +} +reactor Destination { + input in:int; + reaction(in) {= + if(!in.is_present()){ + reactor::log::Error() << "Reaction to input of triggered even though all inputs are absent!"; + exit(1); + } + =} +} + +main reactor TriggerDownstreamOnlyIfPresent2 { + s = new Source(); + d = new[2] Destination(); + s.out -> d.in; +} \ No newline at end of file From 406d3a38985a1b355326bbdb3c8b23a215ff1a76 Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 5 Nov 2021 15:23:37 +0100 Subject: [PATCH 24/29] Removes test that is currently not needed --- test/Cpp/src/TimeoutZero.lf | 46 ------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 test/Cpp/src/TimeoutZero.lf diff --git a/test/Cpp/src/TimeoutZero.lf b/test/Cpp/src/TimeoutZero.lf deleted file mode 100644 index cf4609d8e2..0000000000 --- a/test/Cpp/src/TimeoutZero.lf +++ /dev/null @@ -1,46 +0,0 @@ -/** -* A test for the timeout functionality in Lingua Franca. -* This variant tests timeout at (0,0). -* -* @author Maiko Brants TU Dresden -* -* Modeled after the C version of this test. -**/ -target Cpp { - timeout: 0 sec -}; - -import Sender from "lib/LoopedActionSender.lf" - -reactor Consumer { - input in:int; - state success:bool(false); - - reaction(in) {= - auto current{get_elapsed_logical_time()}; - if(current > 0ms ){ - reactor::log::Error() << "Received at: " << current << ". Failed to enforce timeout."; - exit(1); - } else { - success=true; - } - =} - - reaction(shutdown) {= - reactor::log::Info() << "Shutdown invoked at " << get_elapsed_logical_time(); - if((get_elapsed_logical_time() == 0ns ) && (success == true)){ - reactor::log::Info() << "SUCCESS: successfully enforced timeout."; - } else { - reactor::log::Error() << "Shutdown invoked at: " << get_elapsed_logical_time() << ". Failed to enforce timeout."; - exit(1); - } - - =} -} - -main reactor TimeoutZero { - consumer = new Consumer(); - producer = new Sender(break_interval = 1 msec); - - producer.out -> consumer.in; -} \ No newline at end of file From 683db3a5bec24ec8de1803cdbb46b0b4b4ff3691 Mon Sep 17 00:00:00 2001 From: Rodario Date: Fri, 12 Nov 2021 11:52:07 +0100 Subject: [PATCH 25/29] Fixes compilation error of Alignment test on windows mashine --- test/Cpp/src/Alignment.lf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Cpp/src/Alignment.lf b/test/Cpp/src/Alignment.lf index 92aacd50ca..f9abc72feb 100644 --- a/test/Cpp/src/Alignment.lf +++ b/test/Cpp/src/Alignment.lf @@ -76,7 +76,7 @@ reactor Sieve { reactor Destination { input ok:bool; input in:int; - state last_invoked:{=std::chrono::time_point=}({=std::chrono::system_clock::now()=}); + state last_invoked:{=reactor::TimePoint=}; reaction(ok, in) {= if (ok.is_present() && in.is_present()) { reactor::log::Info() << "Destination: Input " << *in.get() << " is a prime at tag ( " From 4af54de1174fcfcb4e877ea3d1adb763623a15a1 Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 8 Dec 2021 11:03:36 +0100 Subject: [PATCH 26/29] Fixes use of wrong tag and cleanup --- test/Cpp/src/DoublePort.lf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/Cpp/src/DoublePort.lf b/test/Cpp/src/DoublePort.lf index 33109244df..9751cbabcf 100644 --- a/test/Cpp/src/DoublePort.lf +++ b/test/Cpp/src/DoublePort.lf @@ -32,12 +32,11 @@ reactor Print { input in:int; input in2:int; reaction(in, in2) {= - auto elapsed_time = get_elapsed_logical_time(); if(in.is_present()){ - reactor::log::Info() << "At tag (" << elapsed_time << ", " << get_logical_time() + reactor::log::Info() << "At tag (" << get_elapsed_logical_time() << ", " << environment()->logical_time().micro_step() << "), received in = " << *in.get(); } else if (in2.is_present()){ - reactor::log::Info() << "At tag (" << elapsed_time << ", " << get_logical_time() + reactor::log::Info() << "At tag (" << get_elapsed_logical_time() << ", " << environment()->logical_time().micro_step() << "), received in2 = " << *in2.get(); } From 3e976ad966353a83106ef1ac7c18ca6caae321b9 Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 15 Dec 2021 13:22:46 +0100 Subject: [PATCH 27/29] Fix from comments in PR --- test/Cpp/src/Alignment.lf | 8 ++++---- test/Cpp/src/ImportComposition.lf | 2 +- test/Cpp/src/PhysicalConnection.lf | 6 +++--- test/Cpp/src/ScheduleLogicalAction.lf | 2 +- test/Cpp/src/SlowingClock.lf | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/Cpp/src/Alignment.lf b/test/Cpp/src/Alignment.lf index f9abc72feb..df75c56331 100644 --- a/test/Cpp/src/Alignment.lf +++ b/test/Cpp/src/Alignment.lf @@ -79,12 +79,12 @@ reactor Destination { state last_invoked:{=reactor::TimePoint=}; reaction(ok, in) {= if (ok.is_present() && in.is_present()) { - reactor::log::Info() << "Destination: Input " << *in.get() << " is a prime at tag ( " - << last_invoked << " )"; + reactor::log::Info() << "Destination: Input " << *in.get() << " is a prime at logical time ( " + << get_elapsed_logical_time() << " )"; } if( get_logical_time() <= last_invoked) { - reactor::log::Error() << "Invoked at tag (" << get_logical_time() << ") " - << "but previously invoked at tag (" << last_invoked << ")"; + reactor::log::Error() << "Invoked at logical time (" << get_logical_time() << ") " + << "but previously invoked at logical time (" << get_elapsed_logical_time() << ")"; } last_invoked = get_logical_time(); diff --git a/test/Cpp/src/ImportComposition.lf b/test/Cpp/src/ImportComposition.lf index 5786693b00..a62e221dce 100644 --- a/test/Cpp/src/ImportComposition.lf +++ b/test/Cpp/src/ImportComposition.lf @@ -24,7 +24,7 @@ main reactor ImportComposition { auto receive_time = get_elapsed_logical_time(); reactor::log::Info() << "Received " << *imp_comp.y.get() << " at time " << receive_time; received = true; - if(receive_time.count() != 55000000LL) { + if(receive_time != 55ms) { reactor::log::Error() << "ERROR: Received time should have been: 55,000,000."; exit(1); } diff --git a/test/Cpp/src/PhysicalConnection.lf b/test/Cpp/src/PhysicalConnection.lf index fef3ec9b3f..383a0529b3 100644 --- a/test/Cpp/src/PhysicalConnection.lf +++ b/test/Cpp/src/PhysicalConnection.lf @@ -16,9 +16,9 @@ reactor Source { reactor Destination { input in:int; reaction(in) {= - auto time{get_elapsed_physical_time()}; - reactor::log::Info() << "Received " << *in.get() << " at logical time " << time.count() << "."; - if(time.count() <= 0LL) { + auto time{get_elapsed_logical_time()}; + reactor::log::Info() << "Received " << *in.get() << " at logical time " << time << "."; + if(time <= reactor::Duration::zero()) { reactor::log::Error() << "ERROR: Logical time should have been greater than zero."; exit(1); } diff --git a/test/Cpp/src/ScheduleLogicalAction.lf b/test/Cpp/src/ScheduleLogicalAction.lf index afe9f66d16..2b38e2620a 100644 --- a/test/Cpp/src/ScheduleLogicalAction.lf +++ b/test/Cpp/src/ScheduleLogicalAction.lf @@ -31,7 +31,7 @@ reactor print { reaction(x) {= auto elapsed_time = get_elapsed_logical_time(); reactor::log::Info() << "Result is " << *x.get(); - reactor::log::Info() << "Current logical time is: " << elapsed_time.count(); + reactor::log::Info() << "Current logical time is: " << elapsed_time; reactor::log::Info() << "Current physical time is: " << get_elapsed_physical_time().count(); if(elapsed_time != expected_time) { reactor::log::Error() << "ERROR: Expected logical time to be " << expected_time; diff --git a/test/Cpp/src/SlowingClock.lf b/test/Cpp/src/SlowingClock.lf index 5ad97d9fca..ca271ada9d 100644 --- a/test/Cpp/src/SlowingClock.lf +++ b/test/Cpp/src/SlowingClock.lf @@ -22,7 +22,7 @@ main reactor SlowingClock { =} reaction(a) -> a {= auto elapsed_logical_time = get_elapsed_logical_time(); - reactor::log::Info() << "Logical time since start: " << elapsed_logical_time.count() << " nsec."; + reactor::log::Info() << "Logical time since start: " << elapsed_logical_time; if(elapsed_logical_time != expected_time) { reactor::log::Error() << "Expected time to be: " << expected_time; exit(1); From af7d905ff32c4b0b6a12e3e5dc8ba19f8047d720 Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 15 Dec 2021 13:31:11 +0100 Subject: [PATCH 28/29] Fix for PhysicalConnection Test including wrong error msg --- test/Cpp/src/PhysicalConnection.lf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Cpp/src/PhysicalConnection.lf b/test/Cpp/src/PhysicalConnection.lf index 383a0529b3..75321b0b3b 100644 --- a/test/Cpp/src/PhysicalConnection.lf +++ b/test/Cpp/src/PhysicalConnection.lf @@ -16,10 +16,10 @@ reactor Source { reactor Destination { input in:int; reaction(in) {= - auto time{get_elapsed_logical_time()}; - reactor::log::Info() << "Received " << *in.get() << " at logical time " << time << "."; + auto time{get_elapsed_physical_time()}; + reactor::log::Info() << "Received " << *in.get() << " at physical time " << time << "."; if(time <= reactor::Duration::zero()) { - reactor::log::Error() << "ERROR: Logical time should have been greater than zero."; + reactor::log::Error() << "ERROR: Physical time should have been greater than zero."; exit(1); } =} From bf84399210581afcdb7cdfad57a9cc2c79c23484 Mon Sep 17 00:00:00 2001 From: Rodario Date: Wed, 15 Dec 2021 13:35:51 +0100 Subject: [PATCH 29/29] Remove PhysicalConnection test currently not implemented in Cpp --- test/Cpp/src/PhysicalConnection.lf | 31 ------------------------------ 1 file changed, 31 deletions(-) delete mode 100644 test/Cpp/src/PhysicalConnection.lf diff --git a/test/Cpp/src/PhysicalConnection.lf b/test/Cpp/src/PhysicalConnection.lf deleted file mode 100644 index 75321b0b3b..0000000000 --- a/test/Cpp/src/PhysicalConnection.lf +++ /dev/null @@ -1,31 +0,0 @@ -/** -* -* @author Maiko Brants TU Dresden -* -* Test physical connections. -* -* Modeled after the C version of this test. -**/ -target Cpp; -reactor Source { - output out:int; - reaction(startup) -> out {= - out.set(42); - =} -} -reactor Destination { - input in:int; - reaction(in) {= - auto time{get_elapsed_physical_time()}; - reactor::log::Info() << "Received " << *in.get() << " at physical time " << time << "."; - if(time <= reactor::Duration::zero()) { - reactor::log::Error() << "ERROR: Physical time should have been greater than zero."; - exit(1); - } - =} -} -main reactor PhysicalConnection { - source = new Source(); - destination = new Destination(); - source.out ~> destination.in; -} \ No newline at end of file