Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand attribute persistence provider api #27611

Merged
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
48915f3
Modified the AttributePersistenceProvider ReadValue function signitur…
hicklin Jul 3, 2023
1f989a9
Expanded AttributePersistanceProvider API to include reading and wirt…
hicklin Jul 3, 2023
b5ed2d5
Templated the AttributePersistanceProvider read and wiret function to…
hicklin Jul 3, 2023
c58e9a2
Fixed AttributePersistanceProvider accepted types. Added read helper …
hicklin Jul 4, 2023
1b1abfe
Merge branch 'project-chip:master' into expand_AttributePersistancePr…
hicklin Jul 4, 2023
e398672
Restyled by clang-format
restyled-commits Jul 4, 2023
6e3d3c7
Fixed mismatched size return error of DefaultAttributePersistenceProv…
hicklin Jul 4, 2023
4630dc1
Started work on tests for the AttributePersistenceProvider.
hicklin Jul 5, 2023
d60a795
Added unit tests for AttributePersistenceProvider testing the storage…
hicklin Jul 5, 2023
1643373
Changed the type of aSize in ReadValue to size_t
hicklin Jul 6, 2023
e1ec87e
Removed the dependancy on generated code in the AttributePersistencez…
hicklin Jul 6, 2023
4574741
Added static funtctions to get the KVS null representation for differ…
hicklin Jul 6, 2023
b5d456c
Added functions to read and write nullable bools and accompanying tests.
hicklin Jul 6, 2023
15230fc
Incorporated boolean tests in the scalar test.
hicklin Jul 6, 2023
476bf9c
Merge branch 'master' into expand_AttributePersistanceProvider_API
hicklin Jul 6, 2023
76db4d3
Added failure before init test
hicklin Jul 6, 2023
333ac54
Restyled by clang-format
restyled-commits Jul 6, 2023
4f9c481
Merge branch 'master' into expand_AttributePersistanceProvider_API
hicklin Jul 7, 2023
2d6f26a
Fixed after merge.
hicklin Jul 7, 2023
2d4cca0
Removed the failure on init test as it may have been causing seg faul…
hicklin Jul 7, 2023
09488ec
Renamed GetNull -> GetNullValueForNullableType
hicklin Jul 7, 2023
582b92c
Added the initialisation of valueReadBack and added a new templated f…
hicklin Jul 7, 2023
7c1bf20
Added handline of signed ints and accompanying tests.
hicklin Jul 7, 2023
81d062f
Added handline of nullable signed ints and accompanying tests.
hicklin Jul 7, 2023
de3b1c9
Type cast null.
hicklin Jul 7, 2023
35070d1
Merge branch 'master' into expand_AttributePersistanceProvider_API
hicklin Jul 7, 2023
7f2423f
Restyled by clang-format
restyled-commits Jul 7, 2023
9ab6af9
Changed shift bit to be af the same type are the return val.
hicklin Jul 7, 2023
e289e60
Added tests got GetNull functions
hicklin Jul 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restyled by clang-format
restyled-commits authored and hicklin committed Jul 6, 2023
commit 333ac54be5b5eb8e540e863f5ad545120f4f07cb
24 changes: 12 additions & 12 deletions src/app/tests/TestAttributePersistenceProvider.cpp
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@
*/

#include <app-common/zap-generated/cluster-objects.h>
#include <lib/support/TestPersistentStorageDelegate.h>
#include <app/DefaultAttributePersistenceProvider.h>
#include <lib/support/TestPersistentStorageDelegate.h>
#include <lib/support/UnitTestRegistration.h>
#include <nlunit-test.h>

@@ -64,7 +64,7 @@ void TestStorageAndRetrivalByteSpans(nlTestSuite * inSuite, void * inContext)
DefaultAttributePersistenceProvider persistenceProvider;

// Failure before Init
uint8_t valueArray[1] = {0x42};
uint8_t valueArray[1] = { 0x42 };
ByteSpan value(valueArray);
CHIP_ERROR err = persistenceProvider.WriteValue(TestConcretePath, value);
NL_TEST_ASSERT(inSuite, err == CHIP_ERROR_INCORRECT_STATE);
@@ -93,8 +93,8 @@ void TestStorageAndRetrivalByteSpans(nlTestSuite * inSuite, void * inContext)
* @param testValue The test value to store and retrieve
*/
template <typename T>
void testHelperStorageAndRetrivalScalarValues(nlTestSuite * inSuite,
DefaultAttributePersistenceProvider & persistenceProvider, T testValue)
void testHelperStorageAndRetrivalScalarValues(nlTestSuite * inSuite, DefaultAttributePersistenceProvider & persistenceProvider,
T testValue)
{
CHIP_ERROR err = persistenceProvider.WriteScalarValue(TestConcretePath, testValue);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
@@ -203,8 +203,6 @@ void TestStorageAndRetrivalNullableScalarValues(nlTestSuite * inSuite, void * in
persistenceProvider.Shutdown();
}



/**
* Test that the correct error is given when trying to read a value with a buffer that's too small.
*/
@@ -218,7 +216,7 @@ void TestBufferTooSmallErrors(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

// Store large data
uint8_t valueArray[9] = {0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42};
uint8_t valueArray[9] = { 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42 };
ByteSpan value(valueArray);
err = persistenceProvider.WriteValue(TestConcretePath, value);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);
@@ -269,11 +267,13 @@ void TestBufferTooSmallErrors(nlTestSuite * inSuite, void * inContext)
} // anonymous namespace

namespace {
const nlTest sTests[] = { NL_TEST_DEF("Test AttributePersistenceProvider: Storage and retrival of ByteSpans", TestStorageAndRetrivalByteSpans),
NL_TEST_DEF("Test AttributePersistenceProvider: Storage and retrival of scalar values", TestStorageAndRetrivalScalarValues),
NL_TEST_DEF("Test AttributePersistenceProvider: Storage and retrival of nullable scalar values", TestStorageAndRetrivalNullableScalarValues),
NL_TEST_DEF("Test AttributePersistenceProvider: Small buffer errors", TestBufferTooSmallErrors),
NL_TEST_SENTINEL() };
const nlTest sTests[] = {
NL_TEST_DEF("Test AttributePersistenceProvider: Storage and retrival of ByteSpans", TestStorageAndRetrivalByteSpans),
NL_TEST_DEF("Test AttributePersistenceProvider: Storage and retrival of scalar values", TestStorageAndRetrivalScalarValues),
NL_TEST_DEF("Test AttributePersistenceProvider: Storage and retrival of nullable scalar values",
TestStorageAndRetrivalNullableScalarValues),
NL_TEST_DEF("Test AttributePersistenceProvider: Small buffer errors", TestBufferTooSmallErrors), NL_TEST_SENTINEL()
};
}

int TestAttributePersistenceProvider()