Skip to content

Commit

Permalink
test 9, with flash and monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
OlafFilies committed Oct 31, 2024
1 parent 54e3013 commit 36d28f0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 35 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/hil-unity-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,25 @@ jobs:
readarray -t TESTS < <(echo $lib | jq ".\"${LIB}\".\"${EXAMPLE}\"[]" -r --compact-output)
for ((idx=0; idx<${#TESTS[@]}; ++idx)); do
cd $GITHUB_WORKSPACE/tests/Unity/
echo "=============================================================================================================="
echo "Run on index $idx for TEST: ${TESTS[idx]} under EXAMPLE: ${EXAMPLE} and LIB: ${LIB}"
echo "$idx: ${TESTS[idx]}"
echo "PORT= ${PORTS[idx]}"
echo "FQBN=${{ env.fqbn }}"
echo "=============================================================================================================="
make FQBN=${{ env.fqbn }} PORT=${PORTS[idx]} UNITY_PATH=/opt/runner_support/Unity_github ${TESTS[idx]}
done
#
for ((idx=0; idx<${#TESTS[@]}; ++idx)); do
cd $GITHUB_WORKSPACE/tests/Unity/
timeout 1m /opt/runner_support/py_console.py \
--port ${PORTS[idx]} \
--report .build/report.json
done
done
done
Expand Down
88 changes: 53 additions & 35 deletions tests/Unity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $(info BAUD_RATE : $(BAUD_RATE))

TESTS_CONNECTED=-DTEST_CAN_CONNECTED
TESTS_NOT_CONNECTED=-DTEST_CAN

CAN: TESTS=-DTEST_CAN
CAN_connected: TESTS=-DTEST_CAN -DTEST_CAN_CONNECTED
CAN_connected_node1: TESTS=-DTEST_CAN_CONNECTED_NODE1
Expand All @@ -31,46 +31,46 @@ test: unity_corelibs flash
EXAMPLES= CANReceiver CANReceiverCallback CANSender CANLoopBack

clean:
-rm -rf build/*
-rm -rf build/*

arduino: clean
mkdir -p build
mkdir -p build
# copy library files (not needed for bundled libraries)
# cp -r src/* build
# find src -name '*.[hc]*' -a \( \! -name '*mtb*' \) -print -exec cp {} build \;
.PHONY: CANReceiver CANReceiverCallback CANSender CANLoopBack
CANReceiver: arduino
cp examples/CANReceiver/CANReceiver.ino build/build.ino
cp examples/CANReceiver/CANReceiver.ino build/build.ino

CANReceiverCallback: arduino
cp examples/CANReceiverCallback/CANReceiverCallback.ino build/build.ino
cp examples/CANReceiverCallback/CANReceiverCallback.ino build/build.ino

CANSender: arduino
cp examples/CANSender/CANSender.ino build/build.ino
cp examples/CANSender/CANSender.ino build/build.ino

CANLoopBack: arduino
cp examples/CANLoopBack/CANLoopBack.ino build/build.ino
cp examples/CANLoopBack/CANLoopBack.ino build/build.ino


# install Unity from https://www.throwtheswitch.org/unity or git
unity_corelibs: arduino
ifeq ($(UNITY_PATH),)
$(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !")
$(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !")
else
find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
find src -name '*.[hc]*' -a \! -path '*mtb*' -a \! -path '*applibs*' -exec \cp {} build \;
cp src/corelibs/Test_main.ino build/build.ino
find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
find src -name '*.[hc]*' -a \! -path '*mtb*' -a \! -path '*applibs*' -exec \cp {} build \;
cp src/corelibs/Test_main.ino build/build.ino
endif

unity_corelibs_can: arduino
ifeq ($(UNITY_PATH),)
$(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !")
$(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !")
else
find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
find src/corelibs/CAN -name '*.[hc]*' -exec \cp {} build \;
find src/utils -name '*.[hc]*' -exec \cp {} build \;
find src -maxdepth 1 -name '*.[hc]*' -exec \cp {} build \;
cp src/Test_main.ino build/build.ino
find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
find src/corelibs/CAN -name '*.[hc]*' -exec \cp {} build \;
find src/utils -name '*.[hc]*' -exec \cp {} build \;
find src -maxdepth 1 -name '*.[hc]*' -exec \cp {} build \;
cp src/Test_main.ino build/build.ino
endif


Expand All @@ -79,39 +79,54 @@ endif
# download arduino-cli.exe from : https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip
compile:
ifeq ($(FQBN),)
$(error "Must set variable FQBN in order to be able to compile Arduino sketches !")
$(error "Must set variable FQBN in order to be able to compile Arduino sketches !")
else
# CAUTION : only use '=' when assigning values to vars, not '+='
arduino-cli.exe compile --clean --log --warnings all --fqbn $(FQBN) --build-property "compiler.c.extra_flags=\"-DUNITY_INCLUDE_CONFIG_H=1\"" \
--build-property compiler.cpp.extra_flags="$(TESTS)" build
arduino-cli.exe compile \
--clean \
--log \
--warnings all \
--fqbn $(FQBN) \
--build-property "compiler.c.extra_flags=\"-DUNITY_INCLUDE_CONFIG_H=1\"" \
--build-property compiler.cpp.extra_flags="$(TESTS)" \
--export-binaries \
build
endif


compileLTO:
ifeq ($(FQBN),)
$(error "Must set variable FQBN in order to be able to compile Arduino sketches !")
$(error "Must set variable FQBN in order to be able to compile Arduino sketches !")
else
# compiler.c.extra_flags : switch to -std=c23 whenever XMCLib is conforming; currently neither c99 nor c11 work !
# CAUTION : only use '=' when assigning values to vars, not '+='
arduino-cli.exe compile --clean --log --warnings all --fqbn $(FQBN) \
--build-property compiler.c.extra_flags="\"-DUNITY_INCLUDE_CONFIG_H=1\" -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c20 " \
--build-property compiler.cpp.extra_flags="$(TESTS) -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c++20 " \
--build-property compiler.ar.cmd=arm-none-eabi-gcc-ar \
--build-property compiler.libraries.ldflags=-lstdc++ \
--build-property compiler.arm.cmsis.path="-isystem{compiler.xmclib_include.path}/XMCLib/inc -isystem{compiler.dsp_include.path} -isystem{compiler.nn_include.path} -isystem{compiler.cmsis_include.path} -isystem{compiler.xmclib_include.path}/LIBS -isystem{build.variant.path} -isystem{build.variant.config_path}" \
--build-property compiler.usb.path="-isystem{runtime.platform.path}/cores/usblib -isystem{runtime.platform.path}/cores/usblib/Common -isystem{runtime.platform.path}/cores/usblib/Class -isystem{runtime.platform.path}/cores/usblib/Class/Common -isystem{runtime.platform.path}/cores/usblib/Class/Device -isystem{runtime.platform.path}/cores/usblib/Core -isystem{runtime.platform.path}/cores/usblib/Core/XMC4000" \
build
arduino-cli.exe compile \
--clean \
--log \
--warnings all \
--fqbn $(FQBN) \
--build-property compiler.c.extra_flags="\"-DUNITY_INCLUDE_CONFIG_H=1\" -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c20 " \
--build-property compiler.cpp.extra_flags="$(TESTS) -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c++20 " \
--build-property compiler.ar.cmd=arm-none-eabi-gcc-ar \
--build-property compiler.libraries.ldflags=-lstdc++ \
--build-property compiler.arm.cmsis.path="-isystem{compiler.xmclib_include.path}/XMCLib/inc -isystem{compiler.dsp_include.path} -isystem{compiler.nn_include.path} -isystem{compiler.cmsis_include.path} -isystem{compiler.xmclib_include.path}/LIBS -isystem{build.variant.path} -isystem{build.variant.config_path}" \
--build-property compiler.usb.path="-isystem{runtime.platform.path}/cores/usblib -isystem{runtime.platform.path}/cores/usblib/Common -isystem{runtime.platform.path}/cores/usblib/Class -isystem{runtime.platform.path}/cores/usblib/Class/Common -isystem{runtime.platform.path}/cores/usblib/Class/Device -isystem{runtime.platform.path}/cores/usblib/Core -isystem{runtime.platform.path}/cores/usblib/Core/XMC4000" \
build
endif


upload: compile
ifeq ($(PORT),)
$(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !")
$(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !")
endif
ifeq ($(FQBN),)
$(error "Must set variable FQBN in order to be able to flash Arduino sketches !")
$(error "Must set variable FQBN in order to be able to flash Arduino sketches !")
else
arduino-cli.exe upload -p $(PORT) --fqbn $(FQBN) --verbose build
arduino-cli.exe upload \
-p $(PORT) \
--fqbn $(FQBN) \
--verbose \
build
endif


Expand All @@ -120,11 +135,14 @@ flash: compile upload

monitor:
ifeq ($(PORT),)
$(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !")
$(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !")
endif
ifeq ($(FQBN),)
$(error "Must set variable FQBN in order to be able to flash Arduino sketches !")
$(error "Must set variable FQBN in order to be able to flash Arduino sketches !")
else
arduino-cli.exe monitor -c baudrate=$(BAUD_RATE) -p $(PORT) --fqbn $(FQBN)
arduino-cli.exe monitor \
-c baudrate=$(BAUD_RATE) \
-p $(PORT) \
--fqbn $(FQBN)
endif

0 comments on commit 36d28f0

Please sign in to comment.