feat(storage/vfs): add /dev/null for unwanted output redirection

This commit is contained in:
Tomáš Rohlínek
2024-04-19 10:03:36 +02:00
parent 0b4fff69c5
commit a615f487dd
6 changed files with 349 additions and 1 deletions
+1
View File
@@ -50,6 +50,7 @@ CORE: 105: init_newlib_time in components/esp_system/startup_funcs.c on BIT(0)
CORE: 110: init_vfs_uart in components/esp_driver_uart/src/uart_vfs.c on BIT(0)
CORE: 111: init_vfs_usj in components/esp_driver_usb_serial_jtag/src/usb_serial_jtag_vfs.c on BIT(0)
CORE: 112: init_vfs_usj_sec in components/esp_driver_usb_serial_jtag/src/usb_serial_jtag_vfs.c on BIT(0)
CORE: 113: init_vfs_nullfs in components/vfs/nullfs.c on BIT(0)
CORE: 114: init_vfs_console in components/esp_vfs_console/vfs_console.c on BIT(0)
CORE: 115: init_newlib_stdio in components/newlib/newlib_init.c on BIT(0)
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <assert.h>
#include "sdkconfig.h"
#include "esp_rom_uart.h"
@@ -15,6 +16,9 @@
#include "driver/uart.h"
#include "soc/uart_channel.h"
#include <fcntl.h>
#include <unistd.h>
#if CONFIG_ESP_CONSOLE_NONE
/* Set up UART on UART_0 (console) to be able to
notify pytest test case that app booted successfully
@@ -49,6 +53,15 @@ void app_main(void)
{
printf("Hello World\n");
int fd = open("/dev/null", O_RDWR);
assert(fd >= 0); // Standard check
// Check if correct file descriptor is returned
// In this case it should be neither of 0, 1, 2 (== stdin, stdout, stderr)
assert(fd > 2);
close(fd);
#if CONFIG_ESP_CONSOLE_NONE
console_none_print();
#endif // CONFIG_ESP_CONSOLE_NONE