Эх сурвалжийг харах

add: Unit test - don't trigger WDT when erasing chip

Adam Múdry 3 жил өмнө
parent
commit
586e738f8a

+ 1 - 0
components/spi_flash/test/test_esp_flash.c

@@ -651,4 +651,5 @@ TEST_CASE("Test esp_flash read/write performance", "[esp_flash][test_env=UT_T1_E
 #endif
 
 TEST_CASE_MULTI_FLASH("Test esp_flash read/write performance", test_flash_read_write_performance);
+
 #endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C6)

+ 5 - 1
components/spi_flash/test_apps/esp_flash/main/test_esp_flash_def.h

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Unlicense OR CC0-1.0
  */
@@ -153,6 +153,10 @@ typedef void (*flash_test_func_t)(const esp_partition_t *part);
 #define TEST_CASE_MULTI_FLASH(STR, FUNC_TO_RUN) \
     TEST_CASE(STR", "TEST_CHIP_NUM_STR" chips", "[esp_flash_multi][test_env=UT_T1_ESP_FLASH][timeout=35]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
 #endif
+
+#define TEST_CASE_MULTI_FLASH_LONG(STR, FUNC_TO_RUN) \
+    TEST_CASE(STR", "TEST_CHIP_NUM_STR" chips", "[esp_flash_multi][test_env=UT_T1_ESP_FLASH][timeout=120]") {flash_test_func(FUNC_TO_RUN, TEST_CONFIG_NUM);}
+
 #endif
 
 #define TEST_CASE_MULTI_FLASH_IGNORE(STR, FUNC_TO_RUN) \

+ 17 - 1
components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Unlicense OR CC0-1.0
  */
@@ -15,6 +15,7 @@
 #include "esp_private/spi_common_internal.h"
 #include "esp_flash_spi_init.h"
 #include "memspi_host_driver.h"
+#include "spi_flash_mmap.h"
 #include <esp_attr.h>
 #include "esp_log.h"
 
@@ -444,6 +445,21 @@ void test_erase_large_region(const esp_partition_t *part)
 TEST_CASE_FLASH("SPI flash erase large region", test_erase_large_region);
 TEST_CASE_MULTI_FLASH("SPI flash erase large region", test_erase_large_region);
 
+static void test_flash_erase_not_trigger_wdt(const esp_partition_t *part)
+{
+    spi_host_device_t out_host_id;
+    get_chip_host(part->flash_chip, &out_host_id, NULL);
+    // don't erase main flash (spi1), test only spi2 & spi3
+    if (out_host_id != SPI1_HOST) {
+        ESP_ERROR_CHECK(esp_flash_erase_chip(part->flash_chip));
+    } else {
+        ESP_LOGI(TAG, "spi1 skipped");
+    }
+}
+
+TEST_CASE_MULTI_FLASH_LONG("Test erasing flash chip not triggering WDT", test_flash_erase_not_trigger_wdt);
+
+
 #if CONFIG_SPI_FLASH_AUTO_SUSPEND
 void esp_test_for_suspend(void)
 {

+ 2 - 4
components/spi_flash/test_apps/esp_flash/pytest_esp_flash.py

@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
+# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
 # SPDX-License-Identifier: Apache-2.0
 
 import pytest
@@ -56,6 +56,4 @@ def test_esp_flash_rom(dut: Dut) -> None:
     indirect=True,
 )
 def test_esp_flash_multi(dut: Dut) -> None:
-    dut.expect_exact('Press ENTER to see the list of tests')
-    dut.write('[esp_flash_multi]')
-    dut.expect_unity_test_output()
+    dut.run_all_single_board_cases(group='esp_flash_multi', timeout=120)