summaryrefslogtreecommitdiff
path: root/src/kernel/tests
diff options
context:
space:
mode:
authordzwdz2022-05-15 15:26:13 +0200
committerdzwdz2022-05-15 15:26:13 +0200
commit6219918e020c6255ab854306478a2ee4876cc8c7 (patch)
tree1e7c3fada18fc4ce35a48f63734d63c8d0c617f7 /src/kernel/tests
parent27d8fa24b875f2bbcc73dad0795519ef2f5e9cd7 (diff)
shared/ring: ring_contig
Diffstat (limited to 'src/kernel/tests')
-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++);