diff --git a/tests/bluetooth/host/buf/CMakeLists.txt b/tests/bluetooth/host/buf/CMakeLists.txt deleted file mode 100644 index 59af3780d4f16..0000000000000 --- a/tests/bluetooth/host/buf/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# -# CMakeLists.txt file for creating of mocks library. -# - -add_library(mocks STATIC - mocks/net_buf.c - mocks/iso.c - mocks/hci_core.c - mocks/net_buf_expects.c - - ${ZEPHYR_BASE}/subsys/bluetooth/host/buf.c -) - -target_include_directories(mocks PUBLIC - . - ${ZEPHYR_BASE}/tests/bluetooth/host - ${ZEPHYR_BASE}/subsys/bluetooth -) - -target_link_libraries(mocks PRIVATE test_interface) diff --git a/tests/bluetooth/host/buf/bt_buf_get_evt/CMakeLists.txt b/tests/bluetooth/host/buf/bt_buf_get_evt/CMakeLists.txt deleted file mode 100644 index 46098c5146616..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_evt/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) - -project(bluetooth_bt_buf_get_evt) - -find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) - -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks) -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/buf mocks) - -target_link_libraries(testbinary PRIVATE mocks host_mocks) -target_sources(testbinary - PRIVATE - src/main.c - src/test_suite_hci_evt_cmd.c - src/test_suite_hci_evt_num_completed_packets.c -) diff --git a/tests/bluetooth/host/buf/bt_buf_get_evt/prj.conf b/tests/bluetooth/host/buf/bt_buf_get_evt/prj.conf deleted file mode 100644 index 652e7e5d1690e..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_evt/prj.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_ZTEST=y -CONFIG_BT=y -CONFIG_ASSERT=y -CONFIG_ASSERT_LEVEL=2 -CONFIG_ASSERT_VERBOSE=y diff --git a/tests/bluetooth/host/buf/bt_buf_get_evt/src/main.c b/tests/bluetooth/host/buf/bt_buf_get_evt/src/main.c deleted file mode 100644 index a17aee2b204ec..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_evt/src/main.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include "mocks/net_buf.h" -#include "mocks/net_buf_expects.h" -#include "mocks/buf_help_utils.h" - -DEFINE_FFF_GLOBALS; - -/* Rows count equals number of events x 2 */ -#define TEST_PARAMETERS_LUT_ROWS_COUNT 60 - -/* LUT containing testing parameters that will be used - * during each iteration to cover different scenarios - */ -static const struct testing_params testing_params_lut[] = { - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_UNKNOWN), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_VENDOR), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_INQUIRY_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_CONN_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_CONN_REQUEST), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_DISCONN_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_AUTH_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_REMOTE_NAME_REQ_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_ENCRYPT_CHANGE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_REMOTE_FEATURES), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_REMOTE_VERSION_INFO), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_HARDWARE_ERROR), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_ROLE_CHANGE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_PIN_CODE_REQ), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_LINK_KEY_REQ), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_LINK_KEY_NOTIFY), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_DATA_BUF_OVERFLOW), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_INQUIRY_RESULT_WITH_RSSI), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_REMOTE_EXT_FEATURES), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_SYNC_CONN_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_EXTENDED_INQUIRY_RESULT), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_ENCRYPT_KEY_REFRESH_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_IO_CAPA_REQ), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_IO_CAPA_RESP), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_USER_CONFIRM_REQ), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_USER_PASSKEY_REQ), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_SSP_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_USER_PASSKEY_NOTIFY), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_LE_META_EVENT), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_AUTH_PAYLOAD_TIMEOUT_EXP) -}; - -BUILD_ASSERT(ARRAY_SIZE(testing_params_lut) == TEST_PARAMETERS_LUT_ROWS_COUNT); - -ZTEST_SUITE(bt_buf_get_evt_default_events_returns_not_null, NULL, NULL, NULL, NULL, NULL); -ZTEST_SUITE(bt_buf_get_evt_default_events_returns_null, NULL, NULL, NULL, NULL, NULL); - -/* Return the memory pool used for event memory allocation - * based on compilation flags - */ -static struct net_buf_pool *get_memory_pool(bool discardable) -{ - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_evt_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - - if (discardable) { - memory_pool = bt_buf_get_discardable_pool(); - } - - return memory_pool; -} - -/* - * Return value from bt_buf_get_evt() should not be NULL - * - * Constraints: - * - All events except 'BT_HCI_EVT_CMD_COMPLETE', 'BT_HCI_EVT_CMD_STATUS' or - * 'BT_HCI_EVT_NUM_COMPLETED_PACKETS' - * - Timeout value is a positive non-zero value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_evt() - * - bt_buf_get_evt() returns the same reference returned by net_buf_alloc_fixed() - */ -ZTEST(bt_buf_get_evt_default_events_returns_not_null, test_returns_not_null) -{ - const size_t user_data_size = sizeof(struct bt_buf_data); - uint8_t expected_buf_data[sizeof(struct net_buf) + user_data_size]; - struct net_buf *expected_buf = (struct net_buf *)expected_buf_data; - struct net_buf *returned_buf; - uint8_t returned_buffer_type; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - struct testing_params const *params_vector; - uint8_t evt; - bool discardable; - - expected_buf->user_data_size = user_data_size; - - for (size_t i = 0; i < (ARRAY_SIZE(testing_params_lut)); i++) { - - /* Register resets */ - NET_BUF_FFF_FAKES_LIST(RESET_FAKE); - - params_vector = &testing_params_lut[i]; - evt = params_vector->evt; - discardable = params_vector->discardable; - - zassert_true((evt != BT_HCI_EVT_CMD_COMPLETE && evt != BT_HCI_EVT_CMD_STATUS && - evt != BT_HCI_EVT_NUM_COMPLETED_PACKETS), - "Invalid event type %u to this test", evt); - - net_buf_alloc_fixed_fake.return_val = expected_buf; - - returned_buf = bt_buf_get_evt(evt, discardable, timeout); - - expect_single_call_net_buf_alloc(get_memory_pool(discardable), &timeout); - expect_single_call_net_buf_reserve(expected_buf); - expect_not_called_net_buf_ref(); - - zassert_equal(returned_buf, expected_buf, - "bt_buf_get_evt() returned incorrect buffer pointer value"); - - returned_buffer_type = bt_buf_get_type(returned_buf); - zassert_equal(returned_buffer_type, BT_BUF_EVT, - "bt_buf_get_evt() returned incorrect buffer type %u, expected %u (%s)", - returned_buffer_type, BT_BUF_EVT, STRINGIFY(BT_BUF_EVT)); - } -} - -/* - * Return value from bt_buf_get_evt() should be NULL - * - * Constraints: - * - All events except 'BT_HCI_EVT_CMD_COMPLETE', 'BT_HCI_EVT_CMD_STATUS' or - * 'BT_HCI_EVT_NUM_COMPLETED_PACKETS' - * - Timeout value is a positive non-zero value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_evt() - * - bt_buf_get_evt() returns NULL - */ -ZTEST(bt_buf_get_evt_default_events_returns_null, test_returns_null) -{ - struct net_buf *returned_buf; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - struct testing_params const *params_vector; - uint8_t evt; - bool discardable; - - for (size_t i = 0; i < (ARRAY_SIZE(testing_params_lut)); i++) { - - /* Register resets */ - NET_BUF_FFF_FAKES_LIST(RESET_FAKE); - - params_vector = &testing_params_lut[i]; - evt = params_vector->evt; - discardable = params_vector->discardable; - - zassert_true((evt != BT_HCI_EVT_CMD_COMPLETE && evt != BT_HCI_EVT_CMD_STATUS && - evt != BT_HCI_EVT_NUM_COMPLETED_PACKETS), - "Invalid event type %u to this test", evt); - - net_buf_alloc_fixed_fake.return_val = NULL; - - returned_buf = bt_buf_get_evt(evt, discardable, timeout); - - expect_single_call_net_buf_alloc(get_memory_pool(discardable), &timeout); - expect_not_called_net_buf_reserve(); - expect_not_called_net_buf_ref(); - - zassert_is_null(returned_buf, - "bt_buf_get_evt() returned non-NULL value while expecting NULL"); - } -} diff --git a/tests/bluetooth/host/buf/bt_buf_get_evt/src/test_suite_hci_evt_cmd.c b/tests/bluetooth/host/buf/bt_buf_get_evt/src/test_suite_hci_evt_cmd.c deleted file mode 100644 index 2c4d2fed7aaa4..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_evt/src/test_suite_hci_evt_cmd.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include "mocks/net_buf.h" -#include "mocks/net_buf_expects.h" -#include "mocks/buf_help_utils.h" - -/* Rows count equals number of events x 2 */ -#define TEST_PARAMETERS_LUT_ROWS_COUNT 4 - -/* LUT containing testing parameters that will be used - * during each iteration to cover different scenarios - */ -static const struct testing_params testing_params_lut[] = { - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_CMD_COMPLETE), - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_CMD_STATUS) -}; - -BUILD_ASSERT(ARRAY_SIZE(testing_params_lut) == TEST_PARAMETERS_LUT_ROWS_COUNT); - -/* Return the memory pool used for event memory allocation - * based on compilation flags - */ -static struct net_buf_pool *get_memory_pool(void) -{ - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_evt_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - - return memory_pool; -} diff --git a/tests/bluetooth/host/buf/bt_buf_get_evt/src/test_suite_hci_evt_num_completed_packets.c b/tests/bluetooth/host/buf/bt_buf_get_evt/src/test_suite_hci_evt_num_completed_packets.c deleted file mode 100644 index c7f9f716b8824..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_evt/src/test_suite_hci_evt_num_completed_packets.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "mocks/net_buf.h" -#include "mocks/net_buf_expects.h" -#include "mocks/buf_help_utils.h" - -/* Rows count equals number of events x 2 */ -#define TEST_PARAMETERS_LUT_ROWS_COUNT 2 - -/* LUT containing testing parameters that will be used - * during each iteration to cover different scenarios - */ -static const struct testing_params testing_params_lut[] = { - TEST_PARAM_PAIR_DEFINE(BT_HCI_EVT_NUM_COMPLETED_PACKETS), -}; - -BUILD_ASSERT(ARRAY_SIZE(testing_params_lut) == TEST_PARAMETERS_LUT_ROWS_COUNT); - -/* Return the memory pool used for event memory allocation - * based on compilation flags - */ -static struct net_buf_pool *get_memory_pool(bool discardable) -{ - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_evt_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - - if ((IS_ENABLED(CONFIG_BT_CONN) || IS_ENABLED(CONFIG_BT_ISO))) { - memory_pool = bt_buf_get_num_complete_pool(); - } else { - if (discardable) { - memory_pool = bt_buf_get_discardable_pool(); - } - } - - return memory_pool; -} - -ZTEST_SUITE(bt_buf_get_evt_num_completed_pkts_type, NULL, NULL, NULL, NULL, NULL); - -/* - * Return value from bt_buf_get_evt() should not be NULL - * - * Constraints: - * - Only event type 'BT_HCI_EVT_NUM_COMPLETED_PACKETS' - * - Timeout value is a positive non-zero value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_evt() - * - bt_buf_get_evt() returns the same reference returned by net_buf_alloc_fixed() - */ -ZTEST(bt_buf_get_evt_num_completed_pkts_type, test_returns_not_null) -{ - const size_t user_data_size = sizeof(struct bt_buf_data); - uint8_t *expected_buf_data[sizeof(struct net_buf) + user_data_size]; - struct net_buf *expected_buf = (struct net_buf *)expected_buf_data; - struct net_buf *returned_buf; - uint8_t returned_buffer_type; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - struct testing_params const *params_vector; - uint8_t evt; - bool discardable; - - expected_buf->user_data_size = user_data_size; - - for (size_t i = 0; i < (ARRAY_SIZE(testing_params_lut)); i++) { - - /* Register resets */ - NET_BUF_FFF_FAKES_LIST(RESET_FAKE); - - params_vector = &testing_params_lut[i]; - evt = params_vector->evt; - discardable = params_vector->discardable; - - zassert_true((evt == BT_HCI_EVT_NUM_COMPLETED_PACKETS), - "Invalid event type %u to this test", evt); - - net_buf_alloc_fixed_fake.return_val = expected_buf; - - returned_buf = bt_buf_get_evt(evt, discardable, timeout); - - expect_single_call_net_buf_alloc(get_memory_pool(discardable), &timeout); - expect_single_call_net_buf_reserve(expected_buf); - expect_not_called_net_buf_ref(); - - zassert_equal(returned_buf, expected_buf, - "bt_buf_get_evt() returned incorrect buffer pointer value"); - - returned_buffer_type = bt_buf_get_type(returned_buf); - zassert_equal(returned_buffer_type, BT_BUF_EVT, - "bt_buf_get_evt() returned incorrect buffer type %u, expected %u (%s)", - returned_buffer_type, BT_BUF_EVT, STRINGIFY(BT_BUF_EVT)); - } -} - -/* - * Return value from bt_buf_get_evt() should be NULL - * - * Constraints: - * - Only event type 'BT_HCI_EVT_NUM_COMPLETED_PACKETS' - * - Timeout value is a positive non-zero value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_evt() - * - bt_buf_get_evt() returns NULL - */ -ZTEST(bt_buf_get_evt_num_completed_pkts_type, test_returns_null) -{ - struct net_buf *returned_buf; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - struct testing_params const *params_vector; - uint8_t evt; - bool discardable; - - for (size_t i = 0; i < (ARRAY_SIZE(testing_params_lut)); i++) { - - /* Register resets */ - NET_BUF_FFF_FAKES_LIST(RESET_FAKE); - - params_vector = &testing_params_lut[i]; - evt = params_vector->evt; - discardable = params_vector->discardable; - - zassert_true((evt == BT_HCI_EVT_NUM_COMPLETED_PACKETS), - "Invalid event type %u to this test", evt); - - net_buf_alloc_fixed_fake.return_val = NULL; - - returned_buf = bt_buf_get_evt(evt, discardable, timeout); - - expect_single_call_net_buf_alloc(get_memory_pool(discardable), &timeout); - expect_not_called_net_buf_reserve(); - expect_not_called_net_buf_ref(); - - zassert_is_null(returned_buf, - "bt_buf_get_evt() returned non-NULL value while expecting NULL"); - } -} diff --git a/tests/bluetooth/host/buf/bt_buf_get_evt/testcase.yaml b/tests/bluetooth/host/buf/bt_buf_get_evt/testcase.yaml deleted file mode 100644 index 2b7cf5aa41471..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_evt/testcase.yaml +++ /dev/null @@ -1,21 +0,0 @@ -common: - tags: - - bluetooth - - host -tests: - bluetooth.host.bt_buf_get_evt.default: - type: unit - bluetooth.host.bt_buf_get_evt.hci_acl_flow_control: - type: unit - extra_configs: - - CONFIG_BT_CENTRAL=y - - CONFIG_BT_HCI_ACL_FLOW_CONTROL=y - bluetooth.host.bt_buf_get_evt.iso_unicast: - type: unit - # enable CONFIG_BT_ISO_UNICAST - extra_configs: - - CONFIG_BT_ISO_CENTRAL=y - bluetooth.host.bt_buf_get_evt.iso_sync_receiver: - type: unit - extra_configs: - - CONFIG_BT_ISO_SYNC_RECEIVER=y diff --git a/tests/bluetooth/host/buf/bt_buf_get_rx/CMakeLists.txt b/tests/bluetooth/host/buf/bt_buf_get_rx/CMakeLists.txt deleted file mode 100644 index d657ec8206041..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_rx/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) - -project(bluetooth_bt_buf_get_rx) - -find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) - -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks) -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/buf mocks) - -target_link_libraries(testbinary PRIVATE mocks host_mocks) -target_sources(testbinary - PRIVATE - src/main.c - src/test_suite_invalid_inputs.c -) diff --git a/tests/bluetooth/host/buf/bt_buf_get_rx/prj.conf b/tests/bluetooth/host/buf/bt_buf_get_rx/prj.conf deleted file mode 100644 index 652e7e5d1690e..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_rx/prj.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_ZTEST=y -CONFIG_BT=y -CONFIG_ASSERT=y -CONFIG_ASSERT_LEVEL=2 -CONFIG_ASSERT_VERBOSE=y diff --git a/tests/bluetooth/host/buf/bt_buf_get_rx/src/main.c b/tests/bluetooth/host/buf/bt_buf_get_rx/src/main.c deleted file mode 100644 index 4324d75dde55e..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_rx/src/main.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include "mocks/net_buf.h" -#include "mocks/net_buf_expects.h" -#include "mocks/buf_help_utils.h" - -DEFINE_FFF_GLOBALS; - -static void tc_setup(void *f) -{ - /* Register resets */ - NET_BUF_FFF_FAKES_LIST(RESET_FAKE); -} - -ZTEST_SUITE(test_bt_buf_get_rx_returns_null, NULL, NULL, tc_setup, NULL, NULL); -ZTEST_SUITE(test_bt_buf_get_rx_returns_not_null, NULL, NULL, tc_setup, NULL, NULL); - -/* - * Return value from bt_buf_get_rx() should be NULL - * - * This is to test the behaviour when memory allocation request fails - * - * Constraints: - * - Use valid buffer type 'BT_BUF_EVT' - * - Timeout value is a positive non-zero value - * - net_buf_alloc() returns a NULL value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_rx() - * - bt_buf_get_rx() returns NULL - */ -ZTEST(test_bt_buf_get_rx_returns_null, test_returns_null_type_bt_buf_evt) -{ - struct net_buf *returned_buf; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_evt_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - - net_buf_alloc_fixed_fake.return_val = NULL; - - returned_buf = bt_buf_get_rx(BT_BUF_EVT, timeout); - - expect_single_call_net_buf_alloc(memory_pool, &timeout); - expect_not_called_net_buf_reserve(); - expect_not_called_net_buf_ref(); - - zassert_is_null(returned_buf, - "bt_buf_get_rx() returned non-NULL value while expecting NULL"); -} - -/* - * Return value from bt_buf_get_rx() should be NULL - * - * This is to test the behaviour when memory allocation request fails - * - * Constraints: - * - Use valid buffer type 'BT_BUF_ACL_IN' - * - Timeout value is a positive non-zero value - * - net_buf_alloc() returns a NULL value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_rx() - * - bt_buf_get_rx() returns NULL - */ -ZTEST(test_bt_buf_get_rx_returns_null, test_returns_null_type_bt_buf_acl_in) -{ - struct net_buf *returned_buf; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_acl_in_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - - net_buf_alloc_fixed_fake.return_val = NULL; - - returned_buf = bt_buf_get_rx(BT_BUF_ACL_IN, timeout); - - expect_single_call_net_buf_alloc(memory_pool, &timeout); - expect_not_called_net_buf_reserve(); - expect_not_called_net_buf_ref(); - - zassert_is_null(returned_buf, - "bt_buf_get_rx() returned non-NULL value while expecting NULL"); -} - -/* - * Return value from bt_buf_get_rx() should be NULL - * - * This is to test the behaviour when memory allocation request fails - * - * Constraints: - * - Use valid buffer type 'BT_BUF_ISO_IN' - * - Timeout value is a positive non-zero value - * - net_buf_alloc() returns a NULL value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_rx() - * - bt_buf_get_rx() returns NULL - */ -ZTEST(test_bt_buf_get_rx_returns_null, test_returns_null_type_bt_buf_iso_in) -{ - struct net_buf *returned_buf; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) || IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER))) { - memory_pool = bt_buf_get_iso_rx_pool(); - } else { - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_acl_in_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - } - - net_buf_alloc_fixed_fake.return_val = NULL; - - returned_buf = bt_buf_get_rx(BT_BUF_ISO_IN, timeout); - - expect_single_call_net_buf_alloc(memory_pool, &timeout); - expect_not_called_net_buf_reserve(); - expect_not_called_net_buf_ref(); - - zassert_is_null(returned_buf, - "bt_buf_get_rx() returned non-NULL value while expecting NULL"); -} - -/* - * Return value from bt_buf_get_rx() shouldn't be NULL - * - * Constraints: - * - Use valid buffer type 'BT_BUF_EVT' - * - Timeout value is a positive non-zero value - * - net_buf_alloc() return a not NULL value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_rx() - * - bt_buf_get_rx() returns the same value returned by net_buf_alloc_fixed() - * - Return buffer matches the buffer type requested - */ -ZTEST(test_bt_buf_get_rx_returns_not_null, test_returns_not_null_type_bt_buf_evt) -{ - static struct net_buf expected_buf; - struct net_buf *returned_buf; - uint8_t returned_buffer_type; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_evt_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - - net_buf_alloc_fixed_fake.return_val = &expected_buf; - - returned_buf = bt_buf_get_rx(BT_BUF_EVT, timeout); - - expect_single_call_net_buf_alloc(memory_pool, &timeout); - expect_single_call_net_buf_reserve(&expected_buf); - expect_not_called_net_buf_ref(); - - zassert_equal(returned_buf, &expected_buf, - "bt_buf_get_rx() returned incorrect buffer pointer value"); - - returned_buffer_type = bt_buf_get_type(returned_buf); - zassert_equal(returned_buffer_type, BT_BUF_EVT, - "bt_buf_get_rx() returned incorrect buffer type %u, expected %u (%s)", - returned_buffer_type, BT_BUF_EVT, STRINGIFY(BT_BUF_EVT)); -} - -/* - * Return value from bt_buf_get_rx() shouldn't be NULL - * - * Constraints: - * - Use valid buffer type 'BT_BUF_ACL_IN' - * - Timeout value is a positive non-zero value - * - net_buf_alloc() return a not NULL value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_rx() - * - bt_buf_get_rx() returns the same value returned by net_buf_alloc_fixed() - * - Return buffer matches the buffer type requested - */ -ZTEST(test_bt_buf_get_rx_returns_not_null, test_returns_not_null_type_bt_buf_acl_in) -{ - static struct net_buf expected_buf; - struct net_buf *returned_buf; - uint8_t returned_buffer_type; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_acl_in_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - - net_buf_alloc_fixed_fake.return_val = &expected_buf; - - returned_buf = bt_buf_get_rx(BT_BUF_ACL_IN, timeout); - - expect_single_call_net_buf_alloc(memory_pool, &timeout); - expect_single_call_net_buf_reserve(&expected_buf); - expect_not_called_net_buf_ref(); - - zassert_equal(returned_buf, &expected_buf, - "bt_buf_get_rx() returned incorrect buffer pointer value"); - - returned_buffer_type = bt_buf_get_type(returned_buf); - zassert_equal(returned_buffer_type, BT_BUF_ACL_IN, - "bt_buf_get_rx() returned incorrect buffer type %u, expected %u (%s)", - returned_buffer_type, BT_BUF_ACL_IN, STRINGIFY(BT_BUF_ACL_IN)); -} - -/* - * Return value from bt_buf_get_rx() shouldn't be NULL - * - * Constraints: - * - Use valid buffer type 'BT_BUF_ISO_IN' - * - Timeout value is a positive non-zero value - * - net_buf_alloc() return a not NULL value - * - * Expected behaviour: - * - net_buf_alloc() to be called with the correct memory allocation pool - * and the same timeout value passed to bt_buf_get_rx() - * - bt_buf_get_rx() returns the same value returned by net_buf_alloc_fixed() - * - Return buffer matches the buffer type requested - */ -ZTEST(test_bt_buf_get_rx_returns_not_null, test_returns_not_null_type_bt_buf_iso_in) -{ - static struct net_buf expected_buf; - struct net_buf *returned_buf; - uint8_t returned_buffer_type; - k_timeout_t timeout = Z_TIMEOUT_TICKS(1000); - - struct net_buf_pool *memory_pool; - - if ((IS_ENABLED(CONFIG_BT_ISO_UNICAST) || IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER))) { - memory_pool = bt_buf_get_iso_rx_pool(); - } else { - if ((IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL))) { - memory_pool = bt_buf_get_acl_in_pool(); - } else { - memory_pool = bt_buf_get_hci_rx_pool(); - } - } - - net_buf_alloc_fixed_fake.return_val = &expected_buf; - - returned_buf = bt_buf_get_rx(BT_BUF_ISO_IN, timeout); - - expect_single_call_net_buf_alloc(memory_pool, &timeout); - expect_single_call_net_buf_reserve(&expected_buf); - expect_not_called_net_buf_ref(); - - zassert_equal(returned_buf, &expected_buf, - "bt_buf_get_rx() returned incorrect buffer pointer value"); - - returned_buffer_type = bt_buf_get_type(returned_buf); - zassert_equal(returned_buffer_type, BT_BUF_ISO_IN, - "bt_buf_get_rx() returned incorrect buffer type %u, expected %u (%s)", - returned_buffer_type, BT_BUF_ISO_IN, STRINGIFY(BT_BUF_ISO_IN)); -} diff --git a/tests/bluetooth/host/buf/bt_buf_get_rx/src/test_suite_invalid_inputs.c b/tests/bluetooth/host/buf/bt_buf_get_rx/src/test_suite_invalid_inputs.c deleted file mode 100644 index 5034c34d013a4..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_rx/src/test_suite_invalid_inputs.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "host_mocks/assert.h" - -ZTEST_SUITE(test_bt_buf_get_rx_invalid_input, NULL, NULL, NULL, NULL, NULL); - -/* - * Test passing invalid buffer type to bt_buf_get_rx() - * - * Constraints: - * - Use invalid buffer type 'BT_BUF_CMD' - * - * Expected behaviour: - * - An assertion should be raised as an invalid parameter was used - */ -ZTEST(test_bt_buf_get_rx_invalid_input, test_invalid_input_type_bt_buf_cmd) -{ - expect_assert(); - bt_buf_get_rx(BT_BUF_CMD, Z_TIMEOUT_TICKS(1000)); -} - -/* - * Test passing invalid buffer type to bt_buf_get_rx() - * - * Constraints: - * - Use invalid buffer type 'BT_BUF_ACL_OUT' - * - * Expected behaviour: - * - An assertion should be raised as an invalid parameter was used - */ -ZTEST(test_bt_buf_get_rx_invalid_input, test_invalid_input_type_bt_buf_acl_out) -{ - expect_assert(); - bt_buf_get_rx(BT_BUF_ACL_OUT, Z_TIMEOUT_TICKS(1000)); -} - -/* - * Test passing invalid buffer type to bt_buf_get_rx() - * - * Constraints: - * - Use invalid buffer type 'BT_BUF_ISO_OUT' - * - * Expected behaviour: - * - An assertion should be raised as an invalid parameter was used - */ -ZTEST(test_bt_buf_get_rx_invalid_input, test_invalid_input_type_bt_buf_iso_out) -{ - expect_assert(); - bt_buf_get_rx(BT_BUF_ISO_OUT, Z_TIMEOUT_TICKS(1000)); -} - -/* - * Test passing invalid buffer type to bt_buf_get_rx() - * - * Constraints: - * - Use invalid buffer type 'BT_BUF_H4' - * - * Expected behaviour: - * - An assertion should be raised as an invalid parameter was used - */ -ZTEST(test_bt_buf_get_rx_invalid_input, test_invalid_input_type_bt_buf_h4) -{ - expect_assert(); - bt_buf_get_rx(BT_BUF_H4, Z_TIMEOUT_TICKS(1000)); -} diff --git a/tests/bluetooth/host/buf/bt_buf_get_rx/testcase.yaml b/tests/bluetooth/host/buf/bt_buf_get_rx/testcase.yaml deleted file mode 100644 index bfe1120055ee7..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_rx/testcase.yaml +++ /dev/null @@ -1,21 +0,0 @@ -common: - tags: - - bluetooth - - host -tests: - bluetooth.host.bt_buf_get_rx.default: - type: unit - bluetooth.host.bt_buf_get_rx.hci_acl_flow_control: - type: unit - extra_configs: - - CONFIG_BT_CENTRAL=y - - CONFIG_BT_HCI_ACL_FLOW_CONTROL=y - bluetooth.host.bt_buf_get_rx.iso_unicast: - type: unit - # enable CONFIG_BT_ISO_UNICAST - extra_configs: - - CONFIG_BT_ISO_CENTRAL=y - bluetooth.host.bt_buf_get_rx.iso_sync_receiver: - type: unit - extra_configs: - - CONFIG_BT_ISO_SYNC_RECEIVER=y diff --git a/tests/bluetooth/host/buf/bt_buf_get_type/CMakeLists.txt b/tests/bluetooth/host/buf/bt_buf_get_type/CMakeLists.txt deleted file mode 100644 index 0b1f50a25af6c..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_type/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) - -project(bluetooth_bt_buf_get_type) - -find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) - -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks) -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/buf mocks) - -target_link_libraries(testbinary PRIVATE mocks host_mocks) -target_sources(testbinary - PRIVATE - src/main.c -) diff --git a/tests/bluetooth/host/buf/bt_buf_get_type/prj.conf b/tests/bluetooth/host/buf/bt_buf_get_type/prj.conf deleted file mode 100644 index 652e7e5d1690e..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_type/prj.conf +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_ZTEST=y -CONFIG_BT=y -CONFIG_ASSERT=y -CONFIG_ASSERT_LEVEL=2 -CONFIG_ASSERT_VERBOSE=y diff --git a/tests/bluetooth/host/buf/bt_buf_get_type/src/main.c b/tests/bluetooth/host/buf/bt_buf_get_type/src/main.c deleted file mode 100644 index 2b5f49e0cfe8f..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_type/src/main.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -DEFINE_FFF_GLOBALS; - -/* Rows count equals number of types */ -#define TEST_PARAMETERS_LUT_ROWS_COUNT 7 - -/* LUT containing testing parameters that will be used - * during each iteration to cover different scenarios - */ -static const enum bt_buf_type testing_params_lut[] = { - /** HCI command */ - BT_BUF_CMD, - /** HCI event */ - BT_BUF_EVT, - /** Outgoing ACL data */ - BT_BUF_ACL_OUT, - /** Incoming ACL data */ - BT_BUF_ACL_IN, - /** Outgoing ISO data */ - BT_BUF_ISO_OUT, - /** Incoming ISO data */ - BT_BUF_ISO_IN, - /** H:4 data */ - BT_BUF_H4, -}; - -BUILD_ASSERT(ARRAY_SIZE(testing_params_lut) == TEST_PARAMETERS_LUT_ROWS_COUNT); - -ZTEST_SUITE(test_bt_buf_get_set_retrieve_type, NULL, NULL, NULL, NULL, NULL); - -/* - * Buffer type is set and retrieved correctly - * - * Constraints: - * - Use valid buffer buffer reference - * - Use valid buffer type - * - * Expected behaviour: - * - Buffer type field inside 'struct net_buf' is set correctly - * - Retrieving buffer type through bt_buf_get_type() returns the correct - * value - */ -ZTEST(test_bt_buf_get_set_retrieve_type, test_buffer_type_set_get_correctly) -{ - static struct net_buf testing_buffer; - struct net_buf *buf = &testing_buffer; - enum bt_buf_type current_test_buffer_type; - enum bt_buf_type buffer_type_set, returned_buffer_type; - - for (size_t i = 0; i < ARRAY_SIZE(testing_params_lut); i++) { - - current_test_buffer_type = testing_params_lut[i]; - - bt_buf_set_type(buf, current_test_buffer_type); - - returned_buffer_type = bt_buf_get_type(buf); - buffer_type_set = ((struct bt_buf_data *)net_buf_user_data(buf))->type; - - zassert_equal(buffer_type_set, current_test_buffer_type, - "Buffer type %u set by bt_buf_set_type() is incorrect, expected %u", - buffer_type_set, current_test_buffer_type); - - zassert_equal( - returned_buffer_type, current_test_buffer_type, - "Buffer type %u returned by bt_buf_get_type() is incorrect, expected %u", - returned_buffer_type, current_test_buffer_type); - } -} diff --git a/tests/bluetooth/host/buf/bt_buf_get_type/testcase.yaml b/tests/bluetooth/host/buf/bt_buf_get_type/testcase.yaml deleted file mode 100644 index d7ca762e312f7..0000000000000 --- a/tests/bluetooth/host/buf/bt_buf_get_type/testcase.yaml +++ /dev/null @@ -1,7 +0,0 @@ -common: - tags: - - bluetooth - - host -tests: - bluetooth.host.bt_buf_get_type.default: - type: unit diff --git a/tests/bluetooth/host/buf/mocks/buf_help_utils.h b/tests/bluetooth/host/buf/mocks/buf_help_utils.h deleted file mode 100644 index aa7a420291fe2..0000000000000 --- a/tests/bluetooth/host/buf/mocks/buf_help_utils.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -struct net_buf_pool *bt_buf_get_evt_pool(void); -struct net_buf_pool *bt_buf_get_acl_in_pool(void); -struct net_buf_pool *bt_buf_get_hci_rx_pool(void); -struct net_buf_pool *bt_buf_get_discardable_pool(void); -struct net_buf_pool *bt_buf_get_num_complete_pool(void); -struct net_buf_pool *bt_buf_get_discardable_pool(void); -struct net_buf_pool *bt_buf_get_num_complete_pool(void); -struct net_buf_pool *bt_buf_get_iso_rx_pool(void); - -/* LUT testing parameter item */ -struct testing_params { - uint8_t evt; /* Event type */ - bool discardable; /* Discardable flag */ -}; - -#define TEST_PARAM_PAIR_DEFINE(EVT) {EVT, true}, {EVT, false} diff --git a/tests/bluetooth/host/buf/mocks/hci_core.c b/tests/bluetooth/host/buf/mocks/hci_core.c deleted file mode 100644 index cec6324089943..0000000000000 --- a/tests/bluetooth/host/buf/mocks/hci_core.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -struct bt_dev bt_dev = { - .manufacturer = 0x1234, -}; - -#if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL) -void bt_hci_host_num_completed_packets(struct net_buf *buf) -{ -} -#endif diff --git a/tests/bluetooth/host/buf/mocks/iso.c b/tests/bluetooth/host/buf/mocks/iso.c deleted file mode 100644 index 3a66fad20582f..0000000000000 --- a/tests/bluetooth/host/buf/mocks/iso.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include - -/* This file doesn't contain mocks, but rather fakes of the necessary parts of - * subsys/bluetooth/host/iso.c. The API implementations that are copied here - * should be kept in sync with the original. - */ - -#if defined(CONFIG_BT_ISO_UNICAST) || defined(CONFIG_BT_ISO_SYNC_RECEIVER) -NET_BUF_POOL_FIXED_DEFINE(iso_rx_pool, CONFIG_BT_ISO_RX_BUF_COUNT, - BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_RX_MTU), 8, NULL); - -struct net_buf *bt_iso_get_rx(k_timeout_t timeout) -{ - struct net_buf *buf = net_buf_alloc(&iso_rx_pool, timeout); - - if (buf) { - net_buf_reserve(buf, BT_BUF_RESERVE); - bt_buf_set_type(buf, BT_BUF_ISO_IN); - } - - return buf; -} - -struct net_buf_pool *bt_buf_get_iso_rx_pool(void) -{ - return &iso_rx_pool; -} -#endif diff --git a/tests/bluetooth/host/buf/mocks/net_buf.c b/tests/bluetooth/host/buf/mocks/net_buf.c deleted file mode 100644 index 03490d0064733..0000000000000 --- a/tests/bluetooth/host/buf/mocks/net_buf.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -static uint8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, - k_timeout_t timeout) -{ - zassert_unreachable("Unexpected call to '%s()' occurred", __func__); - return NULL; -} - -static void fixed_data_unref(struct net_buf *buf, uint8_t *data) -{ - zassert_unreachable("Unexpected call to '%s()' occurred", __func__); -} - -const struct net_buf_data_cb net_buf_fixed_cb = { - .alloc = fixed_data_alloc, - .unref = fixed_data_unref, -}; - -DEFINE_FAKE_VALUE_FUNC(struct net_buf *, net_buf_alloc_fixed, struct net_buf_pool *, k_timeout_t); -DEFINE_FAKE_VOID_FUNC(net_buf_simple_reserve, struct net_buf_simple *, size_t); -DEFINE_FAKE_VALUE_FUNC(struct net_buf *, net_buf_ref, struct net_buf *); diff --git a/tests/bluetooth/host/buf/mocks/net_buf.h b/tests/bluetooth/host/buf/mocks/net_buf.h deleted file mode 100644 index d137f4f6d0253..0000000000000 --- a/tests/bluetooth/host/buf/mocks/net_buf.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include - -/* List of fakes used by this unit tester */ -#define NET_BUF_FFF_FAKES_LIST(FAKE) \ - FAKE(net_buf_alloc_fixed) \ - FAKE(net_buf_simple_reserve) \ - FAKE(net_buf_ref) - -DECLARE_FAKE_VALUE_FUNC(struct net_buf *, net_buf_alloc_fixed, struct net_buf_pool *, k_timeout_t); -DECLARE_FAKE_VOID_FUNC(net_buf_simple_reserve, struct net_buf_simple *, size_t); -DECLARE_FAKE_VALUE_FUNC(struct net_buf *, net_buf_ref, struct net_buf *); diff --git a/tests/bluetooth/host/buf/mocks/net_buf_expects.c b/tests/bluetooth/host/buf/mocks/net_buf_expects.c deleted file mode 100644 index e8930309147e2..0000000000000 --- a/tests/bluetooth/host/buf/mocks/net_buf_expects.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include "mocks/net_buf.h" -#include "mocks/net_buf_expects.h" - -void expect_single_call_net_buf_alloc(struct net_buf_pool *pool, k_timeout_t *timeout) -{ - const char *func_name = "net_buf_alloc_fixed"; - - zassert_equal(net_buf_alloc_fixed_fake.call_count, 1, "'%s()' was called more than once", - func_name); - - zassert_equal_ptr(net_buf_alloc_fixed_fake.arg0_val, pool, - "'%s()' was called with incorrect '%s' value", func_name, "pool"); - - zassert_mem_equal(&net_buf_alloc_fixed_fake.arg1_val, timeout, sizeof(k_timeout_t), - "'%s()' was called with incorrect '%s' value", func_name, "timeout"); -} - -void expect_not_called_net_buf_alloc(void) -{ - const char *func_name = "net_buf_alloc_fixed"; - - zassert_equal(net_buf_alloc_fixed_fake.call_count, 0, "'%s()' was called unexpectedly", - func_name); -} - -void expect_single_call_net_buf_reserve(struct net_buf *buf) -{ - const char *func_name = "net_buf_simple_reserve"; - - zassert_equal(net_buf_simple_reserve_fake.call_count, 1, "'%s()' was called more than once", - func_name); - - zassert_equal_ptr(net_buf_simple_reserve_fake.arg0_val, &buf->b, - "'%s()' was called with incorrect '%s' value", func_name, "buf"); - - zassert_equal(net_buf_simple_reserve_fake.arg1_val, BT_BUF_RESERVE, - "'%s()' was called with incorrect '%s' value", func_name, "reserve"); -} - -void expect_not_called_net_buf_reserve(void) -{ - const char *func_name = "net_buf_simple_reserve"; - - zassert_equal(net_buf_simple_reserve_fake.call_count, 0, "'%s()' was called unexpectedly", - func_name); -} - -void expect_single_call_net_buf_ref(struct net_buf *buf) -{ - const char *func_name = "net_buf_ref"; - - zassert_equal(net_buf_ref_fake.call_count, 1, "'%s()' was called more than once", - func_name); - - zassert_equal_ptr(net_buf_ref_fake.arg0_val, buf, - "'%s()' was called with incorrect '%s' value", func_name, "buf"); -} - -void expect_not_called_net_buf_ref(void) -{ - const char *func_name = "net_buf_ref"; - - zassert_equal(net_buf_ref_fake.call_count, 0, "'%s()' was called unexpectedly", - func_name); -} diff --git a/tests/bluetooth/host/buf/mocks/net_buf_expects.h b/tests/bluetooth/host/buf/mocks/net_buf_expects.h deleted file mode 100644 index 99e84fd85be4f..0000000000000 --- a/tests/bluetooth/host/buf/mocks/net_buf_expects.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -/* - * Validate expected behaviour when net_buf_alloc() is called - * - * Expected behaviour: - * - net_buf_alloc() to be called once with : - * - correct memory allocation pool - */ -void expect_single_call_net_buf_alloc(struct net_buf_pool *pool, k_timeout_t *timeout); - -/* - * Validate expected behaviour when net_buf_alloc() isn't called - * - * Expected behaviour: - * - net_buf_alloc() isn't called at all - */ -void expect_not_called_net_buf_alloc(void); - -/* - * Validate expected behaviour when net_buf_reserve() is called - * - * Expected behaviour: - * - net_buf_reserve() to be called once with : - * - correct reference value - * - 'reserve' argument set to 'BT_BUF_RESERVE' value - */ -void expect_single_call_net_buf_reserve(struct net_buf *buf); - -/* - * Validate expected behaviour when net_buf_reserve() isn't called - * - * Expected behaviour: - * - net_buf_reserve() isn't called at all - */ -void expect_not_called_net_buf_reserve(void); - -/* - * Validate expected behaviour when net_buf_ref() is called - * - * Expected behaviour: - * - net_buf_ref() to be called once with correct reference value - */ -void expect_single_call_net_buf_ref(struct net_buf *buf); - -/* - * Validate expected behaviour when net_buf_ref() isn't called - * - * Expected behaviour: - * - net_buf_ref() isn't called at all - */ -void expect_not_called_net_buf_ref(void);