Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ROS2 serialization tests #1012

Merged
merged 49 commits into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3a83ef0
Added ROS2 serialization tests
Soroosh129 Mar 9, 2022
3a284f0
Comments only
Soroosh129 Mar 9, 2022
6869ffe
Changed ROS2 tooling version
Soroosh129 Mar 9, 2022
440d610
Removed extra dependencies
Soroosh129 Mar 9, 2022
0cc96b9
Added a skeleton for serialization tests
Soroosh129 Mar 9, 2022
e0d90ce
Hack to run all serialization tests in a separate workflow
Soroosh129 Mar 9, 2022
4f3cd59
Added runs-on
Soroosh129 Mar 9, 2022
5f0a0a1
Updated workflow a bit
Soroosh129 Mar 9, 2022
04633f3
Added back on
Soroosh129 Mar 9, 2022
6b71804
More streamlining
Soroosh129 Mar 9, 2022
f36a967
Removed serialization test from AbstractTest
Soroosh129 Mar 9, 2022
a2fd905
Removed ROS 2 as a dependency
Soroosh129 Mar 9, 2022
44c042e
Added back coreutils
Soroosh129 Mar 9, 2022
0f3ed1a
Enable universe
Soroosh129 Mar 9, 2022
a05329d
Remove line break
Soroosh129 Mar 9, 2022
d325eb3
Adding missing dependency in the ROS docker image
Soroosh129 Mar 9, 2022
c2d3157
Trying ros:latest Docker image
Soroosh129 Mar 9, 2022
0c07de0
Added apt-get update
Soroosh129 Mar 9, 2022
9806255
Small adjustments
Soroosh129 Mar 9, 2022
f205b7d
Added back source for ROS
Soroosh129 Mar 9, 2022
2d5e584
Install rclcpp
Soroosh129 Mar 9, 2022
81b4654
No quotes
Soroosh129 Mar 9, 2022
389d2f1
Trying entrypoint
Soroosh129 Mar 9, 2022
1cbb89f
Modifying bashrc
Soroosh129 Mar 9, 2022
51092d0
Another try
Soroosh129 Mar 9, 2022
d3f5d3d
Adding debug messages to see if env is set up properly
Soroosh129 Mar 9, 2022
2551c58
Directly source ROS
Soroosh129 Mar 9, 2022
37cf18d
Trying to see if multiple run is the culprit
Soroosh129 Mar 9, 2022
7fabf64
Trying again
Soroosh129 Mar 9, 2022
a0b1f2d
Trying again
Soroosh129 Mar 9, 2022
4c26cd2
Installing git
Soroosh129 Mar 9, 2022
6898e03
Another try
Soroosh129 Mar 9, 2022
c327352
Install ROS 2 natively
Soroosh129 Mar 9, 2022
1086a81
Cleanup
Soroosh129 Mar 9, 2022
3aa5164
Turn test to actual tests
Soroosh129 Mar 9, 2022
677ee9a
Exclude SERIALIZATION from 4 thread tests
Soroosh129 Mar 9, 2022
427f097
Exclude SERIALIZATION from more places
Soroosh129 Mar 9, 2022
2653dad
Apply suggestions from code review
Soroosh129 Mar 11, 2022
3eacd7f
Merge remote-tracking branch 'origin/master' into ros2-ccpp-tests
Soroosh129 Mar 11, 2022
f1e8f5b
Removed `cmake: true`
Soroosh129 Mar 11, 2022
69cce38
Cleaned up imports
Soroosh129 Mar 11, 2022
e69784a
Added back removed code that is needed for ROS serialization to work
Soroosh129 Mar 11, 2022
b740c85
Added carriage return
Soroosh129 Mar 11, 2022
f711b9e
Revert "Added carriage return"
Soroosh129 Mar 11, 2022
c73f76e
Added a FIXME (@petervdonovan could you please help?)
Soroosh129 Mar 11, 2022
38cfb5a
Address FIXME.
petervdonovan Mar 11, 2022
844a05e
Update org.lflang.tests/src/org/lflang/tests/serialization/Serializat…
Soroosh129 Mar 12, 2022
e6f3ff4
Added newline
Soroosh129 Mar 12, 2022
1773dc9
Moved supportsSingleThreadedExecution
Soroosh129 Mar 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/c-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,16 @@ jobs:
path: org.lflang/src/lib/c/reactor-c
ref: ${{ inputs.runtime-ref }}
if: ${{ inputs.runtime-ref }}
- name: Install dependencies Ubuntu
run: sudo apt-get install libprotobuf-c-dev protobuf-c-compiler protobuf-compiler libprotobuf-dev
if: ${{ runner.os == 'Linux' }}
- name: Install dependencies OS X
run: |
brew install protobuf
brew install protobuf-c
brew install coreutils
if: ${{ runner.os == 'macOS' }}
- name: Install RTI
uses: ./.github/actions/install-rti
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
- name: Build RTI docker image
uses: ./.github/actions/build-rti-docker
if: ${{ runner.os == 'Linux' }}
if: ${{ runner.os == 'Linux' }}
- name: Perform tests for C target with default scheduler
run: |
./gradlew test --tests org.lflang.tests.runtime.CTest.* --tests org.lflang.tests.lsp.LspTests.lspWithDependenciesTestC
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:

# Run the C integration tests.
c-tests:
uses: lf-lang/lingua-franca/.github/workflows/c-tests.yml@master
uses: lf-lang/lingua-franca/.github/workflows/c-tests.yml@ros2-ccpp-tests
needs: cancel

# Run the CCpp integration tests.
Expand Down Expand Up @@ -102,4 +102,9 @@ jobs:
ts-tests:
uses: lf-lang/lingua-franca/.github/workflows/ts-tests.yml@master
needs: cancel

# Run the serialization tests
serialization-tests:
uses: lf-lang/lingua-franca/.github/workflows/serialization-tests.yml@ros2-ccpp-tests
needs: cancel

4 changes: 0 additions & 4 deletions .github/workflows/py-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ jobs:
java-version: 11
- name: Setup Python
uses: actions/setup-python@v2
- name: Install dependencies Ubuntu
run: sudo apt-get install libprotobuf-dev protobuf-compiler
if: ${{ runner.os == 'Linux' }}
- name: Install dependencies OS X
run: |
brew install protobuf
brew install coreutils
if: ${{ runner.os == 'macOS' }}
- name: Install Google API Python Client
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/serialization-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Serialization tests

on:
workflow_call:
inputs:
compiler-ref:
required: false
type: string

jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Setup Java JDK
uses: actions/setup-java@v1.4.3
with:
java-version: 11
- name: Check out lingua-franca repository
uses: actions/checkout@v2
with:
repository: lf-lang/lingua-franca
submodules: true
ref: ${{ inputs.compiler-ref }}
- name: Setup ROS2
uses: ros-tooling/setup-ros@0.2.2
with:
required-ros-distributions: rolling
- name: Install Protobuf Ubuntu
run: |
sudo apt-get update
sudo apt-get install -y libprotobuf-c-dev protobuf-c-compiler protobuf-compiler libprotobuf-dev
- name: Run serialization tests;
run: |
source /opt/ros/*/setup.bash
./gradlew test --tests org.lflang.tests.serialization.SerializationTest.*
- name: Report to CodeCov
uses: codecov/codecov-action@v2.1.0
with:
file: org.lflang.tests/build/reports/xml/jacoco
fail_ci_if_error: false
verbose: true
if: ${{ !inputs.runtime-ref }} # i.e., if this is part of the main repo's CI
4 changes: 0 additions & 4 deletions .github/workflows/ts-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ jobs:
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('org.lflang/src/lib/ts/package.json') }}
- name: Install Dependencies Ubuntu
run: sudo apt-get install libprotobuf-dev protobuf-compiler
if: ${{ runner.os == 'Linux' }}
- name: Install Dependencies OS X
run: |
brew install protobuf
brew install coreutils
if: ${{ runner.os == 'macOS' }}
- name: Check out lingua-franca repository
Expand Down
3 changes: 2 additions & 1 deletion org.lflang.tests/src/org/lflang/tests/Configurators.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ public static boolean compatibleWithThreadingOff(TestCategory category) {
// CONCURRENT, FEDERATED, EXAMPLE, DOCKER_FEDERATED, DOCKER
// are not compatible with single-threaded execution.
boolean excluded = category == TestCategory.CONCURRENT
|| category == TestCategory.SERIALIZATION
|| category == TestCategory.FEDERATED
|| category == TestCategory.EXAMPLE
|| category == TestCategory.DOCKER_FEDERATED
|| category == TestCategory.DOCKER;

// SERIALIZATION and TARGET tests are excluded on Windows.
excluded |= TestBase.isWindows() && (category == TestCategory.SERIALIZATION || category == TestCategory.TARGET);
excluded |= TestBase.isWindows() && (category == TestCategory.TARGET);
return !excluded;
}
}
15 changes: 0 additions & 15 deletions org.lflang.tests/src/org/lflang/tests/RuntimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ protected RuntimeTest(Target target) {
protected RuntimeTest(List<Target> targets) {
super(targets);
}

/**
* Whether to enable {@link #runWithThreadingOff()}.
*/
protected boolean supportsSingleThreadedExecution() {
return false;
}

/**
* Whether to enable {@link #runFederatedTests()}.
Expand Down Expand Up @@ -105,14 +98,6 @@ public void runTypeParameterTests() {
TestLevel.EXECUTION, false);
}


@Test
public void runSerializationTests() {
runTestsForTargets(Message.DESC_SERIALIZATION,
TestCategory.SERIALIZATION::equals, Configurators::noChanges,
TestLevel.EXECUTION, false);
}

@Test
public void runAsFederated() {
Assumptions.assumeTrue(supportsFederatedExecution(), Message.NO_FEDERATION_SUPPORT);
Expand Down
7 changes: 7 additions & 0 deletions org.lflang.tests/src/org/lflang/tests/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ protected void runTestsFor(List<Target> subset,
runTestsAndPrintResults(target, selected, configurator, level, copy);
}
}

/**
* Whether to enable {@link #runWithThreadingOff()}.
*/
protected boolean supportsSingleThreadedExecution() {
return false;
}

/**
* Determine whether the current platform is Windows.
Expand Down
2 changes: 1 addition & 1 deletion org.lflang.tests/src/org/lflang/tests/lsp/LspTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class LspTests {
private static final Random RANDOM = new Random(2101);
/** The test categories that should be excluded from LSP tests. */
private static final TestCategory[] EXCLUDED_CATEGORIES = {
TestCategory.EXAMPLE, TestCategory.DOCKER, TestCategory.DOCKER_FEDERATED
TestCategory.SERIALIZATION, TestCategory.EXAMPLE, TestCategory.DOCKER, TestCategory.DOCKER_FEDERATED
};
private static final Predicate<List<Diagnostic>> NOT_SUPPORTED = diagnosticsHaveKeyword("supported");
private static final Predicate<List<Diagnostic>> MISSING_DEPENDENCY = diagnosticsHaveKeyword("libprotoc")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private static boolean isExcludedFromCCpp(TestCategory category) {
// be tested when compileExamples is
// run.
boolean excluded = category == TestCategory.EXAMPLE;
excluded |= category == TestCategory.SERIALIZATION;
excluded |= isWindows() && category == TestCategory.DOCKER_FEDERATED;
excluded |= isMac() && (category == TestCategory.DOCKER_FEDERATED || category == TestCategory.DOCKER);
return !excluded;
Expand Down
7 changes: 0 additions & 7 deletions org.lflang.tests/src/org/lflang/tests/runtime/CTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ public void runWithThreadingOff() {
super.runWithThreadingOff();
}

@Test
@Override
public void runSerializationTests() {
Assumptions.assumeFalse(isWindows(), Message.NO_WINDOWS_SUPPORT);
super.runSerializationTests();
}

@Test
@Disabled("TODO only 27/96 tests pass")
@Override
Expand Down
6 changes: 0 additions & 6 deletions org.lflang.tests/src/org/lflang/tests/runtime/CppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ public void runTargetSpecificTests() {
public void runMultiportTests() {
super.runMultiportTests();
}

@Test
@Override
public void runSerializationTests() {
super.runSerializationTests();
}

@Test
@Override
Expand Down
7 changes: 0 additions & 7 deletions org.lflang.tests/src/org/lflang/tests/runtime/PythonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ public void runTargetSpecificTests() {
public void runMultiportTests() {
super.runMultiportTests();
}

@Test
@Override
public void runSerializationTests() {
Assumptions.assumeFalse(isWindows(), Message.NO_WINDOWS_SUPPORT);
super.runSerializationTests();
}

@Test
@Disabled("TODO")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.lflang.tests.runtime;

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.lflang.Target;
import org.lflang.tests.RuntimeTest;
Expand Down Expand Up @@ -44,13 +43,6 @@ public void runMultiportTests() {
super.runMultiportTests();
}

@Test
@Override
public void runSerializationTests() {
Assumptions.assumeFalse(isWindows(), Message.NO_WINDOWS_SUPPORT);
super.runSerializationTests();
}

@Test
@Override
public void runConcurrentTests() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.lflang.tests.serialization;

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.lflang.Target;
import org.lflang.tests.Configurators;
import org.lflang.tests.TestBase;
import org.lflang.tests.TestRegistry.TestCategory;

public class SerializationTest extends TestBase {

protected SerializationTest() {
super(Target.ALL);
}

@Test
public void runSerializationTestsWithThreadingOff() {
Assumptions.assumeTrue(supportsSingleThreadedExecution(), Message.NO_SINGLE_THREADED_SUPPORT);
runTestsForTargets(Message.DESC_SERIALIZATION,
TestCategory.SERIALIZATION::equals, Configurators::disableThreading,
TestLevel.EXECUTION, false);
}

@Test
public void runSerializationTests() {
Assumptions.assumeFalse(isWindows(), Message.NO_WINDOWS_SUPPORT);
runTestsForTargets(Message.DESC_SERIALIZATION,
TestCategory.SERIALIZATION::equals, Configurators::noChanges,
TestLevel.EXECUTION, false);
}
}
12 changes: 6 additions & 6 deletions org.lflang/src/org/lflang/generator/CodeBuilder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.lflang.generator;

import java.nio.file.Path;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
Expand All @@ -10,6 +11,7 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
import org.lflang.lf.Code;
import org.lflang.util.FileUtil;

/**
* Helper class for printing code with indentation.
Expand Down Expand Up @@ -202,12 +204,10 @@ public void unindent() {
* Write the text to a file.
* @param path The file to write the code to.
*/
public void writeToFile(String path) throws IOException {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(path))) {
for (int i = 0; i < code.length(); i++) {
writer.write(code.charAt(i));
}
}
public CodeMap writeToFile(String path) throws IOException {
CodeMap ret = CodeMap.fromGeneratedCode(code.toString());
FileUtil.writeToFile(ret.getGeneratedCode(), Path.of(path), true);
return ret;
}

////////////////////////////////////////////
Expand Down
7 changes: 6 additions & 1 deletion org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ class CCmakeGenerator {
* @param CppMode Indicate if the compilation should happen in C++ mode
* @param hasMain Indicate if the .lf file has a main reactor or not. If not,
* a library target will be created instead of an executable.
* @param cMakeExtras CMake-specific code that should be appended to the CMakeLists.txt.
* @return The content of the CMakeLists.txt.
*/
CodeBuilder generateCMakeCode(
List<String> sources,
String executableName,
ErrorReporter errorReporter,
boolean CppMode,
boolean hasMain) {
boolean hasMain,
String cMakeExtras) {
CodeBuilder cMakeCode = new CodeBuilder();

List<String> additionalSources = new ArrayList<String>();
Expand Down Expand Up @@ -240,6 +242,9 @@ CodeBuilder generateCMakeCode(
}
cMakeCode.newLine();

cMakeCode.pr(cMakeExtras);
cMakeCode.newLine();

return cMakeCode;
}
}
8 changes: 6 additions & 2 deletions org.lflang/src/org/lflang/generator/c/CGenerator.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ class CGenerator extends GeneratorBase {
// Perform distinct code generation into distinct files for each federate.
val baseFilename = topLevelName

// Copy the code generated so far.
var commonCode = new CodeBuilder(code);

// Keep a separate file config for each federate
val oldFileConfig = fileConfig;
val numOfCompileThreads = Math.min(6,
Expand Down Expand Up @@ -515,7 +518,7 @@ class CGenerator extends GeneratorBase {
copyUserFiles(this.targetConfig, this.fileConfig);

// Clear out previously generated code.
code = new CodeBuilder()
code = new CodeBuilder(commonCode)
initializeTriggerObjects = new CodeBuilder()

// Enable clock synchronization if the federate
Expand Down Expand Up @@ -777,7 +780,8 @@ class CGenerator extends GeneratorBase {
topLevelName,
errorReporter,
CCppMode,
mainDef !== null
mainDef !== null,
cMakeExtras
)
cmakeCode.writeToFile(cmakeFile)
}
Expand Down
Loading