-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
277 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Makefile for user application | ||
|
||
# Specify this directory relative to the current application. | ||
TOCK_USERLAND_BASE_DIR = ../../../.. | ||
|
||
# Which files to compile. | ||
C_SRCS := $(wildcard *.c) | ||
|
||
ELF2TAB_ARGS += --write_id 9092 --read_ids 9092 | ||
|
||
# Include userland master makefile. Contains rules and flags for actually | ||
# building the application. | ||
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
KV Permission Unit Test - No Modify Permissions | ||
================ | ||
|
||
This test app has no modify permissions. | ||
|
||
Needs to have the `examples/services/unit_test_supervisor` app installed as | ||
well. | ||
|
||
Output | ||
------ | ||
|
||
Should get expected output like: | ||
|
||
``` | ||
4.000: exists [✓] | ||
4.001: set_get [✓] | ||
4.002: set_set [✓] | ||
4.003: set_delete [✓] | ||
Summary 4: [4/4] Passed, [0/4] Failed, [0/4] Incomplete | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <kv_system.h> | ||
#include <unit_test.h> | ||
|
||
#define KEY_LEN 200 | ||
#define DATA_LEN 3000 | ||
|
||
uint8_t key_buf[KEY_LEN]; | ||
uint8_t data_buf[DATA_LEN]; | ||
uint8_t value_buf[DATA_LEN]; | ||
|
||
|
||
static bool test_exists(void) { | ||
int ret = kv_system_check_status(); | ||
CHECK(ret == RETURNCODE_SUCCESS); | ||
return true; | ||
} | ||
|
||
static bool test_set_get(void) { | ||
int ret; | ||
char key[] = "kvnowritetestapp"; | ||
strcpy((char*) key_buf, key); | ||
|
||
uint32_t value_len = 45; | ||
for (uint32_t i = 0; i < value_len; i++) { | ||
value_buf[i] = (uint8_t) i; | ||
} | ||
|
||
// If key exists this should fail. | ||
ret = kv_system_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); | ||
CHECK(ret == RETURNCODE_SUCCESS); | ||
|
||
return true; | ||
} | ||
|
||
static bool test_set_set(void) { | ||
int ret; | ||
char key[] = "kvnowritetestapp"; | ||
strcpy((char*) key_buf, key); | ||
|
||
uint32_t value_len = 3; | ||
for (uint32_t i = 0; i < value_len; i++) { | ||
value_buf[i] = (uint8_t) i; | ||
} | ||
|
||
ret = kv_system_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); | ||
CHECK(ret == RETURNCODE_ENOSUPPORT); | ||
|
||
return true; | ||
} | ||
|
||
static bool test_set_delete(void) { | ||
int ret; | ||
char key[] = "kvnowritetestapp"; | ||
strcpy((char*) key_buf, key); | ||
|
||
uint32_t value_len = 3; | ||
for (uint32_t i = 0; i < value_len; i++) { | ||
value_buf[i] = (uint8_t) i; | ||
} | ||
|
||
ret = kv_system_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)); | ||
CHECK(ret == RETURNCODE_ENOSUPPORT); | ||
|
||
return true; | ||
} | ||
|
||
int main(void) { | ||
unit_test_fun tests[] = { | ||
TEST(exists), | ||
TEST(set_get), | ||
TEST(set_set), | ||
TEST(set_delete), | ||
}; | ||
unit_test_runner(tests, sizeof(tests) / sizeof(unit_test_fun), 2000, "org.tockos.unit_test"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Makefile for user application | ||
|
||
# Specify this directory relative to the current application. | ||
TOCK_USERLAND_BASE_DIR = ../../../.. | ||
|
||
# Which files to compile. | ||
C_SRCS := $(wildcard *.c) | ||
|
||
ELF2TAB_ARGS += --write_id 9091 --access_ids 9091 | ||
|
||
# Include userland master makefile. Contains rules and flags for actually | ||
# building the application. | ||
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
KV Permission Unit Test - No Read Permissions | ||
================ | ||
|
||
This test app has no read permissions. | ||
|
||
Needs to have the `examples/services/unit_test_supervisor` app installed as | ||
well. | ||
|
||
Output | ||
------ | ||
|
||
Should get expected output like: | ||
|
||
``` | ||
3.000: exists [✓] | ||
3.001: set_get_no_permissions [✓] | ||
Summary 3: [2/2] Passed, [0/2] Failed, [0/2] Incomplete | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <kv_system.h> | ||
#include <unit_test.h> | ||
|
||
#define KEY_LEN 200 | ||
#define DATA_LEN 3000 | ||
|
||
uint8_t key_buf[KEY_LEN]; | ||
uint8_t data_buf[DATA_LEN]; | ||
uint8_t value_buf[DATA_LEN]; | ||
|
||
|
||
static bool test_exists(void) { | ||
int ret = kv_system_check_status(); | ||
CHECK(ret == RETURNCODE_SUCCESS); | ||
return true; | ||
} | ||
|
||
static bool test_set_get_no_permissions(void) { | ||
int ret; | ||
char key[] = "kvnoreadtestapp"; | ||
strcpy((char*) key_buf, key); | ||
|
||
uint32_t value_len = 45; | ||
for (uint32_t i = 0; i < value_len; i++) { | ||
value_buf[i] = (uint8_t) i; | ||
} | ||
|
||
ret = kv_system_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); | ||
CHECK(ret == RETURNCODE_ENOSUPPORT); | ||
|
||
return true; | ||
} | ||
|
||
int main(void) { | ||
unit_test_fun tests[] = { | ||
TEST(exists), | ||
TEST(set_get_no_permissions), | ||
}; | ||
unit_test_runner(tests, sizeof(tests) / sizeof(unit_test_fun), 2000, "org.tockos.unit_test"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Makefile for user application | ||
|
||
# Specify this directory relative to the current application. | ||
TOCK_USERLAND_BASE_DIR = ../../../.. | ||
|
||
# Which files to compile. | ||
C_SRCS := $(wildcard *.c) | ||
|
||
ELF2TAB_ARGS += --read_ids 9090 --access_ids 9090 | ||
|
||
# Include userland master makefile. Contains rules and flags for actually | ||
# building the application. | ||
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
KV Permission Unit Test - No Write Permission | ||
================ | ||
|
||
This app has no write ID and cannot create KV objects. | ||
|
||
Needs to have the `examples/services/unit_test_supervisor` app installed as | ||
well. | ||
|
||
Output | ||
------ | ||
|
||
Should get expected output like: | ||
|
||
``` | ||
2.000: exists [✓] | ||
2.001: set_no_permissions [✓] | ||
Summary 2: [2/2] Passed, [0/2] Failed, [0/2] Incomplete | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include <kv_system.h> | ||
#include <unit_test.h> | ||
|
||
#define KEY_LEN 200 | ||
#define DATA_LEN 3000 | ||
|
||
uint8_t key_buf[KEY_LEN]; | ||
uint8_t data_buf[DATA_LEN]; | ||
uint8_t value_buf[DATA_LEN]; | ||
|
||
|
||
static bool test_exists(void) { | ||
int ret = kv_system_check_status(); | ||
CHECK(ret == RETURNCODE_SUCCESS); | ||
return true; | ||
} | ||
|
||
static bool test_set_no_permissions(void) { | ||
int ret; | ||
char key[] = "kvnowritetestapp"; | ||
strcpy((char*) key_buf, key); | ||
|
||
uint32_t value_len = 45; | ||
for (uint32_t i = 0; i < value_len; i++) { | ||
value_buf[i] = (uint8_t) i; | ||
} | ||
|
||
ret = kv_system_set_sync(key_buf, strlen(key), value_buf, value_len); | ||
CHECK(ret == RETURNCODE_EINVAL); | ||
|
||
return true; | ||
} | ||
|
||
int main(void) { | ||
unit_test_fun tests[] = { | ||
TEST(exists), | ||
TEST(set_no_permissions), | ||
}; | ||
unit_test_runner(tests, sizeof(tests) / sizeof(unit_test_fun), 2000, "org.tockos.unit_test"); | ||
return 0; | ||
} |