Skip to content

Commit

Permalink
Merge pull request #341 from tock/kv-rename
Browse files Browse the repository at this point in the history
Rename kv_system -> kv
  • Loading branch information
lschuermann authored Aug 30, 2023
2 parents ca2f59e + 73b5345 commit 593a49d
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 303 deletions.
76 changes: 38 additions & 38 deletions examples/tests/kv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>

#include <kv_system.h>
#include <kv.h>
#include <unit_test.h>

#define KEY_LEN 200
Expand All @@ -14,7 +14,7 @@ uint8_t value_buf[DATA_LEN];


static bool test_exists(void) {
int ret = kv_system_check_status();
int ret = kv_check_status();
CHECK(ret == RETURNCODE_SUCCESS);
return true;
}
Expand All @@ -29,10 +29,10 @@ static bool test_set_get(void) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_get_sync(key_buf, strlen(key), data_buf, DATA_LEN, &value_len);
ret = kv_get_sync(key_buf, strlen(key), data_buf, DATA_LEN, &value_len);
CHECK(ret == RETURNCODE_SUCCESS);
CHECK(value_len == 45);
for (uint32_t i = 0; i < value_len; i++) {
Expand All @@ -52,10 +52,10 @@ static bool test_set_get_too_long(void) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_get_sync(key_buf, strlen(key), data_buf, 2, &value_len);
ret = kv_get_sync(key_buf, strlen(key), data_buf, 2, &value_len);
CHECK(ret == RETURNCODE_ESIZE);
CHECK(value_len == 10);
for (uint32_t i = 0; i < 2; i++) {
Expand All @@ -69,18 +69,18 @@ static bool test_key_too_long(void) {
int ret;

uint32_t value_len = 0;
ret = kv_system_get_sync(key_buf, KEY_LEN, value_buf, 50, &value_len);
ret = kv_get_sync(key_buf, KEY_LEN, value_buf, 50, &value_len);
CHECK(ret == RETURNCODE_ESIZE);

value_buf[0] = 'V';
ret = kv_system_set_sync(key_buf, KEY_LEN, value_buf, 1);
ret = kv_set_sync(key_buf, KEY_LEN, value_buf, 1);
CHECK(ret == RETURNCODE_ESIZE);
ret = kv_system_add_sync(key_buf, KEY_LEN, value_buf, 1);
ret = kv_add_sync(key_buf, KEY_LEN, value_buf, 1);
CHECK(ret == RETURNCODE_ESIZE);
ret = kv_system_update_sync(key_buf, KEY_LEN, value_buf, 1);
ret = kv_update_sync(key_buf, KEY_LEN, value_buf, 1);
CHECK(ret == RETURNCODE_ESIZE);

ret = kv_system_delete_sync(key_buf, KEY_LEN);
ret = kv_delete_sync(key_buf, KEY_LEN);
CHECK(ret == RETURNCODE_ESIZE);

return true;
Expand All @@ -90,7 +90,7 @@ static bool test_set_value_too_long(void) {
int ret;

key_buf[0] = 'K';
ret = kv_system_set_sync(key_buf, 1, value_buf, DATA_LEN);
ret = kv_set_sync(key_buf, 1, value_buf, DATA_LEN);
CHECK(ret == RETURNCODE_ESIZE);

return true;
Expand All @@ -102,7 +102,7 @@ static bool test_get_not_found(void) {
strcpy((char*) key_buf, random_key);

uint32_t value_len = 0;
ret = kv_system_get_sync(key_buf, strlen(random_key), data_buf, DATA_LEN, &value_len);
ret = kv_get_sync(key_buf, strlen(random_key), data_buf, DATA_LEN, &value_len);
CHECK(ret == RETURNCODE_ENOSUPPORT);

return true;
Expand All @@ -114,7 +114,7 @@ static bool test_get_not_found2(void) {
strcpy((char*) key_buf, random_key);

uint32_t value_len = 0;
ret = kv_system_get_sync(key_buf, strlen(random_key), data_buf, DATA_LEN, &value_len);
ret = kv_get_sync(key_buf, strlen(random_key), data_buf, DATA_LEN, &value_len);
CHECK(ret == RETURNCODE_ENOSUPPORT);

return true;
Expand All @@ -125,15 +125,15 @@ static bool test_add(void) {
char key[] = "kvtestapp";
strcpy((char*) key_buf, key);

ret = kv_system_delete_sync(key_buf, strlen(key));
ret = kv_delete_sync(key_buf, strlen(key));
CHECK(ret == RETURNCODE_SUCCESS || ret == RETURNCODE_ENOSUPPORT);

uint32_t value_len = 10;
for (uint32_t i = 0; i < value_len; i++) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_add_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_add_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

return true;
Expand All @@ -144,18 +144,18 @@ static bool test_add_add(void) {
char key[] = "kvtestapp";
strcpy((char*) key_buf, key);

ret = kv_system_delete_sync(key_buf, strlen(key));
ret = kv_delete_sync(key_buf, strlen(key));
CHECK(ret == RETURNCODE_SUCCESS || ret == RETURNCODE_ENOSUPPORT);

uint32_t value_len = 10;
for (uint32_t i = 0; i < value_len; i++) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_add_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_add_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_add_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_add_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_ENOSUPPORT);

return true;
Expand All @@ -171,17 +171,17 @@ static bool test_update(void) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

for (uint32_t i = 0; i < value_len; i++) {
value_buf[i] = (uint8_t) (10 - i);
}

ret = kv_system_update_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_update_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_get_sync(key_buf, strlen(key), data_buf, 100, &value_len);
ret = kv_get_sync(key_buf, strlen(key), data_buf, 100, &value_len);
CHECK(ret == RETURNCODE_SUCCESS);
CHECK(value_len == 10);
for (uint32_t i = 0; i < 10; i++) {
Expand All @@ -196,15 +196,15 @@ static bool test_update_no_exist(void) {
char key[] = "kvtestapp";
strcpy((char*) key_buf, key);

ret = kv_system_delete_sync(key_buf, strlen(key));
ret = kv_delete_sync(key_buf, strlen(key));
CHECK(ret == RETURNCODE_SUCCESS || ret == RETURNCODE_ENOSUPPORT);

uint32_t value_len = 10;
for (uint32_t i = 0; i < value_len; i++) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_update_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_update_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_ENOSUPPORT);

return true;
Expand All @@ -220,13 +220,13 @@ static bool test_delete(void) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_delete_sync(key_buf, strlen(key));
ret = kv_delete_sync(key_buf, strlen(key));
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_get_sync(key_buf, strlen(key), data_buf, 100, &value_len);
ret = kv_get_sync(key_buf, strlen(key), data_buf, 100, &value_len);
CHECK(ret == RETURNCODE_ENOSUPPORT);

return true;
Expand All @@ -242,13 +242,13 @@ static bool test_delete_delete(void) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_delete_sync(key_buf, strlen(key));
ret = kv_delete_sync(key_buf, strlen(key));
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_delete_sync(key_buf, strlen(key));
ret = kv_delete_sync(key_buf, strlen(key));
CHECK(ret == RETURNCODE_ENOSUPPORT);

return true;
Expand All @@ -259,33 +259,33 @@ static bool test_add_update_set(void) {
char key[] = "kvtestapp";
strcpy((char*) key_buf, key);

ret = kv_system_delete_sync(key_buf, strlen(key));
ret = kv_delete_sync(key_buf, strlen(key));
CHECK(ret == RETURNCODE_SUCCESS || ret == RETURNCODE_ENOSUPPORT);

uint32_t value_len = 30;
for (uint32_t i = 0; i < value_len; i++) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_add_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_add_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

value_len = 15;
for (uint32_t i = 0; i < value_len; i++) {
value_buf[i] = (uint8_t) i + 10;
}

ret = kv_system_update_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_update_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

value_len = 2;
value_buf[0] = 'H';
value_buf[1] = 'I';

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_get_sync(key_buf, strlen(key), data_buf, 100, &value_len);
ret = kv_get_sync(key_buf, strlen(key), data_buf, 100, &value_len);
CHECK(ret == RETURNCODE_SUCCESS);
CHECK(value_len == 2);
CHECK(value_buf[0] == 'H');
Expand All @@ -300,7 +300,7 @@ static bool test_set_zero_value(void) {
strcpy((char*) key_buf, key);

uint32_t value_len = 0;
ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

return true;
Expand Down Expand Up @@ -352,10 +352,10 @@ static bool subtest_set_get_region(uint32_t start, uint32_t stop) {
value_buf[j] = (uint8_t) (j + i);
}

ret = kv_system_set_sync(key_buf, strlen(keys[i]), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(keys[i]), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS);

ret = kv_system_get_sync(key_buf, strlen(keys[i]), data_buf, DATA_LEN, &value_len);
ret = kv_get_sync(key_buf, strlen(keys[i]), data_buf, DATA_LEN, &value_len);
CHECK(ret == RETURNCODE_SUCCESS);
CHECK(value_len == i + 32);
for (uint32_t j = 0; j < value_len; j++) {
Expand Down
12 changes: 6 additions & 6 deletions examples/tests/kv_interactive/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string.h>

#include <console.h>
#include <kv_system.h>
#include <kv.h>

#define KEY_LEN 64
#define DATA_LEN 64
Expand Down Expand Up @@ -86,7 +86,7 @@ int main(void) {

printf("Getting %s\n", key_buf);

ret = kv_system_get_sync(key_buf, key_len, data_buf, DATA_LEN, &value_len);
ret = kv_get_sync(key_buf, key_len, data_buf, DATA_LEN, &value_len);
if (ret < 0) {
printf("Could not get key: %i\n", ret);
} else {
Expand Down Expand Up @@ -117,7 +117,7 @@ int main(void) {

printf("Setting %s=%s\n", key_buf, value_buf);

ret = kv_system_set_sync(key_buf, key_len, value_buf, value_len);
ret = kv_set_sync(key_buf, key_len, value_buf, value_len);
if (ret < 0) {
printf("Error setting key %i\n", ret);
} else {
Expand All @@ -144,7 +144,7 @@ int main(void) {

printf("Adding %s=%s\n", key_buf, value_buf);

ret = kv_system_add_sync(key_buf, key_len, value_buf, value_len);
ret = kv_add_sync(key_buf, key_len, value_buf, value_len);
if (ret < 0) {
printf("Error adding key %i\n", ret);
} else {
Expand All @@ -171,7 +171,7 @@ int main(void) {

printf("Updating %s=%s\n", key_buf, value_buf);

ret = kv_system_update_sync(key_buf, key_len, value_buf, value_len);
ret = kv_update_sync(key_buf, key_len, value_buf, value_len);
if (ret < 0) {
printf("Error updating key %i\n", ret);
} else {
Expand All @@ -188,7 +188,7 @@ int main(void) {

printf("Deleting %s\n", key_buf);

ret = kv_system_delete_sync(key_buf, key_len);
ret = kv_delete_sync(key_buf, key_len);
if (ret < 0) {
printf("Could not delete key: %i\n", ret);
} else {
Expand Down
16 changes: 8 additions & 8 deletions examples/tests/kv_permissions/kv_no_modify/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>

#include <kv_system.h>
#include <kv.h>
#include <unit_test.h>

#define KEY_LEN 200
Expand All @@ -14,7 +14,7 @@ uint8_t value_buf[DATA_LEN];


static bool test_exists(void) {
int ret = kv_system_check_status();
int ret = kv_check_status();
CHECK(ret == RETURNCODE_SUCCESS);
return true;
}
Expand All @@ -30,10 +30,10 @@ static bool test_set_get(void) {
}

// If key exists this should fail.
ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS || ret == RETURNCODE_ENOSUPPORT);

ret = kv_system_get_sync(key_buf, strlen(key), data_buf, DATA_LEN, &value_len);
ret = kv_get_sync(key_buf, strlen(key), data_buf, DATA_LEN, &value_len);
CHECK(ret == RETURNCODE_SUCCESS);

return true;
Expand All @@ -49,10 +49,10 @@ static bool test_set_set(void) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS || ret == RETURNCODE_ENOSUPPORT);

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_ENOSUPPORT);

return true;
Expand All @@ -68,10 +68,10 @@ static bool test_set_delete(void) {
value_buf[i] = (uint8_t) i;
}

ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len);
ret = kv_set_sync(key_buf, strlen(key), value_buf, value_len);
CHECK(ret == RETURNCODE_SUCCESS || ret == RETURNCODE_ENOSUPPORT);

ret = kv_system_delete_sync(key_buf, strlen(key));
ret = kv_delete_sync(key_buf, strlen(key));
CHECK(ret == RETURNCODE_ENOSUPPORT);

return true;
Expand Down
Loading

0 comments on commit 593a49d

Please sign in to comment.