mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
4220752aed
DISABLED_FOR_TARGETS macros are used Partly revert "ci: disable unavailable tests for esp32s2beta" This partly reverts commit76a3a5fb48
. Partly revert "ci: disable UTs for esp32s2beta without runners" This partly reverts commiteb158e9a22
. Partly revert "fix unit test and examples for s2beta" This partly reverts commit9baa7826be
. Partly revert "efuse: Add support for esp32s2beta" This partly reverts commitdb84ba868c
.
48 lines
2.0 KiB
C
48 lines
2.0 KiB
C
#include "esp_flash.h"
|
|
#include "esp_partition.h"
|
|
#include "unity.h"
|
|
|
|
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2BETA)
|
|
TEST_CASE("Basic handling of a partition in external flash", "[partition]")
|
|
{
|
|
esp_flash_t flash = {
|
|
.size = 1 * 1024 * 1024,
|
|
};
|
|
|
|
const esp_partition_type_t t = ESP_PARTITION_TYPE_DATA;
|
|
const esp_partition_subtype_t st = ESP_PARTITION_SUBTYPE_DATA_FAT;
|
|
const char* label = "ext_fat";
|
|
|
|
/* can register */
|
|
const esp_partition_t* ext_partition;
|
|
TEST_ESP_OK(esp_partition_register_external(&flash, 0, flash.size, label, t, st, &ext_partition));
|
|
|
|
/* can find the registered partition */
|
|
const esp_partition_t* found = esp_partition_find_first(t, st, label);
|
|
TEST_ASSERT_EQUAL_HEX(ext_partition, found);
|
|
TEST_ASSERT_EQUAL(found->size, flash.size);
|
|
TEST_ASSERT_EQUAL(found->address, 0);
|
|
|
|
/* can deregister */
|
|
TEST_ESP_OK(esp_partition_deregister_external(ext_partition));
|
|
|
|
/* can not deregister one of the partitions on the main flash chip */
|
|
const esp_partition_t* nvs_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, NULL);
|
|
TEST_ASSERT_NOT_NULL(nvs_partition);
|
|
TEST_ESP_ERR(ESP_ERR_INVALID_ARG, esp_partition_deregister_external(nvs_partition));
|
|
|
|
/* can not deregister an unknown partition */
|
|
esp_partition_t dummy_partition = {};
|
|
TEST_ESP_ERR(ESP_ERR_NOT_FOUND, esp_partition_deregister_external(&dummy_partition));
|
|
|
|
/* can not register a partition larger than the flash size */
|
|
TEST_ESP_ERR(ESP_ERR_INVALID_SIZE,
|
|
esp_partition_register_external(&flash, 0, 2 * flash.size, "ext_fat", t, st, &ext_partition));
|
|
|
|
/* can not register an overlapping partition */
|
|
TEST_ESP_OK(esp_partition_register_external(&flash, 0, 2 * SPI_FLASH_SEC_SIZE, "p1", t, st, &ext_partition));
|
|
TEST_ESP_ERR(ESP_ERR_INVALID_ARG, esp_partition_register_external(&flash, SPI_FLASH_SEC_SIZE, 2 * SPI_FLASH_SEC_SIZE,
|
|
"p2", t, st, NULL));
|
|
TEST_ESP_OK(esp_partition_deregister_external(ext_partition));
|
|
}
|
|
#endif |