Skip to content

Commit

Permalink
Add test for rdp_queue
Browse files Browse the repository at this point in the history
Add test suite for csp_rdp_queue.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
  • Loading branch information
yashi committed Aug 18, 2024
1 parent 9d1a465 commit 9372736
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ target_sources(app PRIVATE
src/buffer.c
src/crc32.c
src/queue.c
src/rdp_queue.c
)
49 changes: 49 additions & 0 deletions src/rdp_queue.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2024 Space Cubics, LLC.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <csp/csp.h>

void csp_rdp_queue_init(void);
int csp_rdp_queue_tx_size(void);
int csp_rdp_queue_rx_size(void);
void csp_rdp_queue_tx_add(csp_conn_t * conn, csp_packet_t * packet);
void csp_rdp_queue_rx_add(csp_conn_t * conn, csp_packet_t * packet);
csp_packet_t * csp_rdp_queue_tx_get(csp_conn_t * conn);
csp_packet_t * csp_rdp_queue_rx_get(csp_conn_t * conn);

ZTEST(rdp_queue, test_rdp_queue_emtpy)
{
csp_rdp_queue_init();
zassert_equal(0, csp_rdp_queue_tx_size());
zassert_equal(0, csp_rdp_queue_rx_size());
zassert_is_null(csp_rdp_queue_tx_get(NULL));
zassert_is_null(csp_rdp_queue_rx_get(NULL));
}

ZTEST(rdp_queue, test_rdp_queue_add_and_get)
{
csp_packet_t *p1;
csp_packet_t *p2;

csp_rdp_queue_init();
zassert_equal(0, csp_rdp_queue_tx_size());
zassert_equal(0, csp_rdp_queue_rx_size());

csp_buffer_init();
p1 = csp_buffer_get(0);
zassert_not_null(p1);
csp_rdp_queue_tx_add(NULL, p1);
zassert_equal(1, csp_rdp_queue_tx_size());

p2 = csp_rdp_queue_tx_get(NULL);
zassert_equal(0, csp_rdp_queue_tx_size());
zassert_not_null(p2);
printf("%p %p\n", p1, p2);
zassert_equal_ptr(p1, p2);
}

ZTEST_SUITE(rdp_queue, NULL, NULL, NULL, NULL, NULL);

0 comments on commit 9372736

Please sign in to comment.