test_partition_manager.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "catch.hpp"
  7. #include <algorithm>
  8. #include <cstring>
  9. #include "nvs_test_api.h"
  10. #include "nvs_handle_simple.hpp"
  11. #include "nvs_partition_manager.hpp"
  12. #include "spi_flash_emulation.h"
  13. #include "nvs_test_api.h"
  14. #include "test_fixtures.hpp"
  15. /*
  16. TEST_CASE("Partition manager initializes multiple partitions", "[partition_mgr]")
  17. {
  18. const uint32_t NVS_FLASH_SECTOR = 6;
  19. const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
  20. SpiFlashEmulator emu(10);
  21. PartitionEmulation part_0(&emu, NVS_FLASH_SECTOR * SPI_FLASH_SEC_SIZE, NVS_FLASH_SECTOR_COUNT_MIN * SPI_FLASH_SEC_SIZE, "test1");
  22. PartitionEmulation part_1(&emu, NVS_FLASH_SECTOR * SPI_FLASH_SEC_SIZE, NVS_FLASH_SECTOR_COUNT_MIN * SPI_FLASH_SEC_SIZE, "test2");
  23. REQUIRE(nvs::NVSPartitionManager::get_instance()->init_custom(&part_0, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN)
  24. == ESP_OK);
  25. // TODO: why does this work, actually? same sectors used as above
  26. REQUIRE(nvs::NVSPartitionManager::get_instance()->init_custom(&part_1, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN)
  27. == ESP_OK);
  28. nvs::Storage *storage1 = nvs::NVSPartitionManager::get_instance()->lookup_storage_from_name("test1");
  29. REQUIRE(storage1 != nullptr);
  30. nvs::Storage *storage2 = nvs::NVSPartitionManager::get_instance()->lookup_storage_from_name("test2");
  31. REQUIRE(storage2 != nullptr);
  32. CHECK(storage1 != storage2);
  33. REQUIRE(nvs::NVSPartitionManager::get_instance()->deinit_partition(part_0.get_partition_name()) == ESP_OK);
  34. REQUIRE(nvs::NVSPartitionManager::get_instance()->deinit_partition(part_1.get_partition_name()) == ESP_OK);
  35. }
  36. */