summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/tests/util.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/kernel/tests/util.c b/src/kernel/tests/util.c
index cf16b75..b7123b4 100644
--- a/src/kernel/tests/util.c
+++ b/src/kernel/tests/util.c
@@ -32,12 +32,23 @@ TEST(strcmp) {
}
TEST(ring) {
- char backbuf[16];
+ char backbuf[16], cmpbuf[16];
size_t num_read = 0, num_written = 0;
uint8_t c;
ring_t r = {backbuf, 16, 0, 0};
+ // test aliasing
+ for (size_t i = 0; i < 16; i++) {
+ TEST_COND(ring_size(&r) == 0);
+ ring_put(&r, "11 bytes...", 11);
+ TEST_COND(ring_size(&r) == 11);
+
+ memset(cmpbuf, 0, sizeof cmpbuf);
+ TEST_COND(ring_get(&r, cmpbuf, 16) == 11);
+ TEST_COND(memcmp(cmpbuf, "11 bytes...", 11) == 0);
+ }
+
TEST_COND(ring_size(&r) == 0);
for (size_t i = 0; i < 7; i++)
ring_put1b(&r, num_written++);