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

TS-534: Fix card.binary HIL testing. #153

Merged
merged 1 commit into from
Jul 1, 2024
Merged
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
30 changes: 8 additions & 22 deletions .github/workflows/notecard-binary-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ jobs:
DELETE_NOTEHUB_ROUTES: true
# CREATE_NOTEHUB_ROUTES set to false to use the already created routes on notehub
CREATE_NOTEHUB_ROUTES: true
# FLASH_TEST_FIRMWARE set to false to skip flashing firmware to the Host (Swan).
# Be sure to press reset on Swan before running the workflow unless you deliberately want to skip running the tests.
FLASH_TEST_FIRMWARE: true
# START_MD5SRV set to false to skip starting the MD5 server. There should be one
# already running locally with MD5SRV_PORT/ADDRESS/TOKEN set correspondingly.
START_MD5SRV: true
Expand All @@ -61,7 +58,6 @@ jobs:
echo NOTEHUB_PROXY_ROUTE_ALIAS=$NOTEHUB_PROXY_ROUTE_ALIAS

- name: Install PlatformIO dependencies
if: env.FLASH_TEST_FIRMWARE!='false'
run: |
python3 -m venv venv # python venv is also used by the md5server, so this comes first.
source venv/bin/activate
Expand All @@ -80,21 +76,11 @@ jobs:
mkdir md5srv-files
./scripts/run_md5srv.sh

- name: Build and upload test firmware
if: env.FLASH_TEST_FIRMWARE!='false'
run: |
source venv/bin/activate
export PLATFORMIO_BUILD_FLAGS="'-D NOTEHUB_PROXY_ROUTE_ALIAS=\"$NOTEHUB_PROXY_ROUTE_ALIAS\"' '-D PRODUCT_UID=\"$NOTEHUB_PRODUCT_UID\"'"
echo "build flags $PLATFORMIO_BUILD_FLAGS"
timeout 10 ./scripts/wait_for_file.sh "$STLINK_PROGRAMMER_PORT"
platformio test -e debug --without-testing --upload-port "$STLINK_PROGRAMMER_PORT" --project-dir "$PIO_PROJECT_DIR"
timeout 10 ./scripts/wait_for_file.sh "$SWAN_SERIAL"

- name: Start tunnelmole
if: env.START_TUNNELMOLE!='false'
run: |
rm -f tmole.log
./scripts/run_tunnelmole.sh
./scripts/run_tmole.sh

- name: Check MD5 server is available
run: |
Expand Down Expand Up @@ -155,13 +141,13 @@ jobs:
exit 1
fi

- name: Run tests
- name: Build and upload test firmware and run tests
run: |
source venv/bin/activate
export PLATFORMIO_BUILD_FLAGS="'-D NOTEHUB_PROXY_ROUTE_ALIAS=\"$NOTEHUB_PROXY_ROUTE_ALIAS\"' '-D PRODUCT_UID=\"$NOTEHUB_PRODUCT_UID\"'"
echo "build flags $PLATFORMIO_BUILD_FLAGS"
cd $PIO_PROJECT_DIR
platformio test -v -e debug \
--without-building --without-uploading \
--test-port "$SWAN_SERIAL" \
--json-output-path test.json \
--junit-output-path test.xml

Expand All @@ -178,7 +164,7 @@ jobs:
- name: Cleanup Notehub proxy route
if: always()
run: |
if [ "$DELETE_NOTEHUB_ROUTES" == "true" && -n "$NOTEHUB_PROXY_ROUTE_UID" ]; then
if [ "$DELETE_NOTEHUB_ROUTES" == "true" ] && [ -n "$NOTEHUB_PROXY_ROUTE_UID" ]; then
echo "Deleting Notehub proxy route."
curl -f -s -X DELETE \
-L "https://api.notefile.net/v1/projects/$NOTEHUB_PROJECT_UID/routes/$NOTEHUB_PROXY_ROUTE_UID" \
Expand All @@ -196,14 +182,14 @@ jobs:
fi


- name: Cleanup tunnelmole
- name: Cleanup tmole
if: always()
run: |
if [ -n "$TMOLE_PID" ]; then
echo "Stopping tunnelmole."
echo "Stopping tmole."
kill $TMOLE_PID
else
echo "Tunnelmole not running (TMOLE_PID is empty)."
echo "tmole not running (TMOLE_PID is empty)."
fi

- name: Cleanup MD5 server
Expand Down
3 changes: 3 additions & 0 deletions scripts/run_tunnelmole.sh → scripts/run_tmole.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh

if [ -n "$MD5SRV_PORT" ]; then
echo "INFO: Using MD5 server port $MD5SRV_PORT." >&2
else
Expand Down
14 changes: 0 additions & 14 deletions scripts/wait_for_file.sh

This file was deleted.

19 changes: 17 additions & 2 deletions test/hitl/card.binary/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@ build_flags =
-D UNITY_INCLUDE_PRINT_FORMATTED
'-D DEFAULT_NOTEHUB_PROXY_ROUTE_ALIAS="cobstest"'
'-D DEFAULT_PRODUCT_UID=""' # don't set the product UID
lib_deps = blues/Blues Wireless Notecard@^1.5.1
lib_deps = blues/Blues Wireless Notecard@^1.6.0
debug_tool = stlink
upload_protocol = stlink
test_framework = unity
test_port = /dev/swan
test_port = /dev/note_c_hil_swan

; The serial port used for streaming test results from the Swan to the host
; computer takes a second to show up after uploading. This script waits for it
; to show up before running the tests. See https://github.com/platformio/platformio-core/issues/3742.
extra_scripts = post:wait_for_test_port.py

; We need to pass this down to OpenOCD so that it uses the correct ST-LINK.
; In my (Hayden's) HIL setup, there are many ST-LINKs connected to the same
; machine. Simply specifying the serial port corresponding to a given ST-LINK
; via upload_port doesn't work, so we have to use the specific serial number
; of the ST-LINK we're trying to target.
upload_flags =
-c
hla_serial 0029000F3156501420323443

[env:debug]
build_type = debug
Expand Down
14 changes: 14 additions & 0 deletions test/hitl/card.binary/wait_for_test_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Import("env")

def after_upload(source, target, env):
port = env.GetProjectOption("test_port")
print("waiting for " + port + " ...")
import serial
while True:
try:
s = serial.Serial(port)
break
except:
pass

env.AddPostAction("upload", after_upload)
Loading