Skip to content

Commit

Permalink
tests: bluetooth: add prefix to exposed API
Browse files Browse the repository at this point in the history
In ull_llcp* some functions used in unittesting did not have
the llcp_ prefix
Although this is not a big issue since they are only used when
testing the module this commit adds the prefix so that we
have a more consistent naming

Signed-off-by: Andries Kruithof <[email protected]>
  • Loading branch information
kruithofa authored and carlescufi committed Feb 24, 2023
1 parent e6ba1ee commit 226c99b
Show file tree
Hide file tree
Showing 25 changed files with 366 additions and 362 deletions.
14 changes: 7 additions & 7 deletions subsys/bluetooth/controller/ll_sw/ull_llcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,34 +1829,34 @@ void ull_cp_rx(struct ll_conn *conn, struct node_rx_pdu *rx)

#ifdef ZTEST_UNITTEST

uint16_t local_ctx_buffers_free(void)
uint16_t llcp_local_ctx_buffers_free(void)
{
return mem_free_count_get(mem_local_ctx.free);
}

uint16_t remote_ctx_buffers_free(void)
uint16_t llcp_remote_ctx_buffers_free(void)
{
return mem_free_count_get(mem_remote_ctx.free);
}

uint16_t ctx_buffers_free(void)
uint16_t llcp_ctx_buffers_free(void)
{
return local_ctx_buffers_free() + remote_ctx_buffers_free();
return llcp_local_ctx_buffers_free() + llcp_remote_ctx_buffers_free();
}

#if defined(LLCP_TX_CTRL_BUF_QUEUE_ENABLE)
uint8_t common_tx_buffer_alloc_count(void)
uint8_t llcp_common_tx_buffer_alloc_count(void)
{
return common_tx_buffer_alloc;
}
#endif /* LLCP_TX_CTRL_BUF_QUEUE_ENABLE */

struct proc_ctx *pub_proc_ctx_acquire(void)
struct proc_ctx *llcp_proc_ctx_acquire(void)
{
return proc_ctx_acquire(&mem_local_ctx);
}

struct proc_ctx *pub_create_procedure(enum llcp_proc proc)
struct proc_ctx *llcp_create_procedure(enum llcp_proc proc)
{
return create_procedure(proc, &mem_local_ctx);
}
Expand Down
30 changes: 15 additions & 15 deletions subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -736,19 +736,19 @@ void llcp_pdu_encode_cis_ind(struct proc_ctx *ctx, struct pdu_data *pdu);
void llcp_pdu_decode_cis_rsp(struct proc_ctx *ctx, struct pdu_data *pdu);

#ifdef ZTEST_UNITTEST
bool lr_is_disconnected(struct ll_conn *conn);
bool lr_is_idle(struct ll_conn *conn);
struct proc_ctx *pub_lr_dequeue(struct ll_conn *conn);

bool rr_is_disconnected(struct ll_conn *conn);
bool rr_is_idle(struct ll_conn *conn);
struct proc_ctx *pub_rr_dequeue(struct ll_conn *conn);
void pub_rr_enqueue(struct ll_conn *conn, struct proc_ctx *ctx);

uint16_t local_ctx_buffers_free(void);
uint16_t remote_ctx_buffers_free(void);
uint16_t ctx_buffers_free(void);
uint8_t common_tx_buffer_alloc_count(void);
struct proc_ctx *pub_proc_ctx_acquire(void);
struct proc_ctx *pub_create_procedure(enum llcp_proc proc);
bool llcp_lr_is_disconnected(struct ll_conn *conn);
bool llcp_lr_is_idle(struct ll_conn *conn);
struct proc_ctx *llcp_lr_dequeue(struct ll_conn *conn);

bool llcp_rr_is_disconnected(struct ll_conn *conn);
bool llcp_rr_is_idle(struct ll_conn *conn);
struct proc_ctx *llcp_rr_dequeue(struct ll_conn *conn);
void llcp_rr_enqueue(struct ll_conn *conn, struct proc_ctx *ctx);

uint16_t llcp_local_ctx_buffers_free(void);
uint16_t llcp_remote_ctx_buffers_free(void);
uint16_t llcp_ctx_buffers_free(void);
uint8_t llcp_common_tx_buffer_alloc_count(void);
struct proc_ctx *llcp_proc_ctx_acquire(void);
struct proc_ctx *llcp_create_procedure(enum llcp_proc proc);
#endif
6 changes: 3 additions & 3 deletions subsys/bluetooth/controller/ll_sw/ull_llcp_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,17 @@ void llcp_lr_abort(struct ll_conn *conn)

#ifdef ZTEST_UNITTEST

bool lr_is_disconnected(struct ll_conn *conn)
bool llcp_lr_is_disconnected(struct ll_conn *conn)
{
return conn->llcp.local.state == LR_STATE_DISCONNECT;
}

bool lr_is_idle(struct ll_conn *conn)
bool llcp_lr_is_idle(struct ll_conn *conn)
{
return conn->llcp.local.state == LR_STATE_IDLE;
}

struct proc_ctx *pub_lr_dequeue(struct ll_conn *conn)
struct proc_ctx *llcp_lr_dequeue(struct ll_conn *conn)
{
return lr_dequeue(conn);
}
Expand Down
8 changes: 4 additions & 4 deletions subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,22 +920,22 @@ static void rr_abort(struct ll_conn *conn)

#ifdef ZTEST_UNITTEST

bool rr_is_disconnected(struct ll_conn *conn)
bool llcp_rr_is_disconnected(struct ll_conn *conn)
{
return conn->llcp.remote.state == RR_STATE_DISCONNECT;
}

bool rr_is_idle(struct ll_conn *conn)
bool llcp_rr_is_idle(struct ll_conn *conn)
{
return conn->llcp.remote.state == RR_STATE_IDLE;
}

struct proc_ctx *pub_rr_dequeue(struct ll_conn *conn)
struct proc_ctx *llcp_rr_dequeue(struct ll_conn *conn)
{
return rr_dequeue(conn);
}

void pub_rr_enqueue(struct ll_conn *conn, struct proc_ctx *ctx)
void llcp_rr_enqueue(struct ll_conn *conn, struct proc_ctx *ctx)
{
rr_enqueue(conn, ctx);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/bluetooth/controller/common/src/helper_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void test_setup(struct ll_conn *conn)
memset(emul_conn_pool, 0x00, sizeof(emul_conn_pool));
emul_conn_pool[0] = conn;

no_of_ctx_buffers_at_test_setup = ctx_buffers_free();
no_of_ctx_buffers_at_test_setup = llcp_ctx_buffers_free();

}

Expand Down
64 changes: 32 additions & 32 deletions tests/bluetooth/controller/ctrl_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ ZTEST(public, test_api_init)

ull_llcp_init(&conn);

zassert_true(lr_is_disconnected(&conn));
zassert_true(rr_is_disconnected(&conn));
zassert_true(llcp_lr_is_disconnected(&conn));
zassert_true(llcp_rr_is_disconnected(&conn));
}

ZTEST(public, test_api_connect)
Expand All @@ -66,8 +66,8 @@ ZTEST(public, test_api_connect)
ull_llcp_init(&conn);

ull_cp_state_set(&conn, ULL_CP_CONNECTED);
zassert_true(lr_is_idle(&conn));
zassert_true(rr_is_idle(&conn));
zassert_true(llcp_lr_is_idle(&conn));
zassert_true(llcp_rr_is_idle(&conn));
}

ZTEST(public, test_api_disconnect)
Expand All @@ -77,16 +77,16 @@ ZTEST(public, test_api_disconnect)
ull_llcp_init(&conn);

ull_cp_state_set(&conn, ULL_CP_DISCONNECTED);
zassert_true(lr_is_disconnected(&conn));
zassert_true(rr_is_disconnected(&conn));
zassert_true(llcp_lr_is_disconnected(&conn));
zassert_true(llcp_rr_is_disconnected(&conn));

ull_cp_state_set(&conn, ULL_CP_CONNECTED);
zassert_true(lr_is_idle(&conn));
zassert_true(rr_is_idle(&conn));
zassert_true(llcp_lr_is_idle(&conn));
zassert_true(llcp_rr_is_idle(&conn));

ull_cp_state_set(&conn, ULL_CP_DISCONNECTED);
zassert_true(lr_is_disconnected(&conn));
zassert_true(rr_is_disconnected(&conn));
zassert_true(llcp_lr_is_disconnected(&conn));
zassert_true(llcp_rr_is_disconnected(&conn));
}

ZTEST(public, test_int_disconnect_loc)
Expand All @@ -106,13 +106,13 @@ ZTEST(public, test_int_disconnect_loc)
test_set_role(&conn, BT_HCI_ROLE_CENTRAL);
ull_cp_state_set(&conn, ULL_CP_CONNECTED);

nr_free_ctx = ctx_buffers_free();
nr_free_ctx = llcp_ctx_buffers_free();
zassert_equal(nr_free_ctx, test_ctx_buffers_cnt());

err = ull_cp_version_exchange(&conn);
zassert_equal(err, BT_HCI_ERR_SUCCESS);

nr_free_ctx = ctx_buffers_free();
nr_free_ctx = llcp_ctx_buffers_free();
zassert_equal(nr_free_ctx, test_ctx_buffers_cnt() - 1);

event_prepare(&conn);
Expand All @@ -125,7 +125,7 @@ ZTEST(public, test_int_disconnect_loc)
*/
ull_cp_state_set(&conn, ULL_CP_DISCONNECTED);

nr_free_ctx = ctx_buffers_free();
nr_free_ctx = llcp_ctx_buffers_free();
zassert_equal(nr_free_ctx, test_ctx_buffers_cnt());

ut_rx_q_is_empty();
Expand All @@ -136,7 +136,7 @@ ZTEST(public, test_int_disconnect_loc)
event_prepare(&conn);
event_done(&conn);

nr_free_ctx = ctx_buffers_free();
nr_free_ctx = llcp_ctx_buffers_free();
zassert_equal(nr_free_ctx, test_ctx_buffers_cnt());

/*
Expand Down Expand Up @@ -164,15 +164,15 @@ ZTEST(public, test_int_disconnect_rem)
/* Connect */
ull_cp_state_set(&conn, ULL_CP_CONNECTED);

nr_free_ctx = ctx_buffers_free();
nr_free_ctx = llcp_ctx_buffers_free();
zassert_equal(nr_free_ctx, test_ctx_buffers_cnt());
/* Prepare */
event_prepare(&conn);

/* Rx */
lt_tx(LL_VERSION_IND, &conn, &remote_version_ind);

nr_free_ctx = ctx_buffers_free();
nr_free_ctx = llcp_ctx_buffers_free();
zassert_equal(nr_free_ctx, test_ctx_buffers_cnt());

/* Disconnect before we reply */
Expand All @@ -188,7 +188,7 @@ ZTEST(public, test_int_disconnect_rem)
/* Done */
event_done(&conn);

nr_free_ctx = ctx_buffers_free();
nr_free_ctx = llcp_ctx_buffers_free();
zassert_equal(nr_free_ctx, test_ctx_buffers_cnt());

/* There should not be a host notifications */
Expand Down Expand Up @@ -343,30 +343,30 @@ ZTEST(internal, test_int_mem_proc_ctx)

ull_cp_init();

nr_of_free_ctx = ctx_buffers_free();
nr_of_free_ctx = llcp_ctx_buffers_free();
zassert_equal(nr_of_free_ctx, CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM +
CONFIG_BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM, NULL);

for (int i = 0U; i < CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM; i++) {
ctx1 = pub_proc_ctx_acquire();
ctx1 = llcp_proc_ctx_acquire();

/* The previous acquire should be valid */
zassert_not_null(ctx1, NULL);
}

nr_of_free_ctx = local_ctx_buffers_free();
nr_of_free_ctx = llcp_local_ctx_buffers_free();
zassert_equal(nr_of_free_ctx, 0);

ctx2 = pub_proc_ctx_acquire();
ctx2 = llcp_proc_ctx_acquire();

/* The last acquire should fail */
zassert_is_null(ctx2, NULL);

llcp_proc_ctx_release(ctx1);
nr_of_free_ctx = local_ctx_buffers_free();
nr_of_free_ctx = llcp_local_ctx_buffers_free();
zassert_equal(nr_of_free_ctx, 1);

ctx1 = pub_proc_ctx_acquire();
ctx1 = llcp_proc_ctx_acquire();

/* Releasing returns the context to the avilable pool */
zassert_not_null(ctx1, NULL);
Expand Down Expand Up @@ -443,15 +443,15 @@ ZTEST(internal, test_int_create_proc)

ull_cp_init();

ctx = pub_create_procedure(PROC_VERSION_EXCHANGE);
ctx = llcp_create_procedure(PROC_VERSION_EXCHANGE);
zassert_not_null(ctx, NULL);

zassert_equal(ctx->proc, PROC_VERSION_EXCHANGE);
zassert_equal(ctx->collision, 0);

for (int i = 0U; i < CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM; i++) {
zassert_not_null(ctx, NULL);
ctx = pub_create_procedure(PROC_VERSION_EXCHANGE);
ctx = llcp_create_procedure(PROC_VERSION_EXCHANGE);
}

zassert_is_null(ctx, NULL);
Expand Down Expand Up @@ -487,7 +487,7 @@ ZTEST(internal, test_int_local_pending_requests)
peek_ctx = llcp_lr_peek(&conn);
zassert_is_null(peek_ctx, NULL);

dequeue_ctx = pub_lr_dequeue(&conn);
dequeue_ctx = llcp_lr_dequeue(&conn);
zassert_is_null(dequeue_ctx, NULL);

llcp_lr_enqueue(&conn, &ctx);
Expand All @@ -497,13 +497,13 @@ ZTEST(internal, test_int_local_pending_requests)
peek_ctx = llcp_lr_peek(&conn);
zassert_equal_ptr(peek_ctx, &ctx, NULL);

dequeue_ctx = pub_lr_dequeue(&conn);
dequeue_ctx = llcp_lr_dequeue(&conn);
zassert_equal_ptr(dequeue_ctx, &ctx, NULL);

peek_ctx = llcp_lr_peek(&conn);
zassert_is_null(peek_ctx, NULL);

dequeue_ctx = pub_lr_dequeue(&conn);
dequeue_ctx = llcp_lr_dequeue(&conn);
zassert_is_null(dequeue_ctx, NULL);
}

Expand All @@ -521,23 +521,23 @@ ZTEST(internal, test_int_remote_pending_requests)
peek_ctx = llcp_rr_peek(&conn);
zassert_is_null(peek_ctx, NULL);

dequeue_ctx = pub_rr_dequeue(&conn);
dequeue_ctx = llcp_rr_dequeue(&conn);
zassert_is_null(dequeue_ctx, NULL);

pub_rr_enqueue(&conn, &ctx);
llcp_rr_enqueue(&conn, &ctx);
peek_ctx = (struct proc_ctx *)sys_slist_peek_head(&conn.llcp.remote.pend_proc_list);
zassert_equal_ptr(peek_ctx, &ctx, NULL);

peek_ctx = llcp_rr_peek(&conn);
zassert_equal_ptr(peek_ctx, &ctx, NULL);

dequeue_ctx = pub_rr_dequeue(&conn);
dequeue_ctx = llcp_rr_dequeue(&conn);
zassert_equal_ptr(dequeue_ctx, &ctx, NULL);

peek_ctx = llcp_rr_peek(&conn);
zassert_is_null(peek_ctx, NULL);

dequeue_ctx = pub_rr_dequeue(&conn);
dequeue_ctx = llcp_rr_dequeue(&conn);
zassert_is_null(dequeue_ctx, NULL);
}

Expand Down
Loading

0 comments on commit 226c99b

Please sign in to comment.