mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
Merge branch 'fix/incorrect_console_open_and_close_behaviour_v5.3' into 'release/v5.3'
fix(storage/vfs_console): stop new console opens from overwriting existing fds (v5.3) See merge request espressif/esp-idf!35268
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
components/esp_system/test_apps/console:
|
||||
disable:
|
||||
- if: CONFIG_NAME == "serial_jtag_only" and SOC_USB_SERIAL_JTAG_SUPPORTED != 1
|
||||
- if: CONFIG_NAME == "simple" and IDF_TARGET != "esp32"
|
||||
|
||||
components/esp_system/test_apps/esp_system_unity_tests:
|
||||
disable:
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "esp_rom_uart.h"
|
||||
@@ -45,6 +49,24 @@ static void console_none_print(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_VFS_SUPPORT_IO
|
||||
static void console_open_close_check(void)
|
||||
{
|
||||
printf("Opening /dev/console\n");
|
||||
int fd = open("/dev/console", O_RDWR);
|
||||
assert(fd >= 0 && "Could not open file");
|
||||
|
||||
const char *msg = "This should be printed to stdout\n";
|
||||
|
||||
write(fd, msg, strlen(msg));
|
||||
|
||||
printf("Closing /dev/console\n");
|
||||
close(fd);
|
||||
|
||||
printf("This should be printed to stdout\n");
|
||||
}
|
||||
#endif // CONFIG_VFS_SUPPORT_IO
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("Hello World\n");
|
||||
@@ -52,4 +74,9 @@ void app_main(void)
|
||||
#if CONFIG_ESP_CONSOLE_NONE
|
||||
console_none_print();
|
||||
#endif // CONFIG_ESP_CONSOLE_NONE
|
||||
|
||||
#if CONFIG_VFS_SUPPORT_IO
|
||||
console_open_close_check();
|
||||
#endif // CONFIG_VFS_SUPPORT_IO
|
||||
|
||||
}
|
||||
|
||||
@@ -38,12 +38,46 @@ def test_esp_system_console_no_output_uart(dut: Dut) -> None:
|
||||
|
||||
@pytest.mark.usb_serial_jtag
|
||||
@pytest.mark.parametrize(
|
||||
'port, config',
|
||||
'port, flash_port, config',
|
||||
[
|
||||
pytest.param('/dev/serial_ports/ttyACM-esp32', 'serial_jtag_only', marks=JTAG_SERIAL_MARKS),
|
||||
pytest.param('/dev/serial_ports/ttyACM-esp32', '/dev/serial_ports/ttyUSB-esp32', 'serial_jtag_only', marks=JTAG_SERIAL_MARKS),
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
def test_esp_system_console_only_serial_jtag(dut: Dut) -> None:
|
||||
dut.expect('2nd stage bootloader')
|
||||
dut.expect('Hello World')
|
||||
dut.expect('Opening /dev/console')
|
||||
dut.expect('This should be printed to stdout')
|
||||
dut.expect('Closing /dev/console')
|
||||
dut.expect('This should be printed to stdout')
|
||||
|
||||
|
||||
@pytest.mark.usb_serial_jtag
|
||||
@pytest.mark.parametrize(
|
||||
'port, flash_port, config',
|
||||
[
|
||||
pytest.param('/dev/serial_ports/ttyACM-esp32', '/dev/serial_ports/ttyUSB-esp32', 'serial_jtag_only_no_vfs', marks=JTAG_SERIAL_MARKS),
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
def test_esp_system_console_only_serial_jtag_no_vfs(dut: Dut) -> None:
|
||||
dut.expect('2nd stage bootloader')
|
||||
dut.expect('Hello World')
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize(
|
||||
'config',
|
||||
[
|
||||
pytest.param('simple', marks=pytest.mark.supported_targets),
|
||||
],
|
||||
indirect=True
|
||||
)
|
||||
def test_esp_system_console_correct_open_and_close(dut: Dut) -> None:
|
||||
dut.expect('2nd stage bootloader')
|
||||
dut.expect('Hello World')
|
||||
dut.expect('Opening /dev/console')
|
||||
dut.expect('This should be printed to stdout')
|
||||
dut.expect('Closing /dev/console')
|
||||
dut.expect('This should be printed to stdout')
|
||||
|
||||
Reference in New Issue
Block a user