Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenroche5 committed Jul 1, 2024
1 parent 13fd8e7 commit c7be471
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
23 changes: 2 additions & 21 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,19 +76,6 @@ 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"
# Build the firmware
platformio run -e debug --project-dir "$PIO_PROJECT_DIR"
timeout 10 ./scripts/wait_for_file.sh "$STLINK_PROGRAMMER_PORT"
# Upload the firmware
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 lt
if: env.START_LT!='false'
run: |
Expand Down Expand Up @@ -158,13 +141,11 @@ jobs:
exit 1
fi
- name: Run tests
- name: Build and upload test firmware and run tests
run: |
source venv/bin/activate
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 @@ -181,7 +162,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 Down
1 change: 1 addition & 0 deletions scripts/run_lt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if ! which lt > /dev/null 2>&1; then
fi

echo "INFO: Starting lt..." >&2
# TODO: When the localtunnel server is under heavy load, this can fail and should just be retried a couple times.
lt --port $MD5SRV_PORT > lt.log 2>&1 &
LT_PID=$!
echo "INFO: lt PID is $LT_PID." >&2
Expand Down
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)

0 comments on commit c7be471

Please sign in to comment.