1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tests/nimble_l2cap: fix NDEBUG compile problem

This commit is contained in:
Gunar Schorcht 2020-02-25 09:28:59 +01:00
parent ad4f1993b2
commit d92277a0f0

View File

@ -27,7 +27,7 @@
#include "host/ble_gap.h"
#include "host/util/util.h"
#include "assert.h"
#include "test_utils/expect.h"
#include "shell.h"
#include "thread.h"
#include "thread_flags.h"
@ -59,12 +59,12 @@ static void _on_data(struct ble_l2cap_event *event)
int res;
(void)res;
struct os_mbuf *rxd = event->receive.sdu_rx;
assert(rxd != NULL);
expect(rxd != NULL);
int rx_len = (int)OS_MBUF_PKTLEN(rxd);
assert(rx_len <= (int)APP_MTU);
expect(rx_len <= (int)APP_MTU);
res = os_mbuf_copydata(rxd, 0, rx_len, _rxbuf);
assert(res == 0);
expect(res == 0);
_last_rx_seq = _rxbuf[POS_SEQ];
if (_rxbuf[POS_TYPE] == TYPE_INCTEST) {
thread_flags_set(_main, FLAG_SYNC);
@ -72,11 +72,11 @@ static void _on_data(struct ble_l2cap_event *event)
/* free buffer */
res = os_mbuf_free_chain(rxd);
assert(res == 0);
expect(res == 0);
rxd = os_mbuf_get_pkthdr(&_coc_mbuf_pool, 0);
assert(rxd != NULL);
expect(rxd != NULL);
res = ble_l2cap_recv_ready(_coc, rxd);
assert(res == 0);
expect(res == 0);
}
static int _on_l2cap_evt(struct ble_l2cap_event *event, void *arg)
@ -103,7 +103,7 @@ static int _on_l2cap_evt(struct ble_l2cap_event *event, void *arg)
/* this event should never be triggered for the L2CAP client */
/* fallthrough */
default:
assert(0);
expect(0);
break;
}
@ -119,10 +119,10 @@ static int _on_gap_evt(struct ble_gap_event *event, void *arg)
case BLE_GAP_EVENT_CONNECT: {
_handle = event->connect.conn_handle;
struct os_mbuf *sdu_rx = os_mbuf_get_pkthdr(&_coc_mbuf_pool, 0);
assert(sdu_rx != NULL);
expect(sdu_rx != NULL);
int res = ble_l2cap_connect(_handle, APP_CID, APP_MTU, sdu_rx,
_on_l2cap_evt, NULL);
assert(res == 0);
expect(res == 0);
break;
}
case BLE_GAP_EVENT_DISCONNECT:
@ -152,12 +152,12 @@ static void _filter_and_connect(struct ble_gap_disc_desc *disc)
APP_NODENAME, (sizeof(APP_NODENAME) - 1));
if (res) {
res = ble_gap_disc_cancel();
assert(res == 0);
expect(res == 0);
printf("# Found Server, connecting now");
res = ble_gap_connect(nimble_riot_own_addr_type, &disc->addr,
BLE_HS_FOREVER, NULL, _on_gap_evt, NULL);
assert(res == 0);
expect(res == 0);
}
}
@ -183,17 +183,17 @@ static void _send(uint32_t type, uint32_t seq, size_t len)
(void)res;
struct os_mbuf *txd;
assert(_coc);
assert(len >= 8);
assert(len <= APP_MTU);
expect(_coc);
expect(len >= 8);
expect(len <= APP_MTU);
printf("# Sending: size %5u seq %5u\n", (unsigned)len, (unsigned)seq);
_txbuf[POS_TYPE] = type;
_txbuf[POS_SEQ] = seq;
txd = os_mbuf_get_pkthdr(&_coc_mbuf_pool, 0);
assert(txd != NULL);
expect(txd != NULL);
res = os_mbuf_append(txd, _txbuf, len);
assert(res == 0);
expect(res == 0);
do {
res = ble_l2cap_send(_coc, txd);
@ -204,7 +204,7 @@ static void _send(uint32_t type, uint32_t seq, size_t len)
if ((res != 0) && (res != BLE_HS_ESTALLED)) {
printf("# err: failed to send (%i)\n", res);
assert(0);
expect(0);
}
}
@ -244,7 +244,7 @@ static int _cmd_inctest(int argc, char **argv)
if (_last_rx_seq != seq) {
printf("# err: bad sequence number in response (%u)\n",
(unsigned)_last_rx_seq);
assert(0);
expect(0);
}
}
time = (xtimer_now_usec() - time);
@ -316,16 +316,16 @@ int main(void)
/* initialize buffers and setup the test environment */
res = os_mempool_init(&_coc_mempool, MBUFCNT, MBUFSIZE, _coc_mem, "appbuf");
assert(res == 0);
expect(res == 0);
res = os_mbuf_pool_init(&_coc_mbuf_pool, &_coc_mempool, MBUFSIZE, MBUFCNT);
assert(res == 0);
expect(res == 0);
/* start scanning for a suitable test server */
puts("# Scanning now");
struct ble_gap_disc_params params = { 0 };
res = ble_gap_disc(nimble_riot_own_addr_type, BLE_HS_FOREVER,
&params, _on_scan_evt, NULL);
assert(res == 0);
expect(res == 0);
/* wait until we are connected to the test server */
thread_flags_wait_all(FLAG_UP);