summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/hil/hil_test.py103
-rw-r--r--test/hil/tinyusb.json22
2 files changed, 79 insertions, 46 deletions
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index 8b89de66c..f292bca15 100755
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -514,6 +514,63 @@ host_test = [
]
+def test_example(board, f1, example):
+ """
+ Test example firmware
+ :param board: board dict
+ :param f1: flags on
+ :param example: example name
+ :return: 0 if success/skip, 1 if failed
+ """
+ name = board['name']
+ err_count = 0
+
+ f1_str = ""
+ if f1 != "":
+ f1_str = '-f1_' + f1.replace(' ', '_')
+
+ fw_dir = f'{TINYUSB_ROOT}/cmake-build/cmake-build-{name}{f1_str}/{example}'
+ if not os.path.exists(fw_dir):
+ fw_dir = f'{TINYUSB_ROOT}/examples/cmake-build-{name}{f1_str}/{example}'
+ fw_name = f'{fw_dir}/{os.path.basename(example)}'
+ print(f'{name+f1_str:40} {example:30} ... ', end='')
+
+ if not os.path.exists(fw_dir) or not (os.path.exists(f'{fw_name}.elf') or os.path.exists(f'{fw_name}.bin')):
+ print('Skip (no binary)')
+ return 0
+
+ if verbose:
+ print(f'Flashing {fw_name}.elf')
+
+ # flash firmware. It may fail randomly, retry a few times
+ max_rety = 3
+ for i in range(max_rety):
+ ret = globals()[f'flash_{board["flasher"]["name"].lower()}'](board, fw_name)
+ if ret.returncode == 0:
+ try:
+ globals()[f'test_{example.replace("/", "_")}'](board)
+ print('OK')
+ break
+ except Exception as e:
+ if i == max_rety - 1:
+ err_count += 1
+ print(STATUS_FAILED)
+ print(f' {e}')
+ else:
+ print()
+ print(f' Test failed: {e}, retry {i+2}/{max_rety}')
+ time.sleep(1)
+ else:
+ print(f'Flashing failed, retry {i+2}/{max_rety}')
+ time.sleep(1)
+
+ if ret.returncode != 0:
+ err_count += 1
+ print(f'Flash {STATUS_FAILED}')
+
+ return err_count
+
+
def test_board(board):
name = board['name']
flasher = board['flasher']
@@ -537,57 +594,17 @@ def test_board(board):
test_list.remove(skip)
print(f'{name:25} {skip:30} ... Skip')
- # board_test is added last to disable board's usb
- test_list.append('device/board_test')
-
err_count = 0
flags_on_list = [""]
if 'build' in board and 'flags_on' in board['build']:
flags_on_list = board['build']['flags_on']
for f1 in flags_on_list:
- f1_str = ""
- if f1 != "":
- f1_str = '-f1_' + f1.replace(' ', '_')
for test in test_list:
- fw_dir = f'{TINYUSB_ROOT}/cmake-build/cmake-build-{name}{f1_str}/{test}'
- if not os.path.exists(fw_dir):
- fw_dir = f'{TINYUSB_ROOT}/examples/cmake-build-{name}{f1_str}/{test}'
- fw_name = f'{fw_dir}/{os.path.basename(test)}'
- print(f'{name+f1_str:40} {test:30} ... ', end='')
-
- if not os.path.exists(fw_dir) or not (os.path.exists(f'{fw_name}.elf') or os.path.exists(f'{fw_name}.bin')):
- print('Skip (no binary)')
- continue
-
- if verbose:
- print(f'Flashing {fw_name}.elf')
-
- # flash firmware. It may fail randomly, retry a few times
- max_rety = 2
- for i in range(max_rety):
- ret = globals()[f'flash_{flasher["name"].lower()}'](board, fw_name)
- if ret.returncode == 0:
- try:
- globals()[f'test_{test.replace("/", "_")}'](board)
- print('OK')
- break
- except Exception as e:
- if i == max_rety - 1:
- err_count += 1
- print(STATUS_FAILED)
- print(f' {e}')
- else:
- print()
- print(f' Test failed: {e}, retry {i+2}/{max_rety}')
- time.sleep(1)
- else:
- print(f'Flashing failed, retry {i+2}/{max_rety}')
- time.sleep(1)
+ err_count += test_example(board, f1, test)
- if ret.returncode != 0:
- err_count += 1
- print(f'Flash {STATUS_FAILED}')
+ # flash board_test last to disable board's usb
+ test_example(board, flags_on_list[0], 'device/board_test')
return err_count
diff --git a/test/hil/tinyusb.json b/test/hil/tinyusb.json
index a9460bf9d..8a835e4c0 100644
--- a/test/hil/tinyusb.json
+++ b/test/hil/tinyusb.json
@@ -21,16 +21,18 @@
"name": "espressif_s3_devkitm",
"uid": "84F703C084E4",
"build" : {
- "flags_on": ["", "CFG_TUD_DWC2_DMA_ENABLE"]
+ "flags_on": ["", "CFG_TUD_DWC2_DMA_ENABLE CFG_TUH_DWC2_DMA_ENABLE"]
},
"tests": {
- "only": ["device/cdc_msc_freertos", "device/hid_composite_freertos"]
+ "only": ["device/cdc_msc_freertos", "device/hid_composite_freertos", "host/device_info"],
+ "dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2005402"}]
},
"flasher": {
"name": "esptool",
"uid": "3ea619acd1cdeb11a0a0b806e93fd3f1",
"args": "-b 1500000"
- }
+ },
+ "comment": "Use TS3USB30 mux to test both device and host"
},
{
"name": "feather_nrf52840_express",
@@ -125,6 +127,20 @@
}
},
{
+ "name": "raspberry_pi_pico_w",
+ "uid": "E6614C311B764A37",
+ "tests": {
+ "device": false, "host": true, "dual": false,
+ "dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2023934"}]
+ },
+ "flasher": {
+ "name": "openocd",
+ "uid": "E6633861A3819D38",
+ "args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\""
+ },
+ "comment": "Test native host"
+ },
+ {
"name": "raspberry_pi_pico2",
"uid": "560AE75E1C7152C9",
"build" : {