Skip to content

Commit af28296

Browse files
committed
buffer: handle libcsp reserved buffers
libcsp commit 5e02b22221 introduced a new function and changed how we manage buffers. Specifically, it reserves two buffers for this new function. Use `csp_buffer_get_always()` in buffer-count tests to consume the reserved buffers. Because `csp_buffer_get_always()` panics on over-allocation, use `csp_buffer_get()` in over-allocation tests to verify that two reserved buffers remain. [1]: libcsp/libcsp@5e02b22 Signed-off-by: Yasushi SHOJI <[email protected]>
1 parent 25aef1f commit af28296

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/buffer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ ZTEST(buffer, test_buffer_count)
2323
zassert_true(csp_buffer_remaining() == CSP_BUFFER_COUNT);
2424

2525
for (i = 0; i < CSP_BUFFER_COUNT; i++) {
26-
packets[i] = csp_buffer_get(0);
26+
/* csp_buffer_get_always() is the only way to get all buffers */
27+
packets[i] = csp_buffer_get_always();
2728
zassert_true(packets[i] != NULL, NULL);
2829
}
2930

@@ -44,12 +45,12 @@ ZTEST(buffer, test_buffer_over_allocate)
4445

4546
memset(packets, 0, sizeof(packets));
4647

47-
for (i = 0; i < CSP_BUFFER_COUNT; i++) {
48+
for (i = 0; i < CSP_BUFFER_COUNT - 2; i++) {
4849
packets[i] = csp_buffer_get(0);
4950
zassert_true(packets[i] != NULL, NULL);
5051
}
5152

52-
zassert_true(csp_buffer_remaining() == 0);
53+
zassert_true(csp_buffer_remaining() == 2);
5354
p = csp_buffer_get(0);
5455
zassert_true(p == NULL, NULL);
5556

0 commit comments

Comments
 (0)