From 35251a69eb16bc7e377325028f304c80e8147c2b Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Thu, 11 Jul 2024 17:40:08 +0800 Subject: [PATCH] test(usb_serial): Add a test for printf/rom_printf after driver is installed --- .../main/test_usb_serial_jtag.c | 16 ++++++++++++ .../usb_serial_jtag/pytest_usb_serial_jtag.py | 25 ++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/main/test_usb_serial_jtag.c b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/main/test_usb_serial_jtag.c index a42ec99797..9d5ced3011 100644 --- a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/main/test_usb_serial_jtag.c +++ b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/main/test_usb_serial_jtag.c @@ -16,6 +16,7 @@ #include #include #include +#include "esp_rom_sys.h" #define PRINT_TIMES (300) static const char TAG[] = "usb_serial_test"; @@ -120,3 +121,18 @@ TEST_CASE("see if fsync appears to work", "[usb_serial_jtag]") usb_serial_jtag_vfs_use_nonblocking(); usb_serial_jtag_driver_uninstall(); } + +TEST_CASE("test rom printf work after driver installed", "[usb_serial_jtag]") +{ + usb_serial_jtag_driver_config_t cfg = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT(); + TEST_ESP_OK(usb_serial_jtag_driver_install(&cfg)); + + // Tell vfs to use usb-serial-jtag driver + usb_serial_jtag_vfs_use_driver(); + + esp_rom_printf("hi, espressif1\n"); + printf("hi, espressif2"); + + usb_serial_jtag_vfs_use_nonblocking(); + usb_serial_jtag_driver_uninstall(); +} diff --git a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/pytest_usb_serial_jtag.py b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/pytest_usb_serial_jtag.py index f53d82df69..859de671c1 100644 --- a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/pytest_usb_serial_jtag.py +++ b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/pytest_usb_serial_jtag.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 import pytest from pytest_embedded import Dut @@ -10,9 +10,9 @@ from pytest_embedded import Dut @pytest.mark.esp32h2 @pytest.mark.usb_serial_jtag @pytest.mark.parametrize( - 'port, config', + 'port, flash_port, config', [ - pytest.param('/dev/serial_ports/ttyACM-esp32', 'release'), + pytest.param('/dev/serial_ports/ttyACM-esp32', '/dev/serial_ports/ttyUSB-esp32', 'release'), ], indirect=True, ) @@ -25,3 +25,22 @@ def test_usb_serial_jtag_dev(dut: Dut) -> None: # type: ignore dut.expect_exact('Enter next test, or \'enter\' to see menu') dut.write('\"see if fsync appears to work\"') dut.expect('PASS') + + +@pytest.mark.esp32s3 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32h2 +@pytest.mark.usb_serial_jtag +@pytest.mark.parametrize( + 'port, flash_port, config', + [ + pytest.param('/dev/serial_ports/ttyACM-esp32', '/dev/serial_ports/ttyUSB-esp32', 'release'), + ], + indirect=True, +) +def test_usb_serial_jtag_rom_dev(dut: Dut) -> None: # type: ignore + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('\"test rom printf work after driver installed\"') + dut.expect(r'hi, espressif1', timeout=10) + dut.expect(r'hi, espressif2', timeout=10)