From 3c564fd947bbaa9042930afc83ed1afd5a073242 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 11 Nov 2024 18:40:31 +0700 Subject: [PATCH] try adding host test for p4 --- test/hil/hil_test.py | 46 ++++++++++++++++++++++++++++++++++++------- test/hil/tinyusb.json | 8 ++++---- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index 0d7cae77e..4a0510223 100755 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -224,14 +224,13 @@ def flash_uniflash(board, firmware): # ------------------------------------------------------------- # Tests: dual # ------------------------------------------------------------- - def test_dual_host_info_to_device_cdc(board): uid = board['uid'] - declared_devs = [f'{d["vid_pid"]}_{d["serial"]}' for d in board['tests']['dual_attached']] + declared_devs = [f'{d["vid_pid"]}_{d["serial"]}' for d in board['tests']['dev_attached']] - port = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 0) + port = get_serial_dev(board["flasher_sn"], None, None, 0) ser = open_serial_dev(port) - # read from cdc, first line should contain vid/pid and serial + # read from serial, first line should contain vid/pid and serial data = ser.read(1000) lines = data.decode('utf-8').splitlines() enum_dev_sn = [] @@ -251,6 +250,39 @@ def test_dual_host_info_to_device_cdc(board): return 0 +# ------------------------------------------------------------- +# Tests: host +# ------------------------------------------------------------- +def test_host_cdc_msc_hid(board): + uid = board['uid'] + declared_devs = [f'{d["vid_pid"]}_{d["serial"]}' for d in board['tests']['dev_attached']] + + port = get_serial_dev(uid, 'TinyUSB', "TinyUSB_Device", 0) + ser = open_serial_dev(port) + # read from serial, first line should contain vid/pid and serial + data = ser.read(1000) + lines = data.decode('utf-8').splitlines() + enum_dev_sn = [] + for l in lines: + vid_pid_sn = re.search(r'ID ([0-9a-fA-F]+):([0-9a-fA-F]+) SN (\w+)', l) + if vid_pid_sn: + print(f'\r\n {l} ', end='') + enum_dev_sn.append(f'{vid_pid_sn.group(1)}_{vid_pid_sn.group(2)}_{vid_pid_sn.group(3)}') + + if set(declared_devs) != set(enum_dev_sn): + # for pico/pico2 make this test optional + failed_msg = f'Enumerated devices {enum_dev_sn} not match with declared {declared_devs}' + if 'raspberry_pi_pico' in board['name']: + print(f'\r\n {failed_msg} {STATUS_FAILED} ', end='') + else: + assert False, failed_msg + return 0 + + +def test_host_cdc_msc_hid_freertos(board): + test_host_cdc_msc_hid(board) + + # ------------------------------------------------------------- # Tests: device # ------------------------------------------------------------- @@ -397,7 +429,7 @@ device_tests = [ 'device/hid_boot_interface', ] -dual_tests = [ +host_tests = [ 'dual/host_info_to_device_cdc', ] @@ -411,8 +443,8 @@ def test_board(board): if 'tests' in board: board_tests = board['tests'] - if 'dual_attached' in board_tests: - test_list += dual_tests + if 'dev_attached' in board_tests: + test_list += host_tests if 'only' in board_tests: test_list = board_tests['only'] if 'skip' in board_tests: diff --git a/test/hil/tinyusb.json b/test/hil/tinyusb.json index ea5345126..1b0b7c99a 100644 --- a/test/hil/tinyusb.json +++ b/test/hil/tinyusb.json @@ -4,7 +4,7 @@ "name": "espressif_p4_function_ev", "uid": "6055F9F98715", "tests": { - "only": ["device/cdc_msc_freertos", "device/hid_composite_freertos"] + "only": ["device/cdc_msc_freertos", "device/hid_composite_freertos", "host/cdc_msc_hid_freertos"] }, "flasher": "esptool", "flasher_sn": "4ea4f48f6bc3ee11bbb9d00f9e1b1c54", @@ -44,7 +44,7 @@ "flasher_sn": "123456", "flasher_args": "-device ATSAMD51J19", "tests": { - "dual_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002130"}] + "dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002130"}] } }, { @@ -72,7 +72,7 @@ "flasher_sn": "E6614103E72C1D2F", "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\"", "tests": { - "dual_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002470"}] + "dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002470"}] } }, { @@ -82,7 +82,7 @@ "flasher_sn": "E6633861A3978538", "flasher_args": "-f interface/cmsis-dap.cfg -f target/rp2350.cfg -c \"adapter speed 5000\"", "tests": { - "dual_attached": [{"vid_pid": "1a86_55d4", "serial": "533D004242"}] + "dev_attached": [{"vid_pid": "1a86_55d4", "serial": "533D004242"}] } }, {