Skip to content

Commit

Permalink
Merge branch 'master' into target-property-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
byeonggiljun authored Apr 1, 2024
2 parents be84fa9 + 22666f0 commit b728aef
Show file tree
Hide file tree
Showing 95 changed files with 850 additions and 1,135 deletions.
139 changes: 45 additions & 94 deletions .github/scripts/run-zephyr-tests.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#!/bin/bash
timeout=300 # 5min timeout is hopefully enough
verbose=false

# Function to recursively find all folders containing the top-level CMakeLists.txt
overall_success=true
num_successes=0
num_failures=0
failed_tests=""

# Skip tests doing file IO and tracing
skip=("FileReader" "FilePkgReader" "Tracing" "ThreadedThreaded" "CountTest" "AsyncCallback")
# Skip
skip=("FileReader" "FilePkgReader")

find_kconfig_folders() {
if [ -f "$folder/CMakeLists.txt" ]; then
Expand All @@ -20,17 +12,15 @@ find_kconfig_folders() {
echo "Skipping: $test_name"
else
echo "Running: $test_name"
if run_qemu_zephyr_test "$folder"; then
echo "Test $test_name successful"
run_qemu_zephyr_test $folder
if [ "$?" -eq 0 ]; then
echo "Test passed"
let "num_successes+=1"
else
echo "Test $test_name failed"
let "num_failures+=1"
failed_tests+="$test_name, "
overall_success=false
echo "Test failed."
exit 1
fi
fi

return
fi
for folder in "$1"/*; do
Expand All @@ -40,88 +30,55 @@ find_kconfig_folders() {
done
}

run_native_zephyr_test() {
return_val=0
pushd $1/build

rm -f res.text

timeout 60s make run | tee res.txt
result=$?

if [ $result -eq 0 ]; then
echo "Command completed within the timeout."
return_val=0
else
echo "Command terminated or timed out."
echo "Test output:"
echo "----------------------------------------------------------------"
cat res.txt
echo "----------------------------------------------------------------"
return_val=1
fi

popd
return "$return_val"




}

# Run Zephyr test until either: Timeout or finds match in output
# https://www.unix.com/shell-programming-and-scripting/171401-kill-process-if-grep-match-found.html
# Run Zephyr test until either: Timeout or finds match in output using expect
# https://spin.atomicobject.com/monitoring-stdout-with-a-timeout/
run_qemu_zephyr_test() {
success=false
pushd $1/build

rm -f /tmp/procfifo
rm -f res.text
mkfifo /tmp/procfifo

make run | tee res.txt > /tmp/procfifo &
PID=$!
SECONDS=0
while IFS= read -t $timeout line
do
if [ "$verbose" = "true" ]; then echo $line; fi

if echo "$line" | grep -q 'FATAL ERROR';
res="_res.txt"
# Run test program in background and pipe results to a file.
make run > $res &
if [ $? -ne 0 ]; then
echo "ERROR: make run failed."
exit 1
fi
pid=$!
return_val=2
wait_count=0
timeout=60
# Parse the file and match on known outputs. With timeout.
while [ "$wait_count" -le "$timeout" ]; do
sleep 1
if grep --quiet 'FATAL ERROR' "$res"
then
echo "Matched on ERROR"
echo $line
success=false
pkill -P $$
cat $res
echo "-----------------------------------------------------------------------------------------------------------"
echo "ERROR: Found 'FATAL ERROR'"
return_val=1
break
fi

if echo "$line" | grep -q '^exit';
if grep --quiet '^exit' "$res"
then
echo "Matched on exit"
success=true
pkill -P $$
break
fi

if (($SECONDS > $timeout)) ; then
echo "Timeout without freeze"
success=false
cat $res
echo "-----------------------------------------------------------------------------------------------------------"
echo "SUCCESS: Found 'exit'"
return_val=0
break
fi
done < /tmp/procfifo

return_val=0
if [ "$success" = false ]; then
echo "General Timeout"
pkill -P $$
echo "Test output:"
echo "----------------------------------------------------------------"
cat res.txt
echo "----------------------------------------------------------------"
return_val=1
((wait_count++))
done
kill $pid
if [ $? -ne 0 ]; then
echo "ERROR: Could not kill qemu process"
exit 1
fi

rm -f /tmp/procfifo
if [ "$return_val" -eq 2 ]; then
cat $res
echo "-----------------------------------------------------------------------------------------------------------"
echo "ERROR: Timed out"
fi
popd
return "$return_val"
}
Expand All @@ -137,14 +94,8 @@ cd -

# Print report
echo "================================================================================================================"

if [ "$overall_success" = false ]; then
echo "Results: FAIL"
else
echo "Results: PASS"
fi
echo "Tests passed!"
echo "Number of passes: $num_successes"
echo "Number of fails: $num_failures"
echo "Skipped tests: ${skip[@]}"

if [ "$overall_success" = false ]; then
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/c-zephyr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ jobs:
--tests org.lflang.tests.runtime.CZephyrTest.buildZephyrUnthreaded* \
--tests org.lflang.tests.runtime.CZephyrTest.buildZephyrThreaded* core:integrationTestCodeCoverageReport
./.github/scripts/run-zephyr-tests.sh test/C/src-gen
rm -r test/C/src-gen
rm -rf test/C/src-gen
- name: Run basic tests
run: |
./gradlew core:integrationTest --tests org.lflang.tests.runtime.CZephyrTest.buildBasic* core:integrationTestCodeCoverageReport
./.github/scripts/run-zephyr-tests.sh test/C/src-gen
rm -r test/C/src-gen
rm -rf test/C/src-gen
- name: Run concurrent tests
run: |
./gradlew core:integrationTest --tests org.lflang.tests.runtime.CZephyrTest.buildConcurrent* core:integrationTestCodeCoverageReport
./.github/scripts/run-zephyr-tests.sh test/C/src-gen
rm -r test/C/src-gen
rm -rf test/C/src-gen
- name: Run Zephyr board tests
run: |
./gradlew core:integrationTest --tests org.lflang.tests.runtime.CZephyrTest.buildZephyrBoards* core:integrationTestCodeCoverageReport
rm -r test/C/src-gen
rm -rf test/C/src-gen
- name: Smoke test of lf-west-template
run: |
export LFC=$(pwd)/bin/lfc-dev
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/py-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ jobs:
fetch-depth: 0
- name: Prepare build environment
uses: ./.github/actions/prepare-build-env
- name: Install RTI
uses: ./.github/actions/install-rti
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
- name: Setup Python
uses: actions/setup-python@v4
with:
Expand All @@ -49,19 +46,22 @@ jobs:
- name: Install Google API Python Client
run: pip3 install --upgrade google-api-python-client
- name: Check out specific ref of reactor-c
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: lf-lang/reactor-c
path: core/src/main/resources/lib/c/reactor-c
ref: ${{ inputs.reactor-c-ref }}
if: ${{ inputs.reactor-c-ref }}
- name: Check out specific ref of reactor-c-py
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
repository: lf-lang/reactor-c-py
path: core/src/main/resources/lib/py/reactor-c-py
ref: ${{ inputs.reactor-c-py-ref }}
if: ${{ inputs.reactor-c-py-ref }}
- name: Install RTI
uses: ./.github/actions/install-rti
if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
- name: Run Python tests
run: ./gradlew targetTest -Ptarget=Python
- name: Report to CodeCov
Expand Down
6 changes: 3 additions & 3 deletions cli/lfc/src/test/resources/org/lflang/cli/issue490.lf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# https://github.com/lf-lang/lingua-franca/issues/490
# issue is that one error ends at EOF
target Python;
main reactor R(p(3)) {
state liss(2, 3);
main reactor R(p = 3) {
state list = [2, 3];
reaction (startup) {
print(self.liss)
print(self.list)
}
}
14 changes: 7 additions & 7 deletions cli/lfc/src/test/resources/org/lflang/cli/issue490.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ lfc: error: Name of main reactor must match the file name (or be omitted).
--> %%%PATH.lf%%%:4:14
|
3 | target Python;
4 | main reactor R(p(3)) {
4 | main reactor R(p = 3) {
| ^ Name of main reactor must match the file name (or be omitted).
|
5 | state liss(2, 3);
5 | state list = [2, 3];
lfc: error: The Python target does not support reaction declarations. Please specify a reaction body.
--> %%%PATH.lf%%%:6:3
|
5 | state liss(2, 3);
5 | state list = [2, 3];
6 | reaction (startup) {
| ^^^^^^^^^^^^^^^^^^^^ The Python target does not support reaction declarations. Please specify a reaction body.
|
7 | print(self.liss)
7 | print(self.list)
lfc: error: no viable alternative at input '{'
--> %%%PATH.lf%%%:6:22
|
5 | state liss(2, 3);
5 | state list = [2, 3];
6 | reaction (startup) {
| ^ no viable alternative at input '{'
|
7 | print(self.liss)
7 | print(self.list)
lfc: error: no viable alternative at input '('
--> %%%PATH.lf%%%:7:5
|
6 | reaction (startup) {
7 | print(self.liss)
7 | print(self.list)
| ^^^^^ no viable alternative at input '('
|
8 | }
4 changes: 2 additions & 2 deletions cli/lfc/src/test/resources/org/lflang/cli/tabs.lf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
target C;

main reactor {
state foo(1);
state bar(1);
state foo = 1;
state bar = 1;
}
12 changes: 6 additions & 6 deletions cli/lfc/src/test/resources/org/lflang/cli/tabs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ lfc: error: State must have a type.
--> %%%PATH.lf%%%:4:2
|
3 | main reactor {
4 | state foo(1);
| ^^^^^^^^^^^^^ State must have a type.
4 | state foo = 1;
| ^^^^^^^^^^^^^^ State must have a type.
|
5 | state bar(1);
5 | state bar = 1;
lfc: error: State must have a type.
--> %%%PATH.lf%%%:5:2
|
4 | state foo(1);
5 | state bar(1);
| ^^^^^^^^^^^^^^^^ State must have a type.
4 | state foo = 1;
5 | state bar = 1;
| ^^^^^^^^^^^^^^^^^ State must have a type.
|
6 | }
10 changes: 5 additions & 5 deletions cli/lff/src/test/java/org/lflang/cli/LffCliTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public class LffCliTest {
List.of(
"""
target C
reactor Filter(period: int = 0, b: double[](0, 0)) {}
reactor Filter(period: int = 0, b: double[] = {0, 0}) {}
main reactor {
az_f = new Filter(
period = 100,
b = (0.229019233988375, 0.421510777305010)
b = {0.229019233988375, 0.421510777305010}
)
}
""",
Expand All @@ -128,9 +128,9 @@ reactor Filter(period: int = 0, b: double[] = {0, 0}) {
"""
target Rust
reactor Snake { // q
state grid: SnakeGrid ({= /* foo */ SnakeGrid::new(grid_side, &snake) =}); // note that this one borrows snake temporarily
state grid2: SnakeGrid ({= // baz
SnakeGrid::new(grid_side, &snake) =});
state grid: SnakeGrid = {= /* foo */ SnakeGrid::new(grid_side, &snake) =}; // note that this one borrows snake temporarily
state grid2: SnakeGrid = {= // baz
SnakeGrid::new(grid_side, &snake) =};
}
""",
"""
Expand Down
Loading

0 comments on commit b728aef

Please sign in to comment.