Skip to content

Commit 9372736

Browse files
committed
Add test for rdp_queue
Add test suite for csp_rdp_queue. Signed-off-by: Yasushi SHOJI <[email protected]>
1 parent 9d1a465 commit 9372736

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ target_sources(app PRIVATE
1010
src/buffer.c
1111
src/crc32.c
1212
src/queue.c
13+
src/rdp_queue.c
1314
)

src/rdp_queue.c

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2024 Space Cubics, LLC.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/ztest.h>
8+
#include <csp/csp.h>
9+
10+
void csp_rdp_queue_init(void);
11+
int csp_rdp_queue_tx_size(void);
12+
int csp_rdp_queue_rx_size(void);
13+
void csp_rdp_queue_tx_add(csp_conn_t * conn, csp_packet_t * packet);
14+
void csp_rdp_queue_rx_add(csp_conn_t * conn, csp_packet_t * packet);
15+
csp_packet_t * csp_rdp_queue_tx_get(csp_conn_t * conn);
16+
csp_packet_t * csp_rdp_queue_rx_get(csp_conn_t * conn);
17+
18+
ZTEST(rdp_queue, test_rdp_queue_emtpy)
19+
{
20+
csp_rdp_queue_init();
21+
zassert_equal(0, csp_rdp_queue_tx_size());
22+
zassert_equal(0, csp_rdp_queue_rx_size());
23+
zassert_is_null(csp_rdp_queue_tx_get(NULL));
24+
zassert_is_null(csp_rdp_queue_rx_get(NULL));
25+
}
26+
27+
ZTEST(rdp_queue, test_rdp_queue_add_and_get)
28+
{
29+
csp_packet_t *p1;
30+
csp_packet_t *p2;
31+
32+
csp_rdp_queue_init();
33+
zassert_equal(0, csp_rdp_queue_tx_size());
34+
zassert_equal(0, csp_rdp_queue_rx_size());
35+
36+
csp_buffer_init();
37+
p1 = csp_buffer_get(0);
38+
zassert_not_null(p1);
39+
csp_rdp_queue_tx_add(NULL, p1);
40+
zassert_equal(1, csp_rdp_queue_tx_size());
41+
42+
p2 = csp_rdp_queue_tx_get(NULL);
43+
zassert_equal(0, csp_rdp_queue_tx_size());
44+
zassert_not_null(p2);
45+
printf("%p %p\n", p1, p2);
46+
zassert_equal_ptr(p1, p2);
47+
}
48+
49+
ZTEST_SUITE(rdp_queue, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)