From 0a352a6ff2f233401e300174bb40137caf55588e Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 29 Sep 2022 22:37:01 +0200 Subject: [PATCH] vfs, spi_flash: re-enable unit tests for C2 --- components/spi_flash/test/test_partitions.c | 3 -- components/vfs/test/test_vfs_access.c | 3 -- components/vfs/test/test_vfs_append.c | 3 -- components/vfs/test/test_vfs_select.c | 3 -- components/vfs/test/test_vfs_uart.c | 33 +++++++++++-------- .../unit-test-app/sdkconfig.defaults.esp32c2 | 3 ++ 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/components/spi_flash/test/test_partitions.c b/components/spi_flash/test/test_partitions.c index d916de7c74..f4c47c1562 100644 --- a/components/spi_flash/test/test_partitions.c +++ b/components/spi_flash/test/test_partitions.c @@ -61,8 +61,6 @@ TEST_CASE("Test erase partition", "[spi_flash][esp_flash]") } } -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5137 static bool s_test_nonzero_sha_of_partition(const esp_partition_t *part, bool allow_invalid_image) { uint8_t sha256[32] = { 0 }; @@ -140,4 +138,3 @@ TEST_CASE("Test esp_partition_get_sha256() that it can handle a big partition", spi_flash_munmap(handle); } -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/vfs/test/test_vfs_access.c b/components/vfs/test/test_vfs_access.c index 2fe9fb1fb0..f76d1de7a3 100644 --- a/components/vfs/test/test_vfs_access.c +++ b/components/vfs/test/test_vfs_access.c @@ -89,8 +89,6 @@ static inline void test_fatfs_delete_file(const char *name) TEST_ASSERT_EQUAL(ret, 0); } -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5139 TEST_CASE("Can use access() for FATFS", "[vfs][fatfs][wear_levelling]") { const char *path = "/spiflash/access.txt"; @@ -130,4 +128,3 @@ TEST_CASE("Can use access() for FATFS", "[vfs][fatfs][wear_levelling]") test_spi_flash_teardown(); } -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/vfs/test/test_vfs_append.c b/components/vfs/test/test_vfs_append.c index 6efa8a725a..0a951ea490 100644 --- a/components/vfs/test/test_vfs_append.c +++ b/components/vfs/test/test_vfs_append.c @@ -78,8 +78,6 @@ static void test_append(const char *path) TEST_ASSERT_NOT_EQUAL(-1, unlink(path)); } -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5139 TEST_CASE("open() with O_APPEND on FATFS works well", "[vfs][FATFS]") { wl_handle_t test_wl_handle; @@ -94,7 +92,6 @@ TEST_CASE("open() with O_APPEND on FATFS works well", "[vfs][FATFS]") TEST_ESP_OK(esp_vfs_fat_spiflash_unmount_rw_wl("/spiflash", test_wl_handle)); } -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) TEST_CASE("open() with O_APPEND on SPIFFS works well", "[vfs][spiffs]") { diff --git a/components/vfs/test/test_vfs_select.c b/components/vfs/test/test_vfs_select.c index badb69e0b5..8568f2c284 100644 --- a/components/vfs/test/test_vfs_select.c +++ b/components/vfs/test/test_vfs_select.c @@ -544,8 +544,6 @@ TEST_CASE("concurrent selects work", "[vfs]") close(dummy_socket_fd); } -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5139 TEST_CASE("select() works with concurrent mount", "[vfs][fatfs]") { wl_handle_t test_wl_handle; @@ -607,4 +605,3 @@ TEST_CASE("select() works with concurrent mount", "[vfs][fatfs]") deinit(uart_fd, socket_fd); close(dummy_socket_fd); } -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/vfs/test/test_vfs_uart.c b/components/vfs/test/test_vfs_uart.c index 6ffd7cd4b5..83a356d23c 100644 --- a/components/vfs/test/test_vfs_uart.c +++ b/components/vfs/test/test_vfs_uart.c @@ -208,8 +208,6 @@ TEST_CASE("fcntl supported in UART VFS", "[vfs]") } #ifdef CONFIG_VFS_SUPPORT_TERMIOS -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5139 TEST_CASE("Can use termios for UART", "[vfs]") { uart_config_t uart_config = { @@ -303,31 +301,41 @@ TEST_CASE("Can use termios for UART", "[vfs]") TEST_ASSERT_EQUAL(0, tcsetattr(uart_fd, TCSANOW, &tios)); TEST_ASSERT_EQUAL(0, tcgetattr(uart_fd, &tios_result)); TEST_ASSERT_EQUAL(CBAUD, tios_result.c_cflag & CBAUD); - TEST_ASSERT_EQUAL(B38400, tios_result.c_ispeed); - TEST_ASSERT_EQUAL(B38400, tios_result.c_ospeed); TEST_ASSERT_EQUAL(ESP_OK, uart_get_baudrate(UART_NUM_1, &baudrate)); - TEST_ASSERT_EQUAL(38400, baudrate); + TEST_ASSERT_INT32_WITHIN(2, 38400, baudrate); + if (APB_CLK_FREQ == 40000000) { + // Setting the speed to 38400 will set it actually to 38401 + // Note: can't use TEST_ASSERT_INT32_WITHIN here because B38400 == 15 + TEST_ASSERT_EQUAL(38401, tios_result.c_ispeed); + TEST_ASSERT_EQUAL(38401, tios_result.c_ospeed); + } else { + TEST_ASSERT_EQUAL(B38400, tios_result.c_ispeed); + TEST_ASSERT_EQUAL(B38400, tios_result.c_ospeed); + } tios.c_cflag |= CBAUDEX; tios.c_ispeed = tios.c_ospeed = B230400; TEST_ASSERT_EQUAL(0, tcsetattr(uart_fd, TCSANOW, &tios)); TEST_ASSERT_EQUAL(0, tcgetattr(uart_fd, &tios_result)); TEST_ASSERT_EQUAL(BOTHER, tios_result.c_cflag & BOTHER); - // Setting the speed to 230400 will set it actually to 230423 - TEST_ASSERT_EQUAL(230423, tios_result.c_ispeed); - TEST_ASSERT_EQUAL(230423, tios_result.c_ospeed); TEST_ASSERT_EQUAL(ESP_OK, uart_get_baudrate(UART_NUM_1, &baudrate)); - TEST_ASSERT_EQUAL(230423, baudrate); + // Setting the speed to 230400 will set it actually to something else, + // depending on the APB clock + TEST_ASSERT_INT32_WITHIN(100, 230400, tios_result.c_ispeed); + TEST_ASSERT_INT32_WITHIN(100, 230400, tios_result.c_ospeed); + TEST_ASSERT_INT32_WITHIN(100, 230400, baudrate); tios.c_cflag |= BOTHER; tios.c_ispeed = tios.c_ospeed = 42321; TEST_ASSERT_EQUAL(0, tcsetattr(uart_fd, TCSANOW, &tios)); TEST_ASSERT_EQUAL(0, tcgetattr(uart_fd, &tios_result)); TEST_ASSERT_EQUAL(BOTHER, tios_result.c_cflag & BOTHER); - TEST_ASSERT_EQUAL(42321, tios_result.c_ispeed); - TEST_ASSERT_EQUAL(42321, tios_result.c_ospeed); TEST_ASSERT_EQUAL(ESP_OK, uart_get_baudrate(UART_NUM_1, &baudrate)); - TEST_ASSERT_EQUAL(42321, baudrate); + // Setting the speed to 230400 will set it actually to something else, + // depending on the APB clock + TEST_ASSERT_INT32_WITHIN(10, 42321, tios_result.c_ispeed); + TEST_ASSERT_INT32_WITHIN(10, 42321, tios_result.c_ospeed); + TEST_ASSERT_INT32_WITHIN(10, 42321, baudrate); memset(&tios_result, 0xFF, sizeof(struct termios)); } @@ -336,5 +344,4 @@ TEST_CASE("Can use termios for UART", "[vfs]") close(uart_fd); uart_driver_delete(UART_NUM_1); } -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) #endif // CONFIG_VFS_SUPPORT_TERMIOS diff --git a/tools/unit-test-app/sdkconfig.defaults.esp32c2 b/tools/unit-test-app/sdkconfig.defaults.esp32c2 index 5bb0b940f9..37b91ad9cd 100644 --- a/tools/unit-test-app/sdkconfig.defaults.esp32c2 +++ b/tools/unit-test-app/sdkconfig.defaults.esp32c2 @@ -2,3 +2,6 @@ CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partition_table_unit_test_app_2m.csv" CONFIG_PARTITION_TABLE_FILENAME="partition_table_unit_test_app_2m.csv" + +# 2MB partition table has a FAT partition too small for 4k sectors +CONFIG_WL_SECTOR_SIZE_512=y