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

Add Renode-based tests of Arduino examples #61

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,22 @@ jobs:
name: Arduino CLI Build
steps:
- uses: actions/checkout@v2

- name: Test
run: |
./scripts/install_arduino_cli.sh
./scripts/test_arduino_library.sh "${PWD}"

- name: Apply serial patch on tflite-micro
run: |
sed --in-place '/#define DEBUG_SERIAL_OBJECT/s/(Serial)/(Serial1)/' src/tensorflow/lite/micro/system_setup.cpp

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@advaitjain this is due to a limitation in Renode. Right now we do not support the USB output, but it is already implemented. We need to review it and release. So we treat this as a temporary workaround.


- name: Build patched binaries
run: |
./scripts/test_arduino_library.sh "${PWD}"

- name: Test patched builds in Renode
uses: antmicro/[email protected]
with:
renode-version: '1.12.0+20210914gitc77eea21'
tests-to-run: 'examples/**/*.robot'
32 changes: 32 additions & 0 deletions examples/hello_world/hello_world.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
*** Settings ***
Suite Setup Setup
Suite Teardown Teardown
Test Setup Reset Emulation
Test Teardown Test Teardown
Resource ${RENODEKEYWORDS}

*** Variables ***
${UART} sysbus.uart0

*** Keywords ***
Create Machine
Execute Command mach create
Execute Command machine LoadPlatformDescription @platforms/boards/arduino_nano_33_ble.repl

Execute Command sysbus LoadELF @${CURDIR}/output/hello_world.ino.elf

*** Test Cases ***
Should Print Brightness Sequence
Create Machine
Create Terminal Tester ${UART}

Execute Command machine EnableProfiler @${CURDIR}/hello_world.dump
Start Emulation

Wait For Line On Uart 127
Wait For Line On Uart 260
Wait For Line On Uart 205
Wait For Line On Uart 195
Wait For Line On Uart 10
Wait For Line On Uart 1
Wait For Line On Uart 100
39 changes: 39 additions & 0 deletions examples/magic_wand/magic_wand.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
*** Settings ***
Suite Setup Setup
Suite Teardown Teardown
Test Setup Reset Emulation
Test Teardown Test Teardown
Resource ${RENODEKEYWORDS}

*** Variables ***
${UART} sysbus.uart0

*** Keywords ***
Create Machine
Execute Command mach create
Execute Command machine LoadPlatformDescription @platforms/boards/arduino_nano_33_ble.repl

Execute Command sysbus LoadELF @${CURDIR}/output/magic_wand.ino.elf

*** Test Cases ***
Should Detect RING Motion
Create Machine
Create Terminal Tester ${UART}

Execute Command sysbus.twi0.lsm9ds1_imu FeedAccelerationSample @${CURDIR}/test_files/circle_rotated.data

Execute Command machine EnableProfiler "${CURDIR}/magic_wand_ring.dump"
Start Emulation
Wait For Line On Uart Magic starts
Wait For Line On Uart RING:

Should Detect SLOPE Motion
Create Machine
Create Terminal Tester ${UART}

Execute Command sysbus.twi0.lsm9ds1_imu FeedAccelerationSample @${CURDIR}/test_files/angle_rotated.data

Execute Command machine EnableProfiler "${CURDIR}/magic_wand_slope.dump"
Start Emulation
Wait For Line On Uart Magic starts
Wait For Line On Uart SLOPE:
Loading