test(usb_serial): Add a test for printf/rom_printf after driver is installed

This commit is contained in:
C.S.M 2024-07-11 17:40:08 +08:00 committed by BOT
parent a263f833c9
commit 35251a69eb
2 changed files with 38 additions and 3 deletions

View File

@ -16,6 +16,7 @@
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
#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();
}

View File

@ -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)