Fix leak check in host unit tests

This commit is contained in:
Christopher Collins
2019-03-27 03:07:09 -07:00
committed by ccollins476ad
parent 2bd8de56a1
commit c4a6886581
3 changed files with 35 additions and 2 deletions
+18
View File
@@ -440,6 +440,24 @@ ble_hs_hci_frag_alloc(uint16_t frag_size, void *arg)
return NULL;
}
/**
* Retrieves the total capacity of the ACL fragment pool (always 1).
*/
int
ble_hs_hci_frag_num_mbufs(void)
{
return ble_hs_hci_frag_mempool.mp_num_blocks;
}
/**
* Retrieves the the count of free buffers in the ACL fragment pool.
*/
int
ble_hs_hci_frag_num_mbufs_free(void)
{
return ble_hs_hci_frag_mempool.mp_num_free;
}
static struct os_mbuf *
ble_hs_hci_acl_hdr_prepend(struct os_mbuf *om, uint16_t handle,
uint8_t pb_flag)
+3
View File
@@ -262,6 +262,9 @@ int ble_hs_hci_cmd_build_le_set_phy(uint16_t conn_handle, uint8_t tx_phys_mask,
uint8_t rx_phys_mask, uint16_t phy_opts,
uint8_t *dst, int dst_len);
int ble_hs_hci_frag_num_mbufs(void);
int ble_hs_hci_frag_num_mbufs_free(void);
#if MYNEWT_VAL(BLE_EXT_ADV)
#endif
+14 -2
View File
@@ -1738,6 +1738,18 @@ ble_hs_test_util_mbuf_chain_len(const struct os_mbuf *om)
return count;
}
static int
ble_hs_test_util_num_mbufs(void)
{
return os_msys_count() + ble_hs_hci_frag_num_mbufs();
}
static int
ble_hs_test_util_num_mbufs_free(void)
{
return os_msys_num_free() + ble_hs_hci_frag_num_mbufs_free();
}
struct os_mbuf *
ble_hs_test_util_mbuf_alloc_all_but(int count)
{
@@ -1787,7 +1799,7 @@ ble_hs_test_util_mbuf_count(const struct ble_hs_test_util_mbuf_params *params)
ble_hs_process_rx_data_queue();
count = os_msys_num_free();
count = ble_hs_test_util_num_mbufs_free();
if (params->prev_tx) {
count += ble_hs_test_util_mbuf_chain_len(ble_hs_test_util_prev_tx_cur);
@@ -1838,7 +1850,7 @@ ble_hs_test_util_assert_mbufs_freed(
}
count = ble_hs_test_util_mbuf_count(params);
TEST_ASSERT(count == os_msys_count());
TEST_ASSERT(count == ble_hs_test_util_num_mbufs());
}
static int