From 99b6f5dcd8e94c70618704132fda69428f635ea5 Mon Sep 17 00:00:00 2001 From: "Armando (Dou Yiwen)" Date: Wed, 2 Sep 2026 16:17:33 +0800 Subject: [PATCH] test(spi_flash): verify partition protection callback registration --- .../test_apps/esp_flash/main/test_esp_flash_drv.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c b/components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c index 0d078d969a7..4827c9bb566 100644 --- a/components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c +++ b/components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c @@ -1137,6 +1137,19 @@ void test_flash_counter(const esp_partition_t* part) TEST_CASE_FLASH("SPI flash counter test", test_flash_counter); #endif //CONFIG_SPI_FLASH_ENABLE_COUNTERS +TEST_CASE("main flash partition protection callbacks are registered", "[esp_flash]") +{ + const esp_partition_t *partition = esp_partition_find_first( + ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, "flash_test"); + TEST_ASSERT_NOT_NULL(partition); + TEST_ASSERT_EQUAL_PTR(esp_flash_default_chip, partition->flash_chip); + TEST_ASSERT_NOT_NULL(esp_flash_default_chip->os_func->region_protected); + TEST_ASSERT_EQUAL( + ESP_OK, + esp_flash_default_chip->os_func->region_protected( + esp_flash_default_chip->os_func_data, partition->address, partition->erase_size)); +} + #if CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS TEST_CASE("test writes to dangerous regions like bootloader", "[esp_flash]") {