fix(nvs_flash): fixed failing nvs_page test

This commit is contained in:
radek.tandler 2023-09-05 15:05:23 +02:00 committed by BOT
parent e8992f500c
commit 4f659b70e1
4 changed files with 17 additions and 25 deletions

View File

@ -30,8 +30,9 @@ menu "NVS"
bool "Enable legacy nvs_set function behavior when same key is reused with different data types"
default n
help
Enabling this will switch the nvs_set family of functions to the legacy mode. When called with same
key and different data type, existing value stored in NVS remains active and as a side effect, the
new value is also stored into NVS, although not accessible using respective nvs_get function. Use only
if your application relies on this NVS API behaviour.
Enabling this option will switch the nvs_set() family of functions to the legacy mode:
when called repeatedly with the same key but different data type, the existing value
in the NVS remains active and the new value is just stored, actually not accessible through
corresponding nvs_get() call for the key given. Use this option only when your application
relies on such NVS API behaviour.
endmenu

View File

@ -1,16 +1,8 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include "unity.h"
#include "test_fixtures.hpp"
@ -863,7 +855,7 @@ void test_Page_calcEntries__uninit()
NVSPageFixture fix;
TEST_ASSERT_EQUAL(Page::PageState::UNINITIALIZED, fix.page.state());
nvs_stats_t nvsStats = {0, 0, 0, 0};
nvs_stats_t nvsStats = {0, 0, 0, 0, 0};
TEST_ASSERT_EQUAL(ESP_OK, fix.page.calcEntries(nvsStats));
TEST_ASSERT_EQUAL(0, nvsStats.used_entries);
@ -888,7 +880,7 @@ void test_Page_calcEntries__corrupt()
TEST_ASSERT_EQUAL(Page::PageState::CORRUPT, page.state());
nvs_stats_t nvsStats = {0, 0, 0, 0};
nvs_stats_t nvsStats = {0, 0, 0, 0, 0};
TEST_ASSERT_EQUAL(ESP_OK, page.calcEntries(nvsStats));
TEST_ASSERT_EQUAL(0, nvsStats.used_entries);
@ -901,7 +893,7 @@ void test_Page_calcEntries__active_wo_blob()
{
NVSValidPageFixture fix;
nvs_stats_t nvsStats = {0, 0, 0, 0};
nvs_stats_t nvsStats = {0, 0, 0, 0, 0};
TEST_ASSERT_EQUAL(ESP_OK, fix.page.calcEntries(nvsStats));
TEST_ASSERT_EQUAL(2, nvsStats.used_entries);
@ -914,7 +906,7 @@ void test_Page_calcEntries__active_with_blob()
{
NVSValidBlobPageFixture fix;
nvs_stats_t nvsStats = {0, 0, 0, 0};
nvs_stats_t nvsStats = {0, 0, 0, 0, 0};
TEST_ASSERT_EQUAL(ESP_OK, fix.page.calcEntries(nvsStats));
TEST_ASSERT_EQUAL(4, nvsStats.used_entries);
@ -927,7 +919,7 @@ void test_Page_calcEntries__invalid()
{
Page page;
nvs_stats_t nvsStats = {0, 0, 0, 0};
nvs_stats_t nvsStats = {0, 0, 0, 0, 0};
TEST_ASSERT_EQUAL(Page::PageState::INVALID, page.state());

View File

@ -291,7 +291,7 @@ esp_err_t Storage::writeItem(uint8_t nsIndex, ItemType datatype, const char* key
esp_err_t err;
if (datatype == ItemType::BLOB) {
err = findItem(nsIndex, ItemType::BLOB_IDX, key, findPage, item);
if(err == ESP_OK && findPage != nullptr) {
if(err == ESP_OK) {
matchedTypePageFound = true;
}
} else {
@ -302,7 +302,7 @@ esp_err_t Storage::writeItem(uint8_t nsIndex, ItemType datatype, const char* key
}
#else
err = findItem(nsIndex, ItemType::ANY, key, findPage, item);
if(err == ESP_OK && findPage != nullptr && datatype == item.datatype) {
if(err == ESP_OK && datatype == item.datatype) {
matchedTypePageFound = true;
}
#endif

View File

@ -587,7 +587,6 @@ components/mbedtls/port/include/sha512_alt.h
components/mbedtls/port/sha/dma/include/esp_sha_dma_priv.h
components/mbedtls/port/sha/dma/sha.c
components/mbedtls/port/sha/parallel_engine/sha.c
components/nvs_flash/host_test/nvs_page_test/main/nvs_page_test.cpp
components/nvs_flash/include/nvs_handle.hpp
components/nvs_flash/src/nvs_cxx_api.cpp
components/nvs_flash/src/nvs_encrypted_partition.hpp