|
|
@@ -552,7 +552,7 @@ TEST_CASE("nvs api tests", "[nvs]")
|
|
|
SpiFlashEmulator emu(10);
|
|
|
emu.randomize(100);
|
|
|
|
|
|
- nvs_handle handle_1;
|
|
|
+ nvs_handle_t handle_1;
|
|
|
const uint32_t NVS_FLASH_SECTOR = 6;
|
|
|
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
|
|
|
emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
|
|
|
@@ -573,7 +573,7 @@ TEST_CASE("nvs api tests", "[nvs]")
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x12345678));
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x23456789));
|
|
|
|
|
|
- nvs_handle handle_2;
|
|
|
+ nvs_handle_t handle_2;
|
|
|
TEST_ESP_OK(nvs_open("namespace2", NVS_READWRITE, &handle_2));
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_2, "foo", 0x3456789a));
|
|
|
const char* str = "value 0123456789abcdef0123456789abcdef";
|
|
|
@@ -620,7 +620,7 @@ TEST_CASE("wifi test", "[nvs]")
|
|
|
emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
|
|
|
|
|
- nvs_handle misc_handle;
|
|
|
+ nvs_handle_t misc_handle;
|
|
|
TEST_ESP_OK(nvs_open("nvs.net80211", NVS_READWRITE, &misc_handle));
|
|
|
char log[33];
|
|
|
size_t log_size = sizeof(log);
|
|
|
@@ -628,7 +628,7 @@ TEST_CASE("wifi test", "[nvs]")
|
|
|
strcpy(log, "foobarbazfizzz");
|
|
|
TEST_ESP_OK(nvs_set_str(misc_handle, "log", log));
|
|
|
|
|
|
- nvs_handle net80211_handle;
|
|
|
+ nvs_handle_t net80211_handle;
|
|
|
TEST_ESP_OK(nvs_open("nvs.net80211", NVS_READWRITE, &net80211_handle));
|
|
|
|
|
|
uint8_t opmode = 2;
|
|
|
@@ -808,7 +808,7 @@ TEST_CASE("can init storage from flash with random contents", "[nvs]")
|
|
|
SpiFlashEmulator emu(10);
|
|
|
emu.randomize(42);
|
|
|
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
const uint32_t NVS_FLASH_SECTOR = 5;
|
|
|
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
|
|
|
emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
|
|
|
@@ -842,13 +842,13 @@ TEST_CASE("nvs api tests, starting with random data in flash", "[nvs][long]")
|
|
|
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
|
|
|
|
|
- nvs_handle handle_1;
|
|
|
+ nvs_handle_t handle_1;
|
|
|
TEST_ESP_ERR(nvs_open("namespace1", NVS_READONLY, &handle_1), ESP_ERR_NVS_NOT_FOUND);
|
|
|
|
|
|
TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle_1));
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x12345678));
|
|
|
for (size_t i = 0; i < 500; ++i) {
|
|
|
- nvs_handle handle_2;
|
|
|
+ nvs_handle_t handle_2;
|
|
|
TEST_ESP_OK(nvs_open("namespace2", NVS_READWRITE, &handle_2));
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x23456789 % (i + 1)));
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_2, "foo", static_cast<int32_t>(i)));
|
|
|
@@ -897,7 +897,7 @@ public:
|
|
|
}
|
|
|
|
|
|
template<typename TGen>
|
|
|
- esp_err_t doRandomThings(nvs_handle handle, TGen gen, size_t& count) {
|
|
|
+ esp_err_t doRandomThings(nvs_handle_t handle, TGen gen, size_t& count) {
|
|
|
|
|
|
const char* keys[] = {"foo", "bar", "longkey_0123456", "another key", "param1", "param2", "param3", "param4", "param5", "singlepage", "multipage"};
|
|
|
const ItemType types[] = {ItemType::I32, ItemType::I32, ItemType::U64, ItemType::U64, ItemType::SZ, ItemType::SZ, ItemType::SZ, ItemType::SZ, ItemType::SZ, ItemType::BLOB, ItemType::BLOB};
|
|
|
@@ -1150,7 +1150,7 @@ TEST_CASE("monkey test", "[nvs][monkey]")
|
|
|
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
|
|
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
|
|
|
RandomTest test;
|
|
|
size_t count = 1000;
|
|
|
@@ -1192,7 +1192,7 @@ TEST_CASE("test recovery from sudden poweroff", "[long][nvs][recovery][monkey]")
|
|
|
}
|
|
|
|
|
|
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
size_t count = iter_count;
|
|
|
|
|
|
if (nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN) == ESP_OK) {
|
|
|
@@ -1225,7 +1225,7 @@ TEST_CASE("test for memory leaks in open/set", "[leaks]")
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
|
|
|
|
|
for (int i = 0; i < 100000; ++i) {
|
|
|
- nvs_handle light_handle = 0;
|
|
|
+ nvs_handle_t light_handle = 0;
|
|
|
char lightbulb[1024] = {12, 13, 14, 15, 16};
|
|
|
TEST_ESP_OK(nvs_open("light", NVS_READWRITE, &light_handle));
|
|
|
TEST_ESP_OK(nvs_set_blob(light_handle, "key", lightbulb, sizeof(lightbulb)));
|
|
|
@@ -1380,7 +1380,7 @@ TEST_CASE("read/write failure (TW8406)", "[nvs]")
|
|
|
nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3);
|
|
|
for (int attempts = 0; attempts < 3; ++attempts) {
|
|
|
int i = 0;
|
|
|
- nvs_handle light_handle = 0;
|
|
|
+ nvs_handle_t light_handle = 0;
|
|
|
char key[15] = {0};
|
|
|
char data[76] = {12, 13, 14, 15, 16};
|
|
|
uint8_t number = 20;
|
|
|
@@ -1412,7 +1412,7 @@ TEST_CASE("nvs_flash_init checks for an empty page", "[nvs]")
|
|
|
uint8_t blob[blob_size] = {0};
|
|
|
SpiFlashEmulator emu(5);
|
|
|
TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5) );
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK( nvs_open("test", NVS_READWRITE, &handle) );
|
|
|
// Fill first page
|
|
|
TEST_ESP_OK( nvs_set_blob(handle, "1a", blob, blob_size) );
|
|
|
@@ -1432,7 +1432,7 @@ TEST_CASE("multiple partitions access check", "[nvs]")
|
|
|
SpiFlashEmulator emu(10);
|
|
|
TEST_ESP_OK( nvs_flash_init_custom("nvs1", 0, 5) );
|
|
|
TEST_ESP_OK( nvs_flash_init_custom("nvs2", 5, 5) );
|
|
|
- nvs_handle handle1, handle2;
|
|
|
+ nvs_handle_t handle1, handle2;
|
|
|
TEST_ESP_OK( nvs_open_from_partition("nvs1", "test", NVS_READWRITE, &handle1) );
|
|
|
TEST_ESP_OK( nvs_open_from_partition("nvs2", "test", NVS_READWRITE, &handle2) );
|
|
|
TEST_ESP_OK( nvs_set_i32(handle1, "foo", 0xdeadbeef));
|
|
|
@@ -1450,7 +1450,7 @@ TEST_CASE("nvs page selection takes into account free entries also not just eras
|
|
|
uint8_t blob[blob_size] = {0};
|
|
|
SpiFlashEmulator emu(3);
|
|
|
TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3) );
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK( nvs_open("test", NVS_READWRITE, &handle) );
|
|
|
// Fill first page
|
|
|
TEST_ESP_OK( nvs_set_blob(handle, "1a", blob, blob_size/3) );
|
|
|
@@ -1478,7 +1478,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
|
|
|
CHECK(stat1.total_entries == 0);
|
|
|
CHECK(stat1.used_entries == 0);
|
|
|
|
|
|
- nvs_handle handle = 0;
|
|
|
+ nvs_handle_t handle = 0;
|
|
|
size_t h_count_entries;
|
|
|
TEST_ESP_ERR(nvs_get_used_entry_count(handle, &h_count_entries), ESP_ERR_NVS_INVALID_HANDLE);
|
|
|
CHECK(h_count_entries == 0);
|
|
|
@@ -1498,7 +1498,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
|
|
|
CHECK(stat1.used_entries == 0);
|
|
|
|
|
|
// create namespace test_k1
|
|
|
- nvs_handle handle_1;
|
|
|
+ nvs_handle_t handle_1;
|
|
|
TEST_ESP_OK(nvs_open("test_k1", NVS_READWRITE, &handle_1));
|
|
|
TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
|
|
|
CHECK(stat2.free_entries + 1 == stat1.free_entries);
|
|
|
@@ -1535,7 +1535,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
|
|
|
TEST_ESP_OK(nvs_get_used_entry_count(handle_1, &h1_count_entries));
|
|
|
CHECK(h1_count_entries == 2);
|
|
|
|
|
|
- nvs_handle handle_2;
|
|
|
+ nvs_handle_t handle_2;
|
|
|
// create namespace test_k2
|
|
|
TEST_ESP_OK(nvs_open("test_k2", NVS_READWRITE, &handle_2));
|
|
|
TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
|
|
|
@@ -1572,7 +1572,7 @@ TEST_CASE("calculate used and free space", "[nvs]")
|
|
|
h2_count_entries = temp;
|
|
|
TEST_ESP_ERR(nvs_get_used_entry_count(handle_1, NULL), ESP_ERR_INVALID_ARG);
|
|
|
|
|
|
- nvs_handle handle_3;
|
|
|
+ nvs_handle_t handle_3;
|
|
|
// create namespace test_k3
|
|
|
TEST_ESP_OK(nvs_open("test_k3", NVS_READWRITE, &handle_3));
|
|
|
TEST_ESP_OK(nvs_get_stats(NULL, &stat2));
|
|
|
@@ -1607,7 +1607,7 @@ TEST_CASE("Recovery from power-off when the entry being erased is not on active
|
|
|
uint8_t blob[blob_size] = {0x11};
|
|
|
SpiFlashEmulator emu(3);
|
|
|
TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3) );
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK( nvs_open("test", NVS_READWRITE, &handle) );
|
|
|
|
|
|
emu.clearStats();
|
|
|
@@ -1635,7 +1635,7 @@ TEST_CASE("Recovery from power-off when page is being freed.", "[nvs]")
|
|
|
uint8_t blob[blob_size] = {0};
|
|
|
SpiFlashEmulator emu(3);
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3));
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("test", NVS_READWRITE, &handle));
|
|
|
// Fill first page
|
|
|
TEST_ESP_OK(nvs_set_blob(handle, "1a", blob, blob_size/3));
|
|
|
@@ -1675,7 +1675,7 @@ TEST_CASE("Multi-page blobs are supported", "[nvs]")
|
|
|
uint8_t blob[blob_size] = {0};
|
|
|
SpiFlashEmulator emu(5);
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5));
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("test", NVS_READWRITE, &handle));
|
|
|
TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, blob_size));
|
|
|
TEST_ESP_OK(nvs_commit(handle));
|
|
|
@@ -1688,7 +1688,7 @@ TEST_CASE("Failures are handled while storing multi-page blobs", "[nvs]")
|
|
|
uint8_t blob[blob_size] = {0};
|
|
|
SpiFlashEmulator emu(5);
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5));
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("test", NVS_READWRITE, &handle));
|
|
|
TEST_ESP_ERR(nvs_set_blob(handle, "abc", blob, blob_size), ESP_ERR_NVS_VALUE_TOO_LONG);
|
|
|
TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, Page::CHUNK_MAX_SIZE*2));
|
|
|
@@ -1704,7 +1704,7 @@ TEST_CASE("Reading multi-page blobs", "[nvs]")
|
|
|
size_t read_size = blob_size;
|
|
|
SpiFlashEmulator emu(5);
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5));
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
memset(blob, 0x11, blob_size);
|
|
|
memset(blob_read, 0xee, blob_size);
|
|
|
TEST_ESP_OK(nvs_open("readTest", NVS_READWRITE, &handle));
|
|
|
@@ -1726,7 +1726,7 @@ TEST_CASE("Modification of values for Multi-page blobs are supported", "[nvs]")
|
|
|
size_t read_size = blob_size;
|
|
|
SpiFlashEmulator emu(6);
|
|
|
TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 6) );
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
memset(blob, 0x11, blob_size);
|
|
|
memset(blob2, 0x22, blob_size);
|
|
|
memset(blob3, 0x33, blob_size);
|
|
|
@@ -1751,7 +1751,7 @@ TEST_CASE("Modification from single page blob to multi-page", "[nvs]")
|
|
|
size_t read_size = blob_size;
|
|
|
SpiFlashEmulator emu(5);
|
|
|
TEST_ESP_OK( nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5) );
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("Test", NVS_READWRITE, &handle) );
|
|
|
TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, Page::CHUNK_MAX_SIZE/2));
|
|
|
TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, blob_size));
|
|
|
@@ -1769,7 +1769,7 @@ TEST_CASE("Modification from multi-page to single page", "[nvs]")
|
|
|
size_t read_size = blob_size;
|
|
|
SpiFlashEmulator emu(5);
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 5) );
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("Test", NVS_READWRITE, &handle) );
|
|
|
TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, blob_size));
|
|
|
TEST_ESP_OK(nvs_set_blob(handle, "abc", blob, Page::CHUNK_MAX_SIZE/2));
|
|
|
@@ -1836,7 +1836,7 @@ TEST_CASE("nvs blob fragmentation test", "[nvs]")
|
|
|
CHECK(blob != NULL);
|
|
|
memset(blob, 0xEE, BLOB_SIZE);
|
|
|
const uint32_t magic = 0xff33eaeb;
|
|
|
- nvs_handle h;
|
|
|
+ nvs_handle_t h;
|
|
|
TEST_ESP_OK( nvs_open("blob_tests", NVS_READWRITE, &h) );
|
|
|
for (int i = 0; i < 128; i++) {
|
|
|
INFO("Iteration " << i << "...\n");
|
|
|
@@ -1887,7 +1887,7 @@ TEST_CASE("Check for nvs version incompatibility", "[nvs]")
|
|
|
TEST_CASE("Check that NVS supports old blob format without blob index", "[nvs]")
|
|
|
{
|
|
|
SpiFlashEmulator emu("../nvs_partition_generator/part_old_blob_format.bin");
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
|
|
|
TEST_ESP_OK( nvs_flash_init_custom("test", 0, 2) );
|
|
|
TEST_ESP_OK( nvs_open_from_partition("test", "dummyNamespace", NVS_READONLY, &handle));
|
|
|
@@ -1948,7 +1948,7 @@ TEST_CASE("monkey test with old-format blob present", "[nvs][monkey]")
|
|
|
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, NVS_FLASH_SECTOR, NVS_FLASH_SECTOR_COUNT_MIN));
|
|
|
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
|
|
|
RandomTest test;
|
|
|
|
|
|
@@ -2031,7 +2031,7 @@ TEST_CASE("Recovery from power-off during modification of blob present in old-fo
|
|
|
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3));
|
|
|
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
|
|
|
|
|
|
uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef};
|
|
|
@@ -2083,7 +2083,7 @@ TEST_CASE("Recovery from power-off during modification of blob present in old-fo
|
|
|
|
|
|
TEST_ESP_OK(nvs_flash_init_custom(NVS_DEFAULT_PART_NAME, 0, 3));
|
|
|
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
TEST_ESP_OK(nvs_open("namespace1", NVS_READWRITE, &handle));
|
|
|
|
|
|
uint8_t hexdata[] = {0x01, 0x02, 0x03, 0xab, 0xcd, 0xef};
|
|
|
@@ -2129,7 +2129,7 @@ TEST_CASE("Recovery from power-off during modification of blob present in old-fo
|
|
|
|
|
|
static void check_nvs_part_gen_args(char const *part_name, int size, char const *filename, bool is_encr, nvs_sec_cfg_t* xts_cfg)
|
|
|
{
|
|
|
- nvs_handle handle;
|
|
|
+ nvs_handle_t handle;
|
|
|
|
|
|
if (is_encr)
|
|
|
TEST_ESP_OK(nvs_flash_secure_init_custom(part_name, 0, size, xts_cfg));
|
|
|
@@ -2547,7 +2547,7 @@ TEST_CASE("test nvs apis with encryption enabled", "[nvs]")
|
|
|
SpiFlashEmulator emu(10);
|
|
|
emu.randomize(100);
|
|
|
|
|
|
- nvs_handle handle_1;
|
|
|
+ nvs_handle_t handle_1;
|
|
|
const uint32_t NVS_FLASH_SECTOR = 6;
|
|
|
const uint32_t NVS_FLASH_SECTOR_COUNT_MIN = 3;
|
|
|
emu.setBounds(NVS_FLASH_SECTOR, NVS_FLASH_SECTOR + NVS_FLASH_SECTOR_COUNT_MIN);
|
|
|
@@ -2570,7 +2570,7 @@ TEST_CASE("test nvs apis with encryption enabled", "[nvs]")
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x12345678));
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_1, "foo", 0x23456789));
|
|
|
|
|
|
- nvs_handle handle_2;
|
|
|
+ nvs_handle_t handle_2;
|
|
|
TEST_ESP_OK(nvs_open("namespace2", NVS_READWRITE, &handle_2));
|
|
|
TEST_ESP_OK(nvs_set_i32(handle_2, "foo", 0x3456789a));
|
|
|
const char* str = "value 0123456789abcdef0123456789abcdef";
|