summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2024-08-02 11:52:35 +0200
committerGitHub <[email protected]>2024-08-02 11:52:35 +0200
commit95cb319bded7db536edaae24936a825a8524a4a2 (patch)
tree7de7d7f8d1916061cdaefcfb4f220397e1d0fbb8 /test
parentadc7a78fd6fbdccbe5f586391997052f2becd149 (diff)
parent4232642899362fa5e9cf0dc59bad6f1f6d32c563 (diff)
Merge branch 'master' into vendor_fifo
Diffstat (limited to 'test')
-rw-r--r--test/fuzz/net_fuzz.cc10
-rw-r--r--test/hil/hfp.json (renamed from test/hil/hil_hfp.json)0
-rw-r--r--test/hil/hil_pi4.json37
-rw-r--r--test/hil/hil_test.py140
-rw-r--r--test/hil/rpi.json74
-rw-r--r--test/unit-test/project.yml12
6 files changed, 164 insertions, 109 deletions
diff --git a/test/fuzz/net_fuzz.cc b/test/fuzz/net_fuzz.cc
index 63cd1ac98..468437b0c 100644
--- a/test/fuzz/net_fuzz.cc
+++ b/test/fuzz/net_fuzz.cc
@@ -69,14 +69,6 @@ void tud_network_init_cb(void) {
// TODO removed later since it is not part of tinyusb stack
uint8_t tud_network_mac_address[6] = {0};
-//------------- NCM -------------//
-
-// callback to client providing optional indication of internal state of network
-// driver
-void tud_network_link_state_cb(bool state) {
- (void)state;
- // NoOp.
-}
-}
+} // extern "C"
#endif
diff --git a/test/hil/hil_hfp.json b/test/hil/hfp.json
index e79a3cfc9..e79a3cfc9 100644
--- a/test/hil/hil_hfp.json
+++ b/test/hil/hfp.json
diff --git a/test/hil/hil_pi4.json b/test/hil/hil_pi4.json
deleted file mode 100644
index 17d9ff1fa..000000000
--- a/test/hil/hil_pi4.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "boards": [
- {
- "name": "raspberry_pi_pico",
- "uid": "E6614C311B764A37",
- "flasher": "openocd",
- "flasher_sn": "E6614103E72C1D2F",
- "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\""
- },
- {
- "name": "espressif_s3_devkitc",
- "uid": "7CDFA1E073CC",
- "tests": [
- "cdc_msc_freertos", "hid_composite_freertos"
- ],
- "flasher": "esptool",
- "flasher_sn": "461cb8d7decdeb119be9b506e93fd3f1",
- "flasher_args": "-b 1500000"
- },
- {
- "name": "feather_nrf52840_express",
- "uid": "1F0479CD0F764471",
- "flasher": "jlink",
- "flasher_sn": "000682804350",
- "flasher_args": "-device nrf52840_xxaa"
- },
- {
- "name": "itsybitsy_m4",
- "uid": "D784B28C5338533335202020FF044726",
- "flasher": "bossac",
- "flashser_vendor": "Adafruit Industries",
- "flasher_product": "ItsyBitsy M4 Express",
- "flasher_reset_pin": "2",
- "flasher_args": "--offset 0x4000"
- }
- ]
-}
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index 7f03ce43f..bdc48591e 100644
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -25,23 +25,25 @@
# ACTION=="add", SUBSYSTEM=="tty", SUBSYSTEMS=="usb", MODE="0666", PROGRAM="/bin/sh -c 'echo $$ID_SERIAL_SHORT | rev | cut -c -8 | rev'", SYMLINK+="ttyUSB_%c.%s{bInterfaceNumber}"
# ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb", ENV{ID_FS_USAGE}=="filesystem", MODE="0666", PROGRAM="/bin/sh -c 'echo $$ID_SERIAL_SHORT | rev | cut -c -8 | rev'", RUN{program}+="/usr/bin/systemd-mount --no-block --automount=yes --collect $devnode /media/blkUSB_%c.%s{bInterfaceNumber}"
+import argparse
import os
import sys
import time
-import click
import serial
import subprocess
import json
import glob
+import platform
# for RPI double reset
-try:
- import gpiozero
-except ImportError:
- pass
+if platform.machine() == 'aarch64':
+ try:
+ import gpiozero
+ except ImportError:
+ pass
-ENUM_TIMEOUT = 10
+ENUM_TIMEOUT = 30
# get usb serial by id
@@ -111,27 +113,48 @@ def read_disk_file(id, fname):
# -------------------------------------------------------------
# Flashing firmware
# -------------------------------------------------------------
+def run_cmd(cmd):
+ #print(cmd)
+ r = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ if r.returncode != 0:
+ title = 'command error'
+ if os.getenv('CI'):
+ print(f"::group::{title}")
+ print(r.stdout.decode("utf-8"))
+ print(f"::endgroup::")
+ else:
+ print(title)
+ print(r.stdout.decode("utf-8"))
+ return r
+
+
def flash_jlink(board, firmware):
- script = ['halt', 'r', f'loadfile {firmware}', 'r', 'go', 'exit']
+ script = ['halt', 'r', f'loadfile {firmware}.elf', 'r', 'go', 'exit']
with open('flash.jlink', 'w') as f:
f.writelines(f'{s}\n' for s in script)
- ret = subprocess.run(
- f'JLinkExe -USB {board["flasher_sn"]} {board["flasher_args"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink',
- shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ ret = run_cmd(f'JLinkExe -USB {board["flasher_sn"]} {board["flasher_args"]} -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink')
os.remove('flash.jlink')
return ret
+def flash_stlink(board, firmware):
+ ret = run_cmd(f'STM32_Programmer_CLI --connect port=swd sn={board["flasher_sn"]} --write {firmware}.elf --go')
+ return ret
+
+
+def flash_stflash(board, firmware):
+ ret = run_cmd(f'st-flash --serial {board["flasher_sn"]} write {firmware}.bin 0x8000000')
+ return ret
+
+
def flash_openocd(board, firmware):
- ret = subprocess.run(
- f'openocd -c "adapter serial {board["flasher_sn"]}" {board["flasher_args"]} -c "program {firmware} reset exit"',
- shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ ret = run_cmd(f'openocd -c "adapter serial {board["flasher_sn"]}" {board["flasher_args"]} -c "program {firmware}.elf reset exit"')
return ret
def flash_esptool(board, firmware):
port = get_serial_dev(board["flasher_sn"], None, None, 0)
- dir = os.path.dirname(firmware)
+ dir = os.path.dirname(f'{firmware}.bin')
with open(f'{dir}/config.env') as f:
IDF_TARGET = json.load(f)['IDF_TARGET']
with open(f'{dir}/flash_args') as f:
@@ -142,21 +165,23 @@ def flash_esptool(board, firmware):
return ret
-def doublereset_with_rpi_gpio(board):
+def doublereset_with_rpi_gpio(pin):
# Off = 0 = Reset
- led = gpiozero.LED(board["flasher_reset_pin"])
+ nrst = gpiozero.LED(pin)
- led.off()
+ nrst.off()
time.sleep(0.1)
- led.on()
+ nrst.on()
time.sleep(0.1)
- led.off()
+ nrst.off()
time.sleep(0.1)
- led.on()
+ nrst.on()
+
def flash_bossac(board, firmware):
# double reset to enter bootloader
- doublereset_with_rpi_gpio(board)
+ if platform.machine() == 'aarch64':
+ doublereset_with_rpi_gpio(board["flasher_reset_pin"])
port = get_serial_dev(board["uid"], board["flashser_vendor"], board["flasher_product"], 0)
timeout = ENUM_TIMEOUT
@@ -169,8 +194,7 @@ def flash_bossac(board, firmware):
assert timeout, 'bossac bootloader is not available'
# sleep a bit more for bootloader to be ready
time.sleep(0.5)
- ret = subprocess.run(f'bossac --port {port} {board["flasher_args"]} -U -i -R -e -w {firmware}', shell=True, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ ret = run_cmd(f'bossac --port {port} {board["flasher_args"]} -U -i -R -e -w {firmware}.bin')
return ret
# -------------------------------------------------------------
@@ -303,39 +327,50 @@ def test_hid_composite_freertos(id):
# -------------------------------------------------------------
# Main
# -------------------------------------------------------------
[email protected]('config_file')
[email protected]('-b', '--board', multiple=True, default=None, help='Boards to test, all if not specified')
-def main(config_file, board):
+def main():
"""
Hardware test on specified boards
"""
- config_file = os.path.join(os.path.dirname(__file__), config_file)
+ parser = argparse.ArgumentParser()
+ parser.add_argument('config_file', help='Configuration JSON file')
+ parser.add_argument('-b', '--board', action='append', default=[], help='Boards to test, all if not specified')
+ args = parser.parse_args()
+
+ config_file = args.config_file
+ boards = args.board
+
+ # if config file is not found, try to find it in the same directory as this script
+ if not os.path.exists(config_file):
+ config_file = os.path.join(os.path.dirname(__file__), config_file)
with open(config_file) as f:
config = json.load(f)
- # all possible tests
+ # all possible tests: board_test is added last to disable board's usb
all_tests = [
- 'cdc_dual_ports', 'cdc_msc', 'dfu', 'dfu_runtime', 'hid_boot_interface',
+ 'cdc_dual_ports',
+ 'cdc_msc',
+ 'cdc_msc_freertos',
+ 'dfu',
+ 'dfu_runtime',
+ 'hid_boot_interface',
+ 'board_test'
]
- if len(board) == 0:
+ if len(boards) == 0:
config_boards = config['boards']
else:
- config_boards = [e for e in config['boards'] if e['name'] in board]
+ config_boards = [e for e in config['boards'] if e['name'] in boards]
for item in config_boards:
- print(f'Testing board:{item["name"]}')
+ name = item['name']
+ print(f'Testing board:{name}')
flasher = item['flasher'].lower()
# default to all tests
if 'tests' in item:
- test_list = item['tests']
+ test_list = item['tests'] + ['board_test']
else:
- test_list = all_tests
-
- # board_test is added last to disable board's usb
- test_list.append('board_test')
+ test_list = list(all_tests)
# remove skip_tests
if 'tests_skip' in item:
@@ -344,29 +379,20 @@ def main(config_file, board):
test_list.remove(skip)
for test in test_list:
- fw_list = [
- # cmake: esp32 & samd51 use .bin file
- f'cmake-build/cmake-build-{item["name"]}/device/{test}/{test}.elf',
- f'cmake-build/cmake-build-{item["name"]}/device/{test}/{test}.bin',
- # make
- f'examples/device/{test}/_build/{item["name"]}/{test}.elf'
- ]
-
- fw = None
- for f in fw_list:
- if os.path.isfile(f):
- fw = f
- break
-
- if fw is None:
- print(f'Cannot find binary file for {test}')
- sys.exit(-1)
+ fw_dir = f'cmake-build/cmake-build-{name}/device/{test}'
+ if not os.path.exists(fw_dir):
+ fw_dir = f'examples/cmake-build-{name}/device/{test}'
+ fw_name = f'{fw_dir}/{test}'
+ print(f' {test} ... ', end='')
+ sys.stdout.flush()
- print(f' {test} ...', end='')
+ if not os.path.exists(fw_dir):
+ print('Skip')
+ continue
# flash firmware. It may fail randomly, retry a few times
for i in range(3):
- ret = globals()[f'flash_{flasher}'](item, fw)
+ ret = globals()[f'flash_{flasher}'](item, fw_name)
if ret.returncode == 0:
break
else:
diff --git a/test/hil/rpi.json b/test/hil/rpi.json
new file mode 100644
index 000000000..9520f30e2
--- /dev/null
+++ b/test/hil/rpi.json
@@ -0,0 +1,74 @@
+{
+ "boards": [
+ {
+ "name": "feather_nrf52840_express",
+ "uid": "1F0479CD0F764471",
+ "flasher": "jlink",
+ "flasher_sn": "000682804350",
+ "flasher_args": "-device nrf52840_xxaa"
+ },
+ {
+ "name": "itsybitsy_m4",
+ "uid": "D784B28C5338533335202020FF044726",
+ "flasher": "openocd",
+ "flasher_sn": "E6614C311B597D32",
+ "flasher_args": "-f interface/cmsis-dap.cfg -f target/atsame5x.cfg -c \"adapter speed 5000\""
+ },
+ {
+ "name": "metro_m7_1011",
+ "uid": "9CE8715DD71137363E00005002004200",
+ "flasher": "jlink",
+ "flasher_sn": "000611000000",
+ "flasher_args": "-device MIMXRT1011xxx5A"
+ },
+ {
+ "name": "lpcxpresso11u37",
+ "uid": "17121919",
+ "flasher": "jlink",
+ "flasher_sn": "000724441579",
+ "flasher_args": "-device LPC11U37/401"
+ },
+ {
+ "name": "ra4m1_ek",
+ "uid": "152E163038303131393346E46F26574B",
+ "tests_skip": ["cdc_msc", "cdc_msc_freertos"],
+ "comment": "MSC is slow to enumerated #2602",
+ "flasher": "jlink",
+ "flasher_sn": "000831174392",
+ "flasher_args": "-device R7FA4M1AB"
+ },
+ {
+ "name": "raspberry_pi_pico",
+ "uid": "E6614C311B764A37",
+ "flasher": "openocd",
+ "flasher_sn": "E6614103E72C1D2F",
+ "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\""
+ },
+ {
+ "name": "stm32f072disco",
+ "uid": "3A001A001357364230353532",
+ "flasher": "jlink",
+ "flasher_sn": "779541626",
+ "flasher_args": "-device stm32f072rb"
+ },
+ {
+ "name": "stm32g0b1nucleo",
+ "uid": "4D0038000450434E37343120",
+ "flasher": "openocd",
+ "flasher_sn": "066FFF495087534867063844",
+ "flasher_args": "-f interface/stlink.cfg -f target/stm32g0x.cfg"
+ }
+ ],
+ "boards-skip": [
+ {
+ "name": "espressif_s3_devkitm",
+ "uid": "84F703C084E4",
+ "tests": [
+ "cdc_msc_freertos", "hid_composite_freertos"
+ ],
+ "flasher": "esptool",
+ "flasher_sn": "3ea619acd1cdeb11a0a0b806e93fd3f1",
+ "flasher_args": "-b 921600"
+ }
+ ]
+}
diff --git a/test/unit-test/project.yml b/test/unit-test/project.yml
index 82528f68c..7fbbabfe6 100644
--- a/test/unit-test/project.yml
+++ b/test/unit-test/project.yml
@@ -81,20 +81,20 @@
:tools:
:test_compiler:
- :executable: clang
- :name: 'clang compiler'
+ :executable: gcc
+ :name: 'gcc compiler'
:arguments:
- -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE #expands to -I search paths
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR #expands to -I search paths
- -D$: COLLECTION_DEFINES_TEST_AND_VENDOR #expands to all -D defined symbols
- - -fsanitize=address
+ #- -fsanitize=address
- -c ${1} #source code input file (Ruby method call param list sub)
- -o ${2} #object file output (Ruby method call param list sub)
:test_linker:
- :executable: clang
- :name: 'clang linker'
+ :executable: gcc
+ :name: 'gcc linker'
:arguments:
- - -fsanitize=address
+ #- -fsanitize=address
- ${1} #list of object files to link (Ruby method call param list sub)
- -o ${2} #executable file output (Ruby method call param list sub)