Skip to content

Commit

Permalink
tests: add simple kv check app
Browse files Browse the repository at this point in the history
This is helpful for users to quickly check if they have KV support or
not.
  • Loading branch information
bradjc committed Jan 6, 2024
1 parent d8caeec commit 8bdeb91
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/tests/kv_check/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Makefile for user application

# Specify this directory relative to the current application.
TOCK_USERLAND_BASE_DIR = ../../..

# Which files to compile.
C_SRCS := $(wildcard *.c)

# Include userland master makefile. Contains rules and flags for actually
# building the application.
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
55 changes: 55 additions & 0 deletions examples/tests/kv_check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
KV Check
=========

This is a simple application to check for the presence of Key-Value support or
not.

If KV support exists, you should see:

```
[KV] Check for Key-Value Support
Key-Value support is enabled.
```

and if you have the process console enabled:

```
$ tockloader listen
tock$ process kv_check
𝐀𝐩𝐩: kv_check - [Terminated]
Events Queued: 0 Syscall Count: 17 Dropped Upcall Count: 0
Restart Count: 0
Last Syscall: Exit { which: 0, completion_code: 0 }
Completion Code: 0
Credential: None
╔═══════════╀══════════════════════════════════════════╗
β•‘ Address β”‚ Region Name Used | Allocated (bytes) β•‘
β•š0x2000B000═β•ͺ══════════════════════════════════════════╝
β”‚ Grant Ptrs 128
β”‚ Upcalls 320
β”‚ Process 920
0x2000AAA8 ┼───────────────────────────────────────────
β”‚ β–Ό Grant 76
0x2000AA5C ┼───────────────────────────────────────────
β”‚ Unused
0x20009FC8 ┼───────────────────────────────────────────
β”‚ β–² Heap 1100 | 3808 S
0x20009B7C ┼─────────────────────────────────────────── R
β”‚ Data 892 | 892 A
0x20009800 ┼─────────────────────────────────────────── M
β”‚ β–Ό Stack 240 | 2048
0x20009710 ┼───────────────────────────────────────────
β”‚ Unused
0x20009000 ┴───────────────────────────────────────────
.....
0x00042000 ┬─────────────────────────────────────────── F
β”‚ App Flash 8116 L
0x0004004C ┼─────────────────────────────────────────── A
β”‚ Protected 76 S
0x00040000 ┴─────────────────────────────────────────── H
```

note that `Completion Code` is zero, meaning KV support exists. If not, the
completion code will be -1.
19 changes: 19 additions & 0 deletions examples/tests/kv_check/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>

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

int main(void) {
printf("[KV] Check for Key-Value Support\n");

if (kv_check_status() == RETURNCODE_SUCCESS) {
printf("Key-Value support is enabled.\n");
tock_exit(0);
} else {
printf("[ERROR] Key-Value support is NOT enabled.\n");
tock_exit(-1);
}

return 0;
}

0 comments on commit 8bdeb91

Please sign in to comment.