From 3c10dcd02c70d141b4608895b85dbb20adf18ed1 Mon Sep 17 00:00:00 2001 From: Soroush Bateni Date: Mon, 4 Apr 2022 14:39:46 -0500 Subject: [PATCH] Added a new failing test for TAN messages --- .../DistributedPhysicalActionUpstream.lf | 44 +++++++++++++++++++ test/C/src/lib/PassThrough.lf | 9 ++++ 2 files changed, 53 insertions(+) create mode 100644 test/C/src/federated/DistributedPhysicalActionUpstream.lf create mode 100644 test/C/src/lib/PassThrough.lf diff --git a/test/C/src/federated/DistributedPhysicalActionUpstream.lf b/test/C/src/federated/DistributedPhysicalActionUpstream.lf new file mode 100644 index 0000000000..301340c782 --- /dev/null +++ b/test/C/src/federated/DistributedPhysicalActionUpstream.lf @@ -0,0 +1,44 @@ +target C { timeout: 2 secs }; + +import PassThrough from "../lib/PassThrough.lf" +import TestCount from "../lib/TestCount.lf" + +preamble {= + int counter = 1; + void callback(void *a) { + schedule(a, counter++); + } + // Simulate time passing before a callback occurs. + void* take_time(void* a) { + while (counter < 40) { + instant_t sleep_time = MSEC(30); + lf_nanosleep(sleep_time); + callback(a); + } + return NULL; + } +=} + +reactor WithPhysicalAction { + output out:int; + state thread_id:lf_thread_t(0); + physical action act(0):int; + reaction(startup) -> act {= + // start new thread, provide callback + lf_thread_create(&self->thread_id, &take_time, act); + =} + + reaction(act) -> out {= + SET(out, act->value); + =} +} + +federated reactor { + a = new WithPhysicalAction(); + m1 = new PassThrough(); + m2 = new PassThrough(); + test = new TestCount(num_inputs=39); + a.out -> m1.in; + m1.out -> m2.in; + m2.out -> test.in; +} diff --git a/test/C/src/lib/PassThrough.lf b/test/C/src/lib/PassThrough.lf new file mode 100644 index 0000000000..c7ebcf6f3c --- /dev/null +++ b/test/C/src/lib/PassThrough.lf @@ -0,0 +1,9 @@ +target C; + +reactor PassThrough { + input in:int; + output out:int; + reaction(in) -> out {= + SET(out, in->value); + =} +}