diff --git a/src/platform/Zephyr/KeyValueStoreManagerImpl.cpp b/src/platform/Zephyr/KeyValueStoreManagerImpl.cpp index 178cb77348e398..35c205db549815 100644 --- a/src/platform/Zephyr/KeyValueStoreManagerImpl.cpp +++ b/src/platform/Zephyr/KeyValueStoreManagerImpl.cpp @@ -47,11 +47,43 @@ struct DeleteSubtreeEntry CHIP_ERROR result; }; +// Random magic bytes to represent an empty value. +// It is needed because Zephyr settings subsystem does not distinguish an empty value from no value. +constexpr uint8_t kEmptyValue[] = { 0x22, 0xa6, 0x54, 0xd1, 0x39 }; +constexpr size_t kEmptyValueSize = sizeof(kEmptyValue); + // Prefix the input key with CHIP_DEVICE_CONFIG_SETTINGS_KEY "/" CHIP_ERROR MakeFullKey(char (&fullKey)[SETTINGS_MAX_NAME_LEN + 1], const char * key) { - const int result = snprintf(fullKey, sizeof(fullKey), CHIP_DEVICE_CONFIG_SETTINGS_KEY "/%s", key); - VerifyOrReturnError(result > 0 && static_cast(result) < sizeof(fullKey), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(key != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + strcpy(fullKey, CHIP_DEVICE_CONFIG_SETTINGS_KEY "/"); + + char * dest = fullKey + strlen(CHIP_DEVICE_CONFIG_SETTINGS_KEY "/"); + char * destEnd = fullKey + SETTINGS_MAX_NAME_LEN; + + while (*key != '\0') + { + char keyChar = *key++; + bool escape = keyChar == '\\' || keyChar == '='; + + if (keyChar == '=') + { + // '=' character is forbidden in a Zephyr setting key, so it must be escaped with "\e". + keyChar = 'e'; + } + + if (escape) + { + VerifyOrReturnError(dest < destEnd, CHIP_ERROR_INVALID_ARGUMENT); + *dest++ = '\\'; + } + + VerifyOrReturnError(dest < destEnd, CHIP_ERROR_INVALID_ARGUMENT); + *dest++ = keyChar; + } + + *dest = 0; + return CHIP_NO_ERROR; } @@ -59,11 +91,23 @@ int LoadEntryCallback(const char * name, size_t entrySize, settings_read_cb read { ReadEntry & entry = *static_cast(param); - // If requested a key X, process just node X and ignore all its descendants: X/* - if (settings_name_next(name, nullptr) > 0) + // If requested key X, process just node X and ignore all its descendants: X/* + if (name != nullptr && *name != '\0') return 0; - // Found requested key + // Found requested key. + uint8_t emptyValue[kEmptyValueSize]; + + if (entrySize == kEmptyValueSize && readCb(cbArg, emptyValue, kEmptyValueSize) == kEmptyValueSize && + memcmp(emptyValue, kEmptyValue, kEmptyValueSize) == 0) + { + // Special case - an empty value represented by known magic bytes. + entry.result = CHIP_NO_ERROR; + + // Return 1 to stop processing further keys + return 1; + } + const ssize_t bytesRead = readCb(cbArg, entry.destination, entry.destinationBufferSize); entry.readSize = bytesRead > 0 ? bytesRead : 0; @@ -106,8 +150,6 @@ void KeyValueStoreManagerImpl::Init() CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size, size_t offset_bytes) const { - VerifyOrReturnError(key, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(value, CHIP_ERROR_INVALID_ARGUMENT); // Offset and partial reads are not supported, for now just return NOT_IMPLEMENTED. // Support can be added in the future if this is needed. VerifyOrReturnError(offset_bytes == 0, CHIP_ERROR_NOT_IMPLEMENTED); @@ -120,20 +162,24 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t // Assign readSize only in case read_bytes_size is not nullptr, as it is optional argument if (read_bytes_size) + { *read_bytes_size = entry.readSize; + } return entry.result; } CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size) { - VerifyOrReturnError(key, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(value, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(value_size > 0, CHIP_ERROR_INVALID_ARGUMENT); - char fullKey[SETTINGS_MAX_NAME_LEN + 1]; ReturnErrorOnFailure(MakeFullKey(fullKey, key)); + if (value_size == 0) + { + value = kEmptyValue; + value_size = kEmptyValueSize; + } + VerifyOrReturnError(settings_save_one(fullKey, value, value_size) == 0, CHIP_ERROR_PERSISTED_STORAGE_FAILED); return CHIP_NO_ERROR; @@ -144,8 +190,9 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Delete(const char * key) char fullKey[SETTINGS_MAX_NAME_LEN + 1]; ReturnErrorOnFailure(MakeFullKey(fullKey, key)); - if (settings_delete(fullKey) != 0) - return CHIP_ERROR_PERSISTED_STORAGE_FAILED; + ReturnErrorCodeIf(Get(key, nullptr, 0) == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND, + CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + ReturnErrorCodeIf(settings_delete(fullKey) != 0, CHIP_ERROR_PERSISTED_STORAGE_FAILED); return CHIP_NO_ERROR; } diff --git a/src/platform/Zephyr/ZephyrConfig.cpp b/src/platform/Zephyr/ZephyrConfig.cpp index 4b23651ff8a11a..72b2ab201fca8e 100644 --- a/src/platform/Zephyr/ZephyrConfig.cpp +++ b/src/platform/Zephyr/ZephyrConfig.cpp @@ -98,8 +98,8 @@ struct ReadRequest // Callback for Zephyr's settings_load_subtree_direct() function int ConfigValueCallback(const char * name, size_t configSize, settings_read_cb readCb, void * cbArg, void * param) { - // If requested a config key X, process just node X and ignore all its descendants: X/* - if (settings_name_next(name, nullptr) > 0) + // If requested config key X, process just node X and ignore all its descendants: X/* + if (name != nullptr && *name != '\0') return 0; ReadRequest & request = *reinterpret_cast(param); diff --git a/src/platform/tests/TestKeyValueStoreMgr.cpp b/src/platform/tests/TestKeyValueStoreMgr.cpp index 938e6b476c2f00..acb3e5533e8a3a 100644 --- a/src/platform/tests/TestKeyValueStoreMgr.cpp +++ b/src/platform/tests/TestKeyValueStoreMgr.cpp @@ -34,167 +34,252 @@ using namespace chip; using namespace chip::DeviceLayer; using namespace chip::DeviceLayer::PersistedStorage; -static void TestKeyValueStoreMgr_EmptyStringKey(nlTestSuite * inSuite, void * inContext) +static void TestKeyValueStoreMgr_EmptyString(nlTestSuite * inSuite, void * inContext) { - CHIP_ERROR err; - const char * kTestKey = "str_key"; - const char kTestValue[] = ""; - char read_value[sizeof(kTestValue)]; - size_t read_size; - err = KeyValueStoreMgr().Put(kTestKey, kTestValue); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = KeyValueStoreMgr().Get(kTestKey, read_value, sizeof(read_value), &read_size); + constexpr const char * kTestKey = "str_key"; + constexpr const char kTestValue[] = ""; + constexpr size_t kTestValueLen = 0; + + char readValue[sizeof(kTestValue)]; + size_t readSize; + + CHIP_ERROR err = KeyValueStoreMgr().Put(kTestKey, kTestValue, kTestValueLen); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Verify if read value is the same as wrote one - NL_TEST_ASSERT(inSuite, strcmp(kTestValue, read_value) == 0); - NL_TEST_ASSERT(inSuite, read_size == sizeof(kTestValue)); + err = KeyValueStoreMgr().Get(kTestKey, readValue, sizeof(readValue), &readSize); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, readSize == kTestValueLen); + + // Verify that read succeeds even if 0-length buffer is provided + err = KeyValueStoreMgr().Get(kTestKey, readValue, 0, &readSize); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, readSize == kTestValueLen); + + err = KeyValueStoreMgr().Get(kTestKey, nullptr, 0, &readSize); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, readSize == kTestValueLen); + + // Verify deletion err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Try to get deleted key and verify if CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND is returned - err = KeyValueStoreMgr().Get(kTestKey, read_value, sizeof(read_value), &read_size); + err = KeyValueStoreMgr().Get(kTestKey, readValue, sizeof(readValue), &readSize); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); } -static void TestKeyValueStoreMgr_StringKey(nlTestSuite * inSuite, void * inContext) +static void TestKeyValueStoreMgr_String(nlTestSuite * inSuite, void * inContext) { - CHIP_ERROR err; - const char * kTestKey = "str_key"; - const char kTestValue[] = "test_value"; - char read_value[sizeof(kTestValue)]; - size_t read_size; - err = KeyValueStoreMgr().Put(kTestKey, kTestValue); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = KeyValueStoreMgr().Get(kTestKey, read_value, sizeof(read_value), &read_size); + constexpr const char * kTestKey = "str_key"; + constexpr const char kTestValue[] = "test_value"; + + char readValue[sizeof(kTestValue)]; + size_t readSize; + + CHIP_ERROR err = KeyValueStoreMgr().Put(kTestKey, kTestValue); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Verify if read value is the same as wrote one - NL_TEST_ASSERT(inSuite, strcmp(kTestValue, read_value) == 0); - NL_TEST_ASSERT(inSuite, read_size == sizeof(kTestValue)); + err = KeyValueStoreMgr().Get(kTestKey, readValue, sizeof(readValue), &readSize); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, strcmp(kTestValue, readValue) == 0); + NL_TEST_ASSERT(inSuite, readSize == sizeof(kTestValue)); + + // Verify deletion err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Try to get deleted key and verify if CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND is returned - err = KeyValueStoreMgr().Get(kTestKey, read_value, sizeof(read_value), &read_size); + err = KeyValueStoreMgr().Get(kTestKey, readValue, sizeof(readValue), &readSize); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); } -static void TestKeyValueStoreMgr_Uint32Key(nlTestSuite * inSuite, void * inContext) +static void TestKeyValueStoreMgr_Uint32(nlTestSuite * inSuite, void * inContext) { - CHIP_ERROR err; - const char * kTestKey = "uint32_key"; - const uint32_t kTestValue = 5; - uint32_t read_value; - err = KeyValueStoreMgr().Put(kTestKey, kTestValue); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = KeyValueStoreMgr().Get(kTestKey, &read_value); + constexpr const char * kTestKey = "uint32_key"; + constexpr const uint32_t kTestValue = 5; + + uint32_t readValue = UINT32_MAX; + + CHIP_ERROR err = KeyValueStoreMgr().Put(kTestKey, kTestValue); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Verify if read value is the same as wrote one - NL_TEST_ASSERT(inSuite, kTestValue == read_value); + err = KeyValueStoreMgr().Get(kTestKey, &readValue); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, kTestValue == readValue); + + // Verify deletion err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Try to get deleted key and verify if CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND is returned - err = KeyValueStoreMgr().Get(kTestKey, &read_value); + err = KeyValueStoreMgr().Get(kTestKey, &readValue); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); } -static void TestKeyValueStoreMgr_ArrayKey(nlTestSuite * inSuite, void * inContext) +static void TestKeyValueStoreMgr_Array(nlTestSuite * inSuite, void * inContext) { - CHIP_ERROR err; - const char * kTestKey = "array_key"; - uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; - uint32_t read_value[5]; - size_t read_size; - err = KeyValueStoreMgr().Put(kTestKey, kTestValue); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = KeyValueStoreMgr().Get(kTestKey, read_value, sizeof(read_value), &read_size); + constexpr const char * kTestKey = "array_key"; + constexpr uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; + + uint32_t readValue[5]; + size_t readSize; + + CHIP_ERROR err = KeyValueStoreMgr().Put(kTestKey, kTestValue); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Verify if read value is the same as wrote one - NL_TEST_ASSERT(inSuite, memcmp(kTestValue, read_value, sizeof(kTestValue)) == 0); - NL_TEST_ASSERT(inSuite, read_size == sizeof(kTestValue)); + err = KeyValueStoreMgr().Get(kTestKey, readValue, sizeof(readValue), &readSize); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, memcmp(kTestValue, readValue, sizeof(kTestValue)) == 0); + NL_TEST_ASSERT(inSuite, readSize == sizeof(kTestValue)); + + // Verify deletion err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Try to get deleted key and verify if CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND is returned - err = KeyValueStoreMgr().Get(kTestKey, read_value, sizeof(read_value), &read_size); + err = KeyValueStoreMgr().Get(kTestKey, readValue, sizeof(readValue), &readSize); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); } -static void TestKeyValueStoreMgr_StructKey(nlTestSuite * inSuite, void * inContext) +static void TestKeyValueStoreMgr_Struct(nlTestSuite * inSuite, void * inContext) { - CHIP_ERROR err; struct TestStruct { uint8_t value1; uint32_t value2; }; - const char * kTestKey = "struct_key"; - TestStruct kTestValue{ 1, 2 }; - TestStruct read_value; - size_t read_size; - err = KeyValueStoreMgr().Put(kTestKey, kTestValue); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = KeyValueStoreMgr().Get(kTestKey, &read_value, sizeof(read_value), &read_size); + + constexpr const char * kTestKey = "struct_key"; + constexpr TestStruct kTestValue{ 1, 2 }; + + TestStruct readValue; + size_t readSize; + + CHIP_ERROR err = KeyValueStoreMgr().Put(kTestKey, kTestValue); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Verify if read value is the same as wrote one - NL_TEST_ASSERT(inSuite, kTestValue.value1 == read_value.value1); - NL_TEST_ASSERT(inSuite, kTestValue.value2 == read_value.value2); - NL_TEST_ASSERT(inSuite, read_size == sizeof(kTestValue)); + err = KeyValueStoreMgr().Get(kTestKey, &readValue, sizeof(readValue), &readSize); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, kTestValue.value1 == readValue.value1); + NL_TEST_ASSERT(inSuite, kTestValue.value2 == readValue.value2); + NL_TEST_ASSERT(inSuite, readSize == sizeof(kTestValue)); + + // Verify deletion err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Try to get deleted key and verify if CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND is returned - err = KeyValueStoreMgr().Get(kTestKey, &read_value, sizeof(read_value), &read_size); + err = KeyValueStoreMgr().Get(kTestKey, &readValue, sizeof(readValue), &readSize); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); } -static void TestKeyValueStoreMgr_UpdateKeyValue(nlTestSuite * inSuite, void * inContext) +static void TestKeyValueStoreMgr_UpdateValue(nlTestSuite * inSuite, void * inContext) { + constexpr const char * kTestKey = "update_key"; + CHIP_ERROR err; - const char * kTestKey = "update_key"; - uint32_t read_value; + uint32_t readValue; + for (uint32_t i = 0; i < 10; i++) { err = KeyValueStoreMgr().Put(kTestKey, i); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = KeyValueStoreMgr().Get(kTestKey, &read_value); + + err = KeyValueStoreMgr().Get(kTestKey, &readValue); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - NL_TEST_ASSERT(inSuite, i == read_value); + NL_TEST_ASSERT(inSuite, i == readValue); } + err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); } static void TestKeyValueStoreMgr_TooSmallBufferRead(nlTestSuite * inSuite, void * inContext) { - CHIP_ERROR err; - const char * kTestKey = "too_small_buffer_read_key"; - uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; - uint32_t read_value; - size_t read_size; - err = KeyValueStoreMgr().Put(kTestKey, kTestValue); + constexpr const char * kTestKey = "too_small_buffer_read_key"; + constexpr uint8_t kTestValue[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + + uint8_t readValue[9]; + size_t readSize; + + CHIP_ERROR err = KeyValueStoreMgr().Put(kTestKey, kTestValue); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Returns buffer too small and should read as many bytes as possible - err = KeyValueStoreMgr().Get(kTestKey, &read_value, sizeof(read_value), &read_size, 0); + err = KeyValueStoreMgr().Get(kTestKey, &readValue, sizeof(readValue), &readSize, 0); NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_BUFFER_TOO_SMALL); - NL_TEST_ASSERT(inSuite, read_size == sizeof(read_value)); - NL_TEST_ASSERT(inSuite, kTestValue[0] == read_value); + NL_TEST_ASSERT(inSuite, readSize == sizeof(readValue)); + NL_TEST_ASSERT(inSuite, memcmp(kTestValue, readValue, readSize) == 0); + err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); } -static void TestKeyValueStoreMgr_MultiReadKey(nlTestSuite * inSuite, void * inContext) +static void TestKeyValueStoreMgr_AllCharactersKey(nlTestSuite * inSuite, void * inContext) { - CHIP_ERROR err; - const char * kTestKey = "multi_key"; - uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; - err = KeyValueStoreMgr().Put(kTestKey, kTestValue); + // Test that all printable characters [0x20 - 0x7f) can be part of the key + constexpr size_t kKeyLength = 32; + constexpr char kCharBegin = 0x20; + constexpr char kCharEnd = 0x7f; + constexpr uint32_t kTestValue = 5; + + char allChars[kCharEnd - kCharBegin]; + + for (char character = kCharBegin; character < kCharEnd; character++) + { + allChars[character - kCharBegin] = character; + } + + for (size_t charId = 0; charId < sizeof(allChars); charId += kKeyLength) + { + char testKey[kKeyLength + 1] = {}; + memcpy(testKey, &allChars[charId], chip::min(sizeof(allChars) - charId, kKeyLength)); + + CHIP_ERROR err = KeyValueStoreMgr().Put(testKey, kTestValue); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + uint32_t readValue = UINT32_MAX; + err = KeyValueStoreMgr().Get(testKey, &readValue); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + err = KeyValueStoreMgr().Delete(testKey); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + } +} + +static void TestKeyValueStoreMgr_NonExistentDelete(nlTestSuite * inSuite, void * inContext) +{ + constexpr const char * kTestKey = "non_existent"; + + CHIP_ERROR err = KeyValueStoreMgr().Delete(kTestKey); + NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); +} + +static void TestKeyValueStoreMgr_MultiRead(nlTestSuite * inSuite, void * inContext) +{ + constexpr const char * kTestKey = "multi_key"; + constexpr uint32_t kTestValue[5] = { 1, 2, 3, 4, 5 }; + + CHIP_ERROR err = KeyValueStoreMgr().Put(kTestKey, kTestValue); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + for (uint32_t i = 0; i < 5; i++) { - uint32_t read_value; - size_t read_size; + uint32_t readValue; + size_t readSize; + // Returns buffer too small for all but the last read. - err = KeyValueStoreMgr().Get(kTestKey, &read_value, sizeof(read_value), &read_size, i * sizeof(uint32_t)); + err = KeyValueStoreMgr().Get(kTestKey, &readValue, sizeof(readValue), &readSize, i * sizeof(uint32_t)); NL_TEST_ASSERT(inSuite, err == (i < 4 ? CHIP_ERROR_BUFFER_TOO_SMALL : CHIP_NO_ERROR)); - NL_TEST_ASSERT(inSuite, read_size == sizeof(read_value)); - NL_TEST_ASSERT(inSuite, kTestValue[i] == read_value); + NL_TEST_ASSERT(inSuite, readSize == sizeof(readValue)); + NL_TEST_ASSERT(inSuite, kTestValue[i] == readValue); } + err = KeyValueStoreMgr().Delete(kTestKey); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); } @@ -223,16 +308,18 @@ static void TestKeyValueStoreMgr_DoFactoryReset(nlTestSuite * inSuite, void * in /** * Test Suite. It lists all the test functions. */ -static const nlTest sTests[] = { NL_TEST_DEF("Test KeyValueStoreMgr_EmptyStringKey", TestKeyValueStoreMgr_EmptyStringKey), - NL_TEST_DEF("Test KeyValueStoreMgr_StringKey", TestKeyValueStoreMgr_StringKey), - NL_TEST_DEF("Test KeyValueStoreMgr_Uint32Key", TestKeyValueStoreMgr_Uint32Key), - NL_TEST_DEF("Test KeyValueStoreMgr_ArrayKey", TestKeyValueStoreMgr_ArrayKey), - NL_TEST_DEF("Test KeyValueStoreMgr_StructKey", TestKeyValueStoreMgr_StructKey), - NL_TEST_DEF("Test KeyValueStoreMgr_UpdateKeyValue", TestKeyValueStoreMgr_UpdateKeyValue), +static const nlTest sTests[] = { NL_TEST_DEF("Test KeyValueStoreMgr_EmptyString", TestKeyValueStoreMgr_EmptyString), + NL_TEST_DEF("Test KeyValueStoreMgr_String", TestKeyValueStoreMgr_String), + NL_TEST_DEF("Test KeyValueStoreMgr_Uint32", TestKeyValueStoreMgr_Uint32), + NL_TEST_DEF("Test KeyValueStoreMgr_Array", TestKeyValueStoreMgr_Array), + NL_TEST_DEF("Test KeyValueStoreMgr_Struct", TestKeyValueStoreMgr_Struct), + NL_TEST_DEF("Test KeyValueStoreMgr_UpdateValue", TestKeyValueStoreMgr_UpdateValue), NL_TEST_DEF("Test KeyValueStoreMgr_TooSmallBufferRead", TestKeyValueStoreMgr_TooSmallBufferRead), + NL_TEST_DEF("Test KeyValueStoreMgr_AllCharactersKey", TestKeyValueStoreMgr_AllCharactersKey), + NL_TEST_DEF("Test KeyValueStoreMgr_NonExistentDelete", TestKeyValueStoreMgr_NonExistentDelete), #if !defined(__ZEPHYR__) && !defined(__MBED__) // Zephyr and Mbed platforms do not support partial or offset reads yet. - NL_TEST_DEF("Test KeyValueStoreMgr_MultiReadKey", TestKeyValueStoreMgr_MultiReadKey), + NL_TEST_DEF("Test KeyValueStoreMgr_MultiRead", TestKeyValueStoreMgr_MultiRead), #endif #ifdef __ZEPHYR__ NL_TEST_DEF("Test TestKeyValueStoreMgr_DoFactoryReset", TestKeyValueStoreMgr_DoFactoryReset),