summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-07-11 15:47:55 +0200
committerHiFiPhile <[email protected]>2025-07-11 15:47:55 +0200
commitf074815405f9c510f3f1eb57f3cbdab40e9e1caa (patch)
tree27157de2ae8ef662974a9d87a8119c12f3fbdffb /test
parent69f6b57772ad4f2923dcf48aabaaba044085c4b0 (diff)
parent29c2af7651f9075a63a036e94c7bbe3d0d00c31a (diff)
Merge branch 'master' into feature/usbtmc_vendor-specific
Diffstat (limited to 'test')
-rw-r--r--test/fuzz/device/net/Makefile2
-rw-r--r--test/fuzz/make.mk6
-rw-r--r--test/fuzz/rules.mk2
-rw-r--r--test/hil/hil_ci_set_matrix.py20
-rwxr-xr-xtest/hil/hil_test.py39
-rw-r--r--test/hil/tinyusb.json3
-rw-r--r--test/unit-test/test/device/msc/test_msc_device.c17
7 files changed, 52 insertions, 37 deletions
diff --git a/test/fuzz/device/net/Makefile b/test/fuzz/device/net/Makefile
index 4e99604ad..2161ad3f1 100644
--- a/test/fuzz/device/net/Makefile
+++ b/test/fuzz/device/net/Makefile
@@ -1,5 +1,3 @@
-DEPS_SUBMODULES += lib/lwip
-
include ../../make.mk
# suppress warning caused by lwip
diff --git a/test/fuzz/make.mk b/test/fuzz/make.mk
index b7b6d6a75..e9aa80bf1 100644
--- a/test/fuzz/make.mk
+++ b/test/fuzz/make.mk
@@ -124,11 +124,5 @@ endif
# Log level is mapped to TUSB DEBUG option
ifneq ($(LOG),)
- CMAKE_DEFSYM += -DLOG=$(LOG)
CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
endif
-
-# Logger: default is uart, can be set to rtt or swo
-ifneq ($(LOGGER),)
- CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
-endif
diff --git a/test/fuzz/rules.mk b/test/fuzz/rules.mk
index ee91c706d..562969663 100644
--- a/test/fuzz/rules.mk
+++ b/test/fuzz/rules.mk
@@ -142,7 +142,7 @@ endif
# get depenecies
.PHONY: get-deps
get-deps:
- $(PYTHON) $(TOP)/tools/get_deps.py $(DEPS_SUBMODULES)
+ $(PYTHON) $(TOP)/tools/get_deps.py $(FAMILY)
size: $(BUILD)/$(PROJECT)
-@echo ''
diff --git a/test/hil/hil_ci_set_matrix.py b/test/hil/hil_ci_set_matrix.py
index 67ce2abb8..ecd964d87 100644
--- a/test/hil/hil_ci_set_matrix.py
+++ b/test/hil/hil_ci_set_matrix.py
@@ -28,14 +28,20 @@ def main():
else:
toolchain = 'arm-gcc'
- if 'build' in board and 'flags_on' in board['build']:
- for f in board['build']['flags_on']:
- if f == '':
- matrix[toolchain].append(f'-b {name}')
- else:
- matrix[toolchain].append(f'-b {name} -f1 {f.replace(" ", " -f1 ")}')
+ build_board = f'-b {name}'
+ if 'build' in board:
+ if 'args' in board['build']:
+ build_board += ' ' + ' '.join(f'-D{a}' for a in board['build']['args'])
+ if 'flags_on' in board['build']:
+ for f in board['build']['flags_on']:
+ if f == '':
+ matrix[toolchain].append(build_board)
+ else:
+ matrix[toolchain].append(f'{build_board} -f1 {f.replace(" ", " -f1 ")}')
+ else:
+ matrix[toolchain].append(build_board)
else:
- matrix[toolchain].append(f'-b {name}')
+ matrix[toolchain].append(build_board)
print(json.dumps(matrix))
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index f292bca15..93cc0a750 100755
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -533,7 +533,7 @@ def test_example(board, f1, 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='')
+ 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)')
@@ -544,29 +544,30 @@ def test_example(board, f1, example):
# flash firmware. It may fail randomly, retry a few times
max_rety = 3
+ start_s = time.time()
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')
+ print(' OK', end='')
break
except Exception as e:
if i == max_rety - 1:
err_count += 1
- print(STATUS_FAILED)
- print(f' {e}')
+ print(f'{STATUS_FAILED}: {e}')
else:
- print()
- print(f' Test failed: {e}, retry {i+2}/{max_rety}')
- time.sleep(1)
+ print(f'\n Test failed: {e}, retry {i+2}/{max_rety}', end='')
+ time.sleep(0.5)
else:
- print(f'Flashing failed, retry {i+2}/{max_rety}')
- time.sleep(1)
+ print(f'\n Flash failed, retry {i+2}/{max_rety}', end='')
+ time.sleep(0.5)
if ret.returncode != 0:
err_count += 1
- print(f'Flash {STATUS_FAILED}')
+ print(f' Flash {STATUS_FAILED}', end='')
+
+ print(f' in {time.time() - start_s:.1f}s')
return err_count
@@ -606,7 +607,7 @@ def test_board(board):
# flash board_test last to disable board's usb
test_example(board, flags_on_list[0], 'device/board_test')
- return err_count
+ return name, err_count
def main():
@@ -620,11 +621,13 @@ def main():
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')
+ parser.add_argument('-s', '--skip', action='append', default=[], help='Skip boards from test')
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output')
args = parser.parse_args()
config_file = args.config_file
boards = args.board
+ skip_boards = args.skip
verbose = args.verbose
# if config file is not found, try to find it in the same directory as this script
@@ -634,12 +637,22 @@ def main():
config = json.load(f)
if len(boards) == 0:
- config_boards = config['boards']
+ config_boards = [e for e in config['boards'] if e['name'] not in skip_boards]
else:
config_boards = [e for e in config['boards'] if e['name'] in boards]
+ err_count = 0
with Pool(processes=os.cpu_count()) as pool:
- err_count = sum(pool.map(test_board, config_boards))
+ mret = pool.map(test_board, config_boards)
+ err_count = sum(e[1] for e in mret)
+ # generate skip list for next re-run if failed
+ skip_fname = f'{config_file}.skip'
+ if err_count > 0:
+ skip_boards += [name for name, err in mret if err == 0]
+ with open(skip_fname, 'w') as f:
+ f.write(' '.join(f'-s {i}' for i in skip_boards))
+ elif os.path.exists(skip_fname):
+ os.remove(skip_fname)
duration = time.time() - duration
print()
diff --git a/test/hil/tinyusb.json b/test/hil/tinyusb.json
index 8a835e4c0..6afcb2186 100644
--- a/test/hil/tinyusb.json
+++ b/test/hil/tinyusb.json
@@ -61,6 +61,9 @@
{
"name": "metro_m4_express",
"uid": "9995AD485337433231202020FF100A34",
+ "build" : {
+ "args": ["MAX3421_HOST=1"]
+ },
"tests": {
"device": true, "host": false, "dual": true,
"dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002130"}]
diff --git a/test/unit-test/test/device/msc/test_msc_device.c b/test/unit-test/test/device/msc/test_msc_device.c
index 3ab46b0f9..e05e9c8b0 100644
--- a/test/unit-test/test/device/msc/test_msc_device.c
+++ b/test/unit-test/test/device/msc/test_msc_device.c
@@ -94,19 +94,20 @@ enum
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE];
-// Invoked when received SCSI_CMD_INQUIRY
-// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
-void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4])
-{
+// Invoked when received SCSI_CMD_INQUIRY, v2 with full inquiry response
+// Some inquiry_resp's fields are already filled with default values, application can update them
+// Return length of inquiry response, typically sizeof(scsi_inquiry_resp_t) (36 bytes), can be longer if included vendor data.
+uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp) {
(void) lun;
-
const char vid[] = "TinyUSB";
const char pid[] = "Mass Storage";
const char rev[] = "1.0";
- memcpy(vendor_id , vid, strlen(vid));
- memcpy(product_id , pid, strlen(pid));
- memcpy(product_rev, rev, strlen(rev));
+ memcpy(inquiry_resp->vendor_id, vid, strlen(vid));
+ memcpy(inquiry_resp->product_id, pid, strlen(pid));
+ memcpy(inquiry_resp->product_rev, rev, strlen(rev));
+
+ return sizeof(scsi_inquiry_resp_t); // 36 bytes
}
// Invoked when received Test Unit Ready command.