diff --git a/lingua-franca b/lingua-franca index 1db503eed..382804927 160000 --- a/lingua-franca +++ b/lingua-franca @@ -1 +1 @@ -Subproject commit 1db503eedc8c25133893ce1aec0bac09045ad79b +Subproject commit 382804927896e2b4abdb16880c2840a911fac882 diff --git a/test/known-good/C/src/PeriodicTask.html b/test/known-good/C/src/PeriodicTask.html new file mode 100644 index 000000000..9f40c9c69 --- /dev/null +++ b/test/known-good/C/src/PeriodicTask.html @@ -0,0 +1,937 @@ + +/** + + + + * This test ensures that level 2 reaction with a tighter deadline runs before a level 1 reaction + + + + * with a looser deadline when there is no dependency between these reactions. This is the correct + + + + * behavior of the GEDF scheduler, so the scheduler is set to GEDF_NP. + + + + + + +*/ + + + +target + + + + + +C + + + { + + + + timeout + + +: + + +200 + + + ms, + + + + scheduler + + +: + + +GEDF_NP + + +, + + + + workers + + +: + + +1 + + + +} + + + + + + + +reactor + + + + + +Periodic + + +(period: + + +time + + + + + += + + + + + +50 + + + ms, name: + + +string + + + + + += + + + + + +" + + +Unnamed + + +" + + +) { + + + + + + +timer + + + trigger( + + +0 + + +, period) + + + + + + + + + + +output + + + + + +t + + +: + + + + + +time + + + + + + + + + + +reaction + + +( + + +trigger) + + +-> + + + t { + + += + + + + instant_t start_time + + += + + + lf_time_physical_elapsed(); + + + + lf_set(t, start_time); + + + + lf_print( + + +" + + +%s started at physical time: + + +" + + + PRINTF_TIME, self + + +-> + + +name, start_time); + + + + + + += + + +} + + + +} + + + + + + + +reactor + + + + + +Probe + + +(dl: + + +time + + + + + += + + + + + +2 + + + ms, name: + + +string + + + + + += + + + + + +" + + +Unnamed + + +" + + +) { + + + + + + +input + + + + + +i + + +: + + + + + +time + + + + + + +output + + + + + +t + + +: + + + + + +time + + + + + + + + + + +reaction + + +( + + +i) + + +-> + + + t { + + += + + + + instant_t start_time + + += + + + lf_time_physical_elapsed(); + + + + lf_set(t, start_time); + + + + lf_print( + + +" + + +%s started at physical time: + + +" + + + PRINTF_TIME, self + + +-> + + +name, start_time); + + + + + + += + + +} + + +deadline + + +(dl) { + + += + + + + instant_t start_time + + += + + + lf_time_physical_elapsed(); + + + + lf_set(t, start_time); + + + + lf_print( + + +" + + +%s VIOLATED DEADLINE at physical time: + + +" + + + PRINTF_TIME, self + + +-> + + +name, start_time); + + + + + + += + + +} + + + +} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +task1 + + + + + += + + + + + +new + + + + + +Periodic + + +(period + + += + + + + + +50 + + + ms, name + + += + + +" + + +task1 + + +" + + +) + + + + + + +detector1 + + + + + += + + + + + +new + + + + + +Probe + + +(dl + + += + + + + + +50 + + + ms, name + + += + + +" + + +detector1 + + +" + + +) + + + + + + + + + + +task1 + + +. + + +t + + + + + +-> + + + + + +detector1 + + +. + + +i + + + + + + +task2 + + + + + += + + + + + +new + + + + + +Periodic + + +(period + + += + + + + + +50 + + + ms, name + + += + + +" + + +task2 + + +" + + +) + + + + + + +detector2 + + + + + += + + + + + +new + + + + + +Probe + + +(dl + + += + + + + + +25 + + + ms, name + + += + + +" + + +detector2 + + +" + + +) + + + + + + + + + + +task2 + + +. + + +t + + + + + +-> + + + + + +detector2 + + +. + + +i + + + + + + + + + + +reaction + + +( + + +task1 + + +. + + +t + + +, + + +detector2 + + +. + + +t + + +) { + + += + + + + if ( + + +task1 + + +. + + +t + + +-> + + +is_present && + + +detector2 + + +. + + +t + + +-> + + +is_present && + + +task1 + + +. + + +t + + +-> + + +value < + + +detector2 + + +. + + +t + + +-> + + +value) { + + + + lf_print_error_and_exit( + + +" + + +EDF policy violated. detector2 should execute before task1 when both are triggered. + + +" + + +); + + + + } + + + + + + += + + +} + + + +} + + + + + + diff --git a/test/known-good/C/src/PreambleInherited.html b/test/known-good/C/src/PreambleInherited.html index 6755947c6..a60e001ad 100644 --- a/test/known-good/C/src/PreambleInherited.html +++ b/test/known-good/C/src/PreambleInherited.html @@ -144,6 +144,54 @@ A { + + + + +reaction + + +( + + +startup + + +) { + + += + + + + printf( + + +" + + +FOO 2: %d + + +\n + + +" + + +, FOO); + + + + + + += + + +} + + } diff --git a/test/known-good/C/src/concurrent/ModesWithWatchdog.html b/test/known-good/C/src/concurrent/ModesWithWatchdog.html new file mode 100644 index 000000000..aed2b651c --- /dev/null +++ b/test/known-good/C/src/concurrent/ModesWithWatchdog.html @@ -0,0 +1,560 @@ + +/** + + + + * When in the Primary mode, the watchdog is sure to trigger, causing the reaction to watcher to be + + + + * executed one microstep later. Previously, after a mode transition, the microstep was hardwired to + + + + * 1, which caused a fatal error after the mode transition when the runtime tried to advance to + + + + * microstep 1 and found that it was already at microstep 1. This program tests that this is fixed. + + + + * Success is simply running to completion without error. + + + + + + +*/ + + + +target + + + + + +C + + + { + + + + keepalive + + +: + + +true + + +, + + + + timeout + + +: + + +1 + + + s + + + +} + + + + + + + +reactor + + + + + +Arbitrator + + +(timeout: + + +time + + + + + += + + + + + +100 + + + ms) { + + + + + + +input + + + + + +in1 + + +: + + + + + +double + + + + + + +input + + + + + +in2 + + +: + + + + + +double + + + + + + + + watchdog watcher(timeout) { + + += + + + lf_print( + + +" + + +watchdog timeout. + + +" + + +); + + += + + +} + + + + + + + + + + +initial + + + + + +mode + + + Primary { + + + + + + +reaction + + +( + + +in1) + + +-> + + + watcher { + + += + + + + lf_watchdog_start(watcher, + + +0 + + +); + + + + + + += + + +} + + + + + + + + + + +reaction + + +( + + +watcher) + + +-> + + + + + +reset + + +(Backup) { + + += + + + + lf_print( + + +" + + +watchdog reaction. + + +" + + +); + + + + lf_set_mode(Backup); + + + + + + += + + +} + + + + } + + + + + + + + + + +mode + + + Backup { + + + + + + +reaction + + +( + + +in2) + + +-> + + + watcher { + + += + + + + lf_watchdog_start(watcher, + + +0 + + +); + + + + + + += + + +} + + + + } + + + +} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +timer + + + t( + + +0 + + +, + + +100 + + + ms) + + + + + + + + + + +ar + + + + + += + + + + + +new + + + + + +Arbitrator + + +() + + + + + + + + + + +reaction + + +( + + +t) + + +-> + + + + + +ar + + +. + + +in1 + + +, + + +ar + + +. + + +in2 + + + { + + += + + + + lf_set( + + +ar + + +. + + +in1 + + +, + + +0.0 + + +); + + + + lf_set( + + +ar + + +. + + +in2 + + +, + + +0.0 + + +); + + + + + + += + + +} + + + +} + + + + + + diff --git a/test/known-good/C/src/concurrent/WatchdogAction.html b/test/known-good/C/src/concurrent/WatchdogAction.html new file mode 100644 index 000000000..fd364d4b4 --- /dev/null +++ b/test/known-good/C/src/concurrent/WatchdogAction.html @@ -0,0 +1,960 @@ + +/** + + + + * Test watchdog. This test starts a watchdog timer of 1500ms every 1s. Half the time, it then + + + + * sleeps after starting the watchdog so that the watchdog expires. There should be a total of two + + + + * watchdog expirations. This version uses an action instead of a reaction to the watchdog. + + + + * @author Benjamin Asch + + + + * @author Edward A. Lee + + + + + + +*/ + + + +target + + + + + +C + + + { + + + + timeout + + +: + + +11000 + + + ms + + + +} + + + + + + + +reactor + + + + + +Watcher + + +(timeout: + + +time + + + + + += + + + + + +1500 + + + ms) { + + + + + + +// Offset may reduce the likelihood of flakiness if long startup times occur. + + + + + + +timer + + + t( + + +1 + + + s, + + +1 + + + s) + + + + + + +// Period has to be smaller than watchdog timeout. Produced if the watchdog triggers. + + + + + + +output + + + + + +d + + +: + + + + + +int + + + + + + +state + + + + + +count + + +: + + + + + +int + + + + + += + + + + + +0 + + + + + + +logical + + + + + +action + + + + + +a + + + + + + + + watchdog poodle(timeout) + + +-> + + + a { + + += + + + + instant_t p + + += + + + lf_time_physical_elapsed(); + + + + lf_print( + + +" + + +******** Watchdog timed out at elapsed physical time: + + +" + + + PRINTF_TIME, p); + + + + self + + +-> + + +count + + ++ + + ++ + + +; + + + + lf_schedule(a, + + +0 + + +); + + + + + + += + + +} + + + + + + + + + + +reaction + + +( + + +t) + + +-> + + + poodle, d { + + += + + + + lf_watchdog_start(poodle, + + +0 + + +); + + + + lf_print( + + +" + + +Watchdog started at physical time + + +" + + + PRINTF_TIME, lf_time_physical_elapsed()); + + + + lf_print( + + +" + + +Will expire at + + +" + + + PRINTF_TIME, lf_time_logical_elapsed() + + ++ + + + self + + +-> + + +timeout); + + + + lf_set(d, + + +42 + + +); + + + + + + += + + +} + + + + + + + + + + +reaction + + +( + + +a) + + +-> + + + d { + + += + + + + lf_print( + + +" + + +Reaction poodle was called. + + +" + + +); + + + + lf_set(d, + + +1 + + +); + + + + + + += + + +} + + + + + + + + + + +reaction + + +( + + +shutdown + + +) + + +-> + + + poodle { + + += + + + + lf_watchdog_stop(poodle); + + + + + + +// Watchdog may expire in tests even without the sleep, but it should at least expire twice. + + + + if (self + + +-> + + +count < + + +2 + + +) { + + + + lf_print_error_and_exit( + + +" + + +Watchdog expired %d times. Expected at least 2. + + +" + + +, self + + +-> + + +count); + + + + } + + + + + + += + + +} + + + +} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +logical + + + + + +action + + + + + +a + + + + + + +state + + + + + +count + + +: + + + + + +int + + + + + += + + + + + +0 + + + + + + + + + + +w + + + + + += + + + + + +new + + + + + +Watcher + + +() + + + + + + + + + + +reaction + + +( + + +startup + + +) { + + += + + + + if (NUMBER_OF_WATCHDOGS ! + + += + + + + + +1 + + +) { + + + + lf_print_error_and_exit( + + +" + + +NUMBER_OF_WATCHDOGS was %d + + +" + + +, NUMBER_OF_WATCHDOGS); + + + + } + + + + + + += + + +} + + + + + + + + + + +reaction + + +( + + +w + + +. + + +d + + +) { + + += + + + + lf_print( + + +" + + +Watcher reactor produced an output. %d + + +" + + +, self + + +-> + + +count + + +% + + + + + +2 + + +); + + + + self + + +-> + + +count + + ++ + + ++ + + +; + + + + if (self + + +-> + + +count + + +% + + + + + +4 + + + + + += + + += + + + + + +0 + + +) { + + + + lf_print( + + +" + + +>>>>>> Taking a long time to process that output! + + +" + + +); + + + + lf_sleep(MSEC( + + +1600 + + +)); + + + + } + + + + + + += + + +} + + + + + + + + + + +reaction + + +( + + +shutdown + + +) { + + += + + + + if (self + + +-> + + +count < + + +12 + + +) { + + + + lf_print_error_and_exit( + + +" + + +Watchdog produced output %d times. Expected at least 12. + + +" + + +, self + + +-> + + +count); + + + + } + + + + + + += + + +} + + + +} + + + + + + diff --git a/test/known-good/C/src/docker/RuntimeFilesPropertyContainerized.html b/test/known-good/C/src/docker/RuntimeFilesPropertyContainerized.html new file mode 100644 index 000000000..bd3ff9354 --- /dev/null +++ b/test/known-good/C/src/docker/RuntimeFilesPropertyContainerized.html @@ -0,0 +1,478 @@ + +target + + + + + +C + + + { + + + + files + + +: + + +" + + +./RuntimeFilesPropertyContainerized.lf + + +" + + +, + + + + docker + + +: + + +true + + + +} + + + + + + + +preamble + + + { + + += + + + + + + +#include + + + + + + +#include + + + + + + +#include + + + += + + +} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +reaction + + +( + + +startup + + +) { + + += + + + + FILE + + +* + + +f + + += + + + fopen( + + +" + + +RuntimeFilesPropertyContainerized.lf + + +" + + +, + + +" + + +rb + + +" + + +); + + + + fseek(f, + + +0 + + +, SEEK_END); + + + + long fsize + + += + + + ftell(f); + + + + fseek(f, + + +0 + + +, SEEK_SET); + + + + + + + + char + + +* + + +string + + += + + + (char + + +* + + +) malloc(fsize + + ++ + + + + + +1 + + +); + + + + fread(string, fsize, + + +1 + + +, f); + + + + fclose(f); + + + + + + + + string[fsize] + + += + + + + + +0 + + +; + + + + + + + + printf( + + +" + + +file contents: + + +\n + + +%s + + +\n + + +" + + +, string); + + + + + + + + + + +// fail if the file contents are not the contents of this file + + + + char + + +* + + + expected + + += + + + + + +" + + +target C { + + +\n + + + files: + + +\" + + +./RuntimeFilesPropertyContainerized.lf + + +\" + + +, + + +\n + + + docker: true + + +\n + + +} + + +" + + +; + + + + string[strlen(expected)] + + += + + + + + +0 + + +; + + + + if (strcmp(string, expected) ! + + += + + + + + +0 + + +) { + + + + printf( + + +" + + +file contents do not match expected contents + + +\n + + +" + + +); + + + + exit( + + +1 + + +); + + + + } else { + + + + printf( + + +" + + +file contents match expected contents + + +\n + + +" + + +); + + + + } + + + + + + + + free(string); + + + + + + += + + +} + + + +} + + + + + + diff --git a/test/known-good/C/src/docker/federated/DockerOptions.html b/test/known-good/C/src/docker/federated/DockerOptions.html new file mode 100644 index 000000000..cb25dc6b5 --- /dev/null +++ b/test/known-good/C/src/docker/federated/DockerOptions.html @@ -0,0 +1,434 @@ + +target + + + + + +C + + + { + + + + logging + + +: + + +WARN + + +, + + + + timeout + + +: + + +1 + + + s, + + + + coordination + + +: + + +centralized + + +, + + + + docker + + +: { + + + + rti-image + + +: + + +" + + +rti:local + + +" + + +, + + + + pre-build-script + + +: + + +" + + +foo.sh + + +" + + +, + + + + pre-run-script + + +: + + +" + + +bar.sh + + +" + + +, + + + + post-build-script + + +: + + +" + + +baz.sh + + +" + + +, + + + + no-build + + +: + + +false + + +, + + + + env-file + + +: + + +" + + +.env + + +" + + + + }, + + + + cmake-include + + +: + + +" + + +cmake-check-environment-variable.cmake + + +" + + + +} + + + + + + + +reactor + + + + + +Hello + + + { + + + + + + +reaction + + +( + + +startup + + +) { + + += + + + + printf( + + +" + + +Hello World! + + +\n + + +" + + +); + + + + + + +// crash if env var "bar" is not set + + + + if (getenv( + + +" + + +BAR + + +" + + +) + + += + + += + + + NULL) { + + + + printf( + + +" + + +bar is not set + + +\n + + +" + + +); + + + + exit( + + +1 + + +); + + + + } + + + + printf( + + +" + + +success: bar = %s + + +\n + + +" + + +, getenv( + + +" + + +BAR + + +" + + +)); + + + + + + += + + +} + + + +} + + + + + + + +federated + + + + + +reactor + + + { + + + + + + +a + + + + + += + + + + + +new + + + + + +Hello + + +() + + + + + + +b + + + + + += + + + + + +new + + + + + +Hello + + +() + + + +} + + + + + + diff --git a/test/known-good/C/src/docker/federated/EscapedScriptName.html b/test/known-good/C/src/docker/federated/EscapedScriptName.html new file mode 100644 index 000000000..375bbabd9 --- /dev/null +++ b/test/known-good/C/src/docker/federated/EscapedScriptName.html @@ -0,0 +1,224 @@ + +target + + + + + +C + + + { + + + + logging + + +: + + +DEBUG + + +, + + + + timeout + + +: + + +1 + + + s, + + + + coordination + + +: + + +centralized + + +, + + + + docker + + +: { + + + + rti-image + + +: + + +" + + +rti:local + + +" + + +, + + + + pre-build-script + + +: + + +" + + +foo ish.sh + + +" + + + + } + + + +} + + + + + + + +reactor + + + + + +Hello + + + { + + + + + + +reaction + + +( + + +startup + + +) { + + += + + + + printf( + + +" + + +Hello World! + + +\n + + +" + + +); + + + + + + += + + +} + + + +} + + + + + + + +federated + + + + + +reactor + + + { + + + + + + +a + + + + + += + + + + + +new + + + + + +Hello + + +() + + + +} + + + + + + diff --git a/test/known-good/C/src/target/ImportedCMakeInclude.html b/test/known-good/C/src/target/ImportedCMakeInclude.html new file mode 100644 index 000000000..4dbc017b9 --- /dev/null +++ b/test/known-good/C/src/target/ImportedCMakeInclude.html @@ -0,0 +1,142 @@ + +target + + + + + +C + + + { + + + + timeout + + +: + + +1 + + + ms + + + +} + + + + + + + +import + + + + + +Foo + + + + + +from + + + + + +" + + +./CMakeInclude.lf + + +" + + + + + + + +reactor + + + + + +Bar + + + + + +extends + + + Foo { + + + +} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +r + + + + + += + + + + + +new + + + + + +Foo + + +() + + + +} + + + + + + diff --git a/test/known-good/C/src/target/InheritedAuth.html b/test/known-good/C/src/target/InheritedAuth.html new file mode 100644 index 000000000..59336f08b --- /dev/null +++ b/test/known-good/C/src/target/InheritedAuth.html @@ -0,0 +1,372 @@ + +// Test passes if it runs successfully. + + + +// Demonstrates inheritance of "auth" target property from import. + + + +// Also see: https://github.com/lf-lang/lingua-franca/issues/2326 + + + +target + + + + + +C + + + { + + + + timeout + + +: + + +1 + + + s + + + +} + + + + + + + +import + + + + + +R1 + + + + + +from + + + + + +" + + +lib/R1.lf + + +" + + + + + + + +reactor + + + + + +R0 + + + { + + + + + + +output + + + + + +out + + +: + + + + + +int + + + + + + +state + + + + + +s + + +: + + + + + +int + + + + + += + + + + + +0 + + + + + + +timer + + + t( + + +0 + + +, + + +100 + + + ms) + + + + + + + + + + +reaction + + +( + + +t) + + +-> + + + out { + + += + + + + self + + +-> + + +s + + ++ + + ++ + + + ; + + + + lf_set(out, self + + +-> + + +s); + + + + lf_print( + + +" + + +R0 is sending %d. + + +" + + +, self + + +-> + + +s); + + + + + + += + + +} + + + +} + + + + + + + +federated + + + + + +reactor + + + { + + + + + + +r1 + + + + + += + + + + + +new + + + + + +R1 + + +() + + + + + + +r0 + + + + + += + + + + + +new + + + + + +R0 + + +() + + + + + + +r0 + + +. + + +out + + + + + +-> + + + + + +r1 + + +. + + +in + + + +} + + + + + + diff --git a/test/known-good/C/src/target/lib/R1.html b/test/known-good/C/src/target/lib/R1.html new file mode 100644 index 000000000..a7638180c --- /dev/null +++ b/test/known-good/C/src/target/lib/R1.html @@ -0,0 +1,126 @@ + +target + + + + + +C + + + { + + + + auth + + +: + + +true + + + +} + + + + + + + +reactor + + + + + +R1 + + + { + + + + + + +input + + + + + +in + + +: + + + + + +int + + + + + + + + + + +reaction + + +( + + +in) { + + += + + + + lf_print( + + +" + + +R1 reacted to input %d + + +" + + +, in + + +-> + + +value); + + + + + + += + + +} + + + +} + + + + + + diff --git a/test/known-good/Cpp/src/SetZero.html b/test/known-good/Cpp/src/SetZero.html new file mode 100644 index 000000000..5394ce58c --- /dev/null +++ b/test/known-good/Cpp/src/SetZero.html @@ -0,0 +1,421 @@ + +target + + + + + +Cpp + + + + + + + +reactor + + + + + +Source + + + { + + + + + + +output + + + + + +out + + +: + + + + + +unsigned + + + + + + + + + + +reaction + + +( + + +startup + + +) + + +-> + + + out { + + += + + + + + + +out + + +. + + +set + + +( + + +0 + + +); + + + + + + += + + +} + + + +} + + + + + + + +reactor + + + + + +Sink + + + { + + + + + + +input + + + + + +in + + +: + + + + + +unsigned + + + + + + + + + + +reaction + + +( + + +startup + + +, in) { + + += + + + + if (! + + +in + + +. + + +is_present + + +() || + + +* + + +in + + +. + + +get + + +() ! + + += + + + + + +0 + + +) { + + + + + + +std + + +:: + + +cerr + + + << + + +" + + +Expected to receive 0 + + +\n + + +" + + +; + + + + exit( + + +1 + + +); + + + + } + + + + + + +std + + +:: + + +cout + + + << + + +" + + +Success! + + +\n + + +" + + +; + + + + + + += + + +} + + + +} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +source + + + + + += + + + + + +new + + + + + +Source + + +() + + + + + + +sink + + + + + += + + + + + +new + + + + + +Sink + + +() + + + + + + +source + + +. + + +out + + + + + +-> + + + + + +sink + + +. + + +in + + + +} + + + + + + diff --git a/test/known-good/Cpp/src/docker/HelloWorldContainerized.html b/test/known-good/Cpp/src/docker/HelloWorldContainerized.html new file mode 100644 index 000000000..1b0b5ab27 --- /dev/null +++ b/test/known-good/Cpp/src/docker/HelloWorldContainerized.html @@ -0,0 +1,141 @@ + +target + + + + + +Cpp + + + { + + + + logging + + +: + + +error + + +, + + +// To test generating a custom trace file name. + + + + docker + + +: + + +true + + +, + + + + build-type + + +: + + +Debug + + + +} + + + + + + + +import + + + + + +HelloWorld2 + + + + + +from + + + + + +" + + +../HelloWorld.lf + + +" + + + + + + + +main + + + + + +reactor + + + { + + + + + + +a + + + + + += + + + + + +new + + + + + +HelloWorld2 + + +() + + + +} + + + + + + diff --git a/test/known-good/Cpp/src/target/TimeExpression.html b/test/known-good/Cpp/src/target/TimeExpression.html new file mode 100644 index 000000000..0ad166c82 --- /dev/null +++ b/test/known-good/Cpp/src/target/TimeExpression.html @@ -0,0 +1,750 @@ + +target + + + + + +Cpp + + + { + + + + timeout + + +: + + +1 + + + s + + + +} + + + + + + + +public + + + + + +preamble + + + { + + += + + + + inline + + +reactor + + +:: + + +Duration + + + get_delay() { return 200ms; } + + + += + + +} + + + + + + + +reactor + + + + + +Foo + + +(foo: + + +time + + + + + += + + + { + + += + + + get_delay() + + += + + +}) { + + + + + + +timer + + + t( + + +0 + + +, foo) + + + + + + + + + + +state + + + + + +timer_triggered + + +: + + + + + +bool + + + + + += + + + + + +false + + + + + + + + + + +reaction + + +( + + +t) { + + += + + + + timer_triggered + + += + + + + + +true + + +; + + + + if (get_elapsed_logical_time() + + +% + + + 200ms ! + + += + + + + + +reactor + + +:: + + +Duration + + +:: + + +zero + + +()) { + + + + + + +std + + +:: + + +cerr + + + << + + +" + + +ERROR: timer triggered at an unexpected time + + +\n + + +" + + +; + + + + exit( + + +4 + + +); + + + + } + + + + + + += + + +} + + + + + + + + + + +reaction + + +( + + +shutdown + + +) { + + += + + + + if (!timer_triggered) { + + + + + + +std + + +:: + + +cerr + + + << + + +" + + +ERROR: timer did not trigger + + +\n + + +" + + +; + + + + exit( + + +1 + + +); + + + + } + + + + + + += + + +} + + + +} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +foo + + + + + += + + + + + +new + + + + + +Foo + + +() + + + + + + + + + + +state + + + + + +timer_triggered + + +: + + + + + +bool + + + + + += + + + + + +false + + + + + + + + + + +timer + + + t( + + +0 + + +, { + + += + + + get_delay() + + ++ + + + 200ms + + += + + +}) + + + + + + + + + + +reaction + + +( + + +t) { + + += + + + + timer_triggered + + += + + + + + +true + + +; + + + + if (get_elapsed_logical_time() + + +% + + + 400ms ! + + += + + + + + +reactor + + +:: + + +Duration + + +:: + + +zero + + +()) { + + + + + + +std + + +:: + + +cerr + + + << + + +" + + +ERROR: timer triggered at an unexpected time + + +\n + + +" + + +; + + + + exit( + + +4 + + +); + + + + } + + + + + + += + + +} + + + + + + + + + + +reaction + + +( + + +shutdown + + +) { + + += + + + + if (!timer_triggered) { + + + + + + +std + + +:: + + +cerr + + + << + + +" + + +ERROR: timer did not trigger + + +\n + + +" + + +; + + + + exit( + + +2 + + +); + + + + } + + + + + + + + + + +std + + +:: + + +cout + + + << + + +" + + +Success + + +\n + + +" + + +; + + + + + + += + + +} + + + +} + + + + + + diff --git a/test/known-good/Python/src/BankIndex.html b/test/known-good/Python/src/BankIndex.html new file mode 100644 index 000000000..10f8dcb5f --- /dev/null +++ b/test/known-good/Python/src/BankIndex.html @@ -0,0 +1,192 @@ + +target + + + + + +Python + + + + + + + +reactor + + + + + +A + + +(bank_index + + += + + +0 + + +, value + + += + + +0 + + +) { + + + + + + +reaction + + +( + + +startup + + +) + + +{= + + + + print("bank_index: {:d}, value: {:d}".format(self.bank_index, self.value)) + + + + if (self.value != 4 - self.bank_index): + + + + sys.stderr.write("ERROR: Expected value to be 4 - bank_index.\n") + + + + exit(1) + + + + + + +=} + + + +} + + + + + + + +main + + + + + +reactor + + +(table + + += + + + [ + + +4 + + +, + + +3 + + +, + + +2 + + +, + + +1 + + +]) { + + + + + + +a + + + + + += + + + + + +new + + +[ + + +4 + + +] A(value + + += + + + + + +{= + + + self.table[bank_index] + + +=} + + +) + + + +} + + + + + + diff --git a/test/known-good/Python/src/PreambleInherited.html b/test/known-good/Python/src/PreambleInherited.html new file mode 100644 index 000000000..013edb0d1 --- /dev/null +++ b/test/known-good/Python/src/PreambleInherited.html @@ -0,0 +1,169 @@ + +target + + + + + +Python + + + + + + + +reactor + + + + + +Base + + + { + + + + + + +preamble + + + + + +{= + + + + def initiation(self): + + + + print("Hello World\n") + + + + + + +=} + + + +} + + + + + + + +reactor + + + + + +Extended + + + + + +extends + + + Base { + + + + + + +reaction + + +( + + +startup + + +) + + +{= + + + + self.initiation() + + + + + + +=} + + + +} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +e + + + + + += + + + + + +new + + + + + +Extended + + +() + + + +} + + + + + + diff --git a/test/known-good/Python/src/PythonPaths.html b/test/known-good/Python/src/PythonPaths.html new file mode 100644 index 000000000..b1adeb71b --- /dev/null +++ b/test/known-good/Python/src/PythonPaths.html @@ -0,0 +1,194 @@ + +/** + + + + * This tests the functions lf.source_directory() and lf.package_directory(). Success is just + + + + * compiling and running without error. The test prints the contents of this file twice. + + + + + + +*/ + + + +target + + + + + +Python + + + + + + + +preamble + + + + + +{= + + + + + + +import + + + os + + + +=} + + + + + + + +main + + + + + +reactor + + + { + + + + + + +state + + + + + +source_path + + + + + += + + + + + +{= + + + os.path.join(lf.source_directory(), "PythonPaths.lf") + + +=} + + + + + + +state + + + + + +package_path + + + + + += + + + + + +{= + + + os.path.join(lf.package_directory(), "src", "PythonPaths.lf") + + +=} + + + + + + + + + + +reaction + + +( + + +startup + + +) + + +{= + + + + with open(self.source_path, "r") as file: + + + + print(file.read()); + + + + print("----------------"); + + + + with open(self.package_path, "r") as file: + + + + print(file.read()); + + + + + + +=} + + + +} + + + + + + diff --git a/test/known-good/Python/src/docker/DockerComposeConfig.html b/test/known-good/Python/src/docker/DockerComposeConfig.html new file mode 100644 index 000000000..5caabbccc --- /dev/null +++ b/test/known-good/Python/src/docker/DockerComposeConfig.html @@ -0,0 +1,570 @@ + +target + + + + + +Python + + + { + + + + coordination + + +: + + +decentralized + + +, + + + + docker + + +: { + + + + docker-compose-override + + +: + + +" + + +./DockerComposeConfig.docker.yml + + +" + + +, + + + + rti-image + + +: + + +" + + +rti:local + + +" + + + + } + + + +} + + + + + + + +reactor + + + + + +Client + + +(STP_offset + + += + + + + + +2 + + + s) { + + + + + + +input + + + + + +server_message + + + + + + +output + + + + + +client_message + + + + + + + + + + +reaction + + +( + + +startup + + +) + + +{= + + + + print("Client Startup!") + + + + + + +=} + + + + + + + + + + +reaction + + +(server_message) + + +-> + + + client_message + + +{= + + + + val = server_message.value + + + + val += 1 + + + + print("client:", val) + + + + if val==49: + + + + print("client done") + + + + request_stop() + + + + if val<49: + + + + client_message.set(val) + + + + + + +=} + + + +} + + + + + + + +reactor + + + + + +Server + + +(STP_offset + + += + + + + + +2 + + + s) { + + + + + + +output + + + + + +server_message + + + + + + +input + + + + + +client_message + + + + + + + + + + +reaction + + +( + + +startup + + +) + + +-> + + + server_message + + +{= + + + + print("Server Startup!") + + + + server_message.set(0) + + + + + + +=} + + + + + + + + + + +reaction + + +(client_message) + + +-> + + + server_message + + +{= + + + + val = client_message.value + + + + val += 1 + + + + print("server:", val) + + + + if val==48: + + + + print("server done") + + + + server_message.set(val) + + + + request_stop() + + + + if val<48: + + + + server_message.set(val) + + + + + + +=} + + + +} + + + + + + + +federated + + + + + +reactor + + +(STP_offset + + += + + + + + +2 + + + s) { + + + + + + +client + + + + + += + + + + + +new + + + + + +Client + + +() + + + + + + +server + + + + + += + + + + + +new + + + + + +Server + + +() + + + + + + +server + + +. + + +server_message + + + + + +-> + + + + + +client + + +. + + +server_message + + + + + +after + + + + + +100 + + + ms + + + + + + +client + + +. + + +client_message + + + + + +-> + + + + + +server + + +. + + +client_message + + + +} + + + + + + diff --git a/test/known-good/Python/src/docker/FilesPropertyContainerized.html b/test/known-good/Python/src/docker/FilesPropertyContainerized.html index d8a91ba53..5d6eb8696 100644 --- a/test/known-good/Python/src/docker/FilesPropertyContainerized.html +++ b/test/known-good/Python/src/docker/FilesPropertyContainerized.html @@ -34,13 +34,30 @@ docker +: { + + + + rti-image + + : - -true + +" + + +rti:local + + +" + } + + + } diff --git a/test/known-good/Python/src/docker/HelloWorldContainerized.html b/test/known-good/Python/src/docker/HelloWorldContainerized.html index e687e2742..0bb267fef 100644 --- a/test/known-good/Python/src/docker/HelloWorldContainerized.html +++ b/test/known-good/Python/src/docker/HelloWorldContainerized.html @@ -15,13 +15,30 @@ docker +: { + + + + rti-image + + : - -true + +" + + +rti:local + + +" + } + + + } diff --git a/test/known-good/Python/src/docker/PingPongContainerized.html b/test/known-good/Python/src/docker/PingPongContainerized.html index 8dff31135..30fee13ea 100644 --- a/test/known-good/Python/src/docker/PingPongContainerized.html +++ b/test/known-good/Python/src/docker/PingPongContainerized.html @@ -107,13 +107,30 @@ docker +: { + + + + rti-image + + : - -true + +" + + +rti:local + + +" + } + + + } diff --git a/test/known-good/Python/src/docker/federated/DistributedCountContainerized.html b/test/known-good/Python/src/docker/federated/DistributedCountContainerized.html index 4005a27e3..7572cea50 100644 --- a/test/known-good/Python/src/docker/federated/DistributedCountContainerized.html +++ b/test/known-good/Python/src/docker/federated/DistributedCountContainerized.html @@ -87,13 +87,30 @@ docker +: { + + + + rti-image + + : - -true + +" + + +rti:local + + +" + } + + + } diff --git a/test/known-good/Python/src/docker/federated/DistributedMultiportContainerized.html b/test/known-good/Python/src/docker/federated/DistributedMultiportContainerized.html index 399a2c043..47c22fc2e 100644 --- a/test/known-good/Python/src/docker/federated/DistributedMultiportContainerized.html +++ b/test/known-good/Python/src/docker/federated/DistributedMultiportContainerized.html @@ -51,13 +51,30 @@ docker +: { + + + + rti-image + + : - -true + +" + + +rti:local + + +" + } + + + } diff --git a/test/known-good/Python/src/docker/federated/DistributedSendClassContainerized.html b/test/known-good/Python/src/docker/federated/DistributedSendClassContainerized.html index c7e22a614..eba41ee4c 100644 --- a/test/known-good/Python/src/docker/federated/DistributedSendClassContainerized.html +++ b/test/known-good/Python/src/docker/federated/DistributedSendClassContainerized.html @@ -28,13 +28,30 @@ docker +: { + + + + rti-image + + : - -true + +" + + +rti:local + + +" + } + + + } diff --git a/test/known-good/Python/src/docker/federated/DistributedDoublePortContainerized.html b/test/known-good/Python/src/docker/federated/failing/DistributedDoublePortContainerized.html similarity index 100% rename from test/known-good/Python/src/docker/federated/DistributedDoublePortContainerized.html rename to test/known-good/Python/src/docker/federated/failing/DistributedDoublePortContainerized.html diff --git a/test/known-good/Python/src/docker/federated/DistributedStopDecentralizedContainerized.html b/test/known-good/Python/src/docker/federated/failing/DistributedStopDecentralizedContainerized.html similarity index 100% rename from test/known-good/Python/src/docker/federated/DistributedStopDecentralizedContainerized.html rename to test/known-good/Python/src/docker/federated/failing/DistributedStopDecentralizedContainerized.html diff --git a/test/known-good/Python/src/federated/Dataflow.html b/test/known-good/Python/src/federated/Dataflow.html new file mode 100644 index 000000000..9a49c8a37 --- /dev/null +++ b/test/known-good/Python/src/federated/Dataflow.html @@ -0,0 +1,759 @@ + +target + + + + + +Python + + + { + + + + coordination + + +: + + +decentralized + + + + + +# logging: debug + + + +} + + + + + + + +preamble + + + + + +{= + + + + + + +import + + + time + + + +=} + + + + + + + +reactor + + + + + +Client + + +(STP_offset + + += + + + + + +{= + + + FOREVER + + +=} + + +) { + + + + + + +input + + + + + +server_message + + + + + + +output + + + + + +client_message + + + + + + + + + + +reaction + + +( + + +startup + + +) + + +{= + + + + print("Client Startup!") + + + + + + +=} + + + + + + + + + + +reaction + + +(server_message) + + +-> + + + client_message + + +{= + + + + val = server_message.value + + + + time.sleep(0.1) + + + + val += 1 + + + + print("client:", val) + + + + if val==49: + + + + print("client done") + + + + request_stop() + + + + if val<49: + + + + client_message.set(val) + + + + + + +=} + + + + + +STP + + +( + + +10 + + + s) + + +{= + + + + print("Client STP Violated!") + + + + exit(1) + + + + + + +=} + + + +} + + + + + + + +reactor + + + + + +Server + + +(STP_offset + + += + + + + + +{= + + + FOREVER + + +=} + + +) { + + + + + + +output + + + + + +server_message + + + + + + +input + + + + + +client_message1 + + + + + + +input + + + + + +client_message2 + + + + + + + + + + +reaction + + +( + + +startup + + +) + + +-> + + + server_message + + +{= + + + + print("Server Startup!") + + + + server_message.set(0) + + + + + + +=} + + + + + + + + + + +reaction + + +(client_message1, client_message2) + + +-> + + + server_message + + +{= + + + + val = max(client_message1.value, client_message2.value) + + + + time.sleep(0.1) + + + + val += 1 + + + + print("server:", val) + + + + if val==48: + + + + print("server done") + + + + server_message.set(val) + + + + request_stop() + + + + if val<48: + + + + server_message.set(val) + + + + + + +=} + + + + + +STP + + +( + + +10 + + + s) + + +{= + + + + print("Server STP Violated!") + + + + exit(1) + + + + + + +=} + + + +} + + + + + + + +federated + + + + + +reactor + + +(STP_offset + + += + + + + + +{= + + + FOREVER + + +=} + + +) { + + + + + + +client1 + + + + + += + + + + + +new + + + + + +Client + + +() + + + + + + +client2 + + + + + += + + + + + +new + + + + + +Client + + +() + + + + + + +server + + + + + += + + + + + +new + + + + + +Server + + +() + + + + + + +server + + +. + + +server_message + + + + + +-> + + + + + +client1 + + +. + + +server_message + + + + + + +client1 + + +. + + +client_message + + + + + +-> + + + + + +server + + +. + + +client_message1 + + + + + +after + + + + + +0 + + + + + + +server + + +. + + +server_message + + + + + +-> + + + + + +client2 + + +. + + +server_message + + + + + + +client2 + + +. + + +client_message + + + + + +-> + + + + + +server + + +. + + +client_message2 + + + + + +after + + + + + +0 + + + +} + + + + + + diff --git a/test/known-good/Python/src/serialization/CustomSerializer.html b/test/known-good/Python/src/serialization/CustomSerializer.html new file mode 100644 index 000000000..7034ec7f9 --- /dev/null +++ b/test/known-good/Python/src/serialization/CustomSerializer.html @@ -0,0 +1,614 @@ + +# To run this test, the `pickle_serializer` package must be installed in the Python environment. + + + +# Run `pip3 install -e ./test/Python/src/serialization/pickle_serializer` in the project root directory to install the pickle_serializer. + + + +target + + + + + +Python + + + { + + + + coordination + + +: + + +decentralized + + + +} + + + + + + + +preamble + + + + + +{= + + + + os.system("pip install ./src/serialization/pickle_serializer/ --user") + + + +=} + + + + + + + +reactor + + + + + +Client + + + { + + + + + + +input + + + + + +server_message + + + + + + +output + + + + + +client_message + + + + + + +state + + + + + +count + + + + + + + + + + +reaction + + +( + + +startup + + +) + + +{= + + + + self.count = 0 + + + + print("Client Startup!") + + + + + + +=} + + + + + + + + + + +reaction + + +(server_message) + + +-> + + + client_message + + +{= + + + + val = server_message.value + + + + if val != self.count: + + + + print("client: out of order", val, self.count) + + + + exit(1) + + + + self.count+=2 + + + + val += 1 + + + + print("client:", val) + + + + if val==23: + + + + print("client done") + + + + request_stop() + + + + if val<23: + + + + client_message.set(val) + + + + + + +=} + + + +} + + + + + + + +reactor + + + + + +Server + + + { + + + + + + +output + + + + + +server_message + + + + + + +input + + + + + +client_message + + + + + + +state + + + + + +count + + + + + + + + + + +reaction + + +( + + +startup + + +) + + +-> + + + server_message + + +{= + + + + self.count = 1 + + + + print("Server Startup!") + + + + server_message.set(0) + + + + + + +=} + + + + + + + + + + +reaction + + +(client_message) + + +-> + + + server_message + + +{= + + + + val = client_message.value + + + + if val != self.count: + + + + print("server: out of order", val, self.count) + + + + exit(1) + + + + self.count+=2 + + + + val += 1 + + + + print("server:", val) + + + + if val==22: + + + + print("server done") + + + + server_message.set(val) + + + + request_stop() + + + + if val<22: + + + + server_message.set(val) + + + + + + +=} + + + +} + + + + + + + +federated + + + + + +reactor + + + { + + + + + + +client + + + + + += + + + + + +new + + + + + +Client + + +() + + + + + + +server + + + + + += + + + + + +new + + + + + +Server + + +() + + + + + + +server + + +. + + +server_message + + + + + +-> + + + + + +client + + +. + + +server_message + + + + + +after + + + + + +100 + + + ms + + +serializer + + + + + +" + + +pickle_serializer + + +" + + + + + + +client + + +. + + +client_message + + + + + +-> + + + + + +server + + +. + + +client_message + + + + + +serializer + + + + + +" + + +pickle_serializer + + +" + + + +} + + + + + +