Skip to content

Commit db73ed0

Browse files
author
Cruz Monrreal
authored
Merge pull request #6480 from davidsaada/david_nvstore_alloc_key
NVStore: add the allocate_key API (instead of set_alloc_key)
2 parents a301db5 + c90182a commit db73ed0

File tree

3 files changed

+167
-63
lines changed

3 files changed

+167
-63
lines changed

features/nvstore/TESTS/nvstore/functionality/main.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,17 @@ static void nvstore_basic_functionality_test()
133133
result = nvstore.set(19, 10, &(nvstore_testing_buf_set[3]));
134134
TEST_ASSERT_EQUAL(NVSTORE_ALREADY_EXISTS, result);
135135

136-
result = nvstore.set_alloc_key(key, 17, &(nvstore_testing_buf_set[3]));
136+
result = nvstore.allocate_key(key, 3);
137137
TEST_ASSERT_EQUAL(NVSTORE_NUM_PREDEFINED_KEYS, key);
138138
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, result);
139+
result = nvstore.set(NVSTORE_NUM_PREDEFINED_KEYS, 17, &(nvstore_testing_buf_set[3]));
140+
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, result);
141+
142+
result = nvstore.allocate_key(key, 3);
143+
TEST_ASSERT_EQUAL(NVSTORE_NUM_PREDEFINED_KEYS + 1, key);
144+
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, result);
145+
result = nvstore.set(NVSTORE_NUM_PREDEFINED_KEYS + 1, 17, &(nvstore_testing_buf_set[3]));
146+
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, result);
139147

140148
// Make sure set items are also gotten OK after reset
141149
result = nvstore.deinit();
@@ -168,6 +176,20 @@ static void nvstore_basic_functionality_test()
168176
TEST_ASSERT_EQUAL(17, actual_len_bytes);
169177
TEST_ASSERT_EQUAL_UINT8_ARRAY(&nvstore_testing_buf_set[3], nvstore_testing_buf_get, 17);
170178

179+
result = nvstore.get(NVSTORE_NUM_PREDEFINED_KEYS + 1, 64, nvstore_testing_buf_get, actual_len_bytes);
180+
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, result);
181+
TEST_ASSERT_EQUAL(17, actual_len_bytes);
182+
TEST_ASSERT_EQUAL_UINT8_ARRAY(&nvstore_testing_buf_set[3], nvstore_testing_buf_get, 17);
183+
184+
result = nvstore.free_all_keys_by_owner(3);
185+
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, result);
186+
187+
result = nvstore.get(NVSTORE_NUM_PREDEFINED_KEYS, 64, nvstore_testing_buf_get, actual_len_bytes);
188+
TEST_ASSERT_EQUAL(NVSTORE_NOT_FOUND, result);
189+
190+
result = nvstore.get(NVSTORE_NUM_PREDEFINED_KEYS + 1, 64, nvstore_testing_buf_get, actual_len_bytes);
191+
TEST_ASSERT_EQUAL(NVSTORE_NOT_FOUND, result);
192+
171193
result = nvstore.get(10, 65, nvstore_testing_buf_get, actual_len_bytes);
172194
TEST_ASSERT_EQUAL(NVSTORE_SUCCESS, result);
173195
TEST_ASSERT_EQUAL(64, actual_len_bytes);
@@ -346,6 +368,12 @@ static void nvstore_basic_functionality_test()
346368
TEST_ASSERT_EQUAL(53, actual_len_bytes);
347369
TEST_ASSERT_EQUAL_UINT8_ARRAY(&(nvstore_testing_buf_set[10]), nvstore_testing_buf_get, 53);
348370

371+
result = nvstore.get(NVSTORE_NUM_PREDEFINED_KEYS, 64, nvstore_testing_buf_get, actual_len_bytes);
372+
TEST_ASSERT_EQUAL(NVSTORE_NOT_FOUND, result);
373+
374+
result = nvstore.get(NVSTORE_NUM_PREDEFINED_KEYS + 1, 64, nvstore_testing_buf_get, actual_len_bytes);
375+
TEST_ASSERT_EQUAL(NVSTORE_NOT_FOUND, result);
376+
349377
delete[] nvstore_testing_buf_set;
350378
delete[] nvstore_testing_buf_get;
351379
}

0 commit comments

Comments
 (0)