diff --git a/tests/bluetooth/host/ecc/CMakeLists.txt b/tests/bluetooth/host/ecc/CMakeLists.txt deleted file mode 100644 index 4f3af9f81604b5..00000000000000 --- a/tests/bluetooth/host/ecc/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# -# CMakeLists.txt file for creating of mocks library. -# - -add_library(mocks STATIC - mocks/net_buf.c - mocks/net_buf_expects.c - mocks/hci_core.c - mocks/hci_core_expects.c - mocks/ecc_help_utils.c - - ${ZEPHYR_BASE}/subsys/bluetooth/host/ecc.c - ${ZEPHYR_BASE}/subsys/logging/log_minimal.c -) - -target_include_directories(mocks PUBLIC - . - ${ZEPHYR_BASE}/subsys/bluetooth - ${ZEPHYR_BASE}/subsys/bluetooth/host - ${ZEPHYR_BASE}/tests/bluetooth/host - ${ZEPHYR_BASE}/tests/bluetooth/host/ecc/mocks -) - -target_link_libraries(mocks PRIVATE test_interface) diff --git a/tests/bluetooth/host/ecc/bt_dh_key_gen/CMakeLists.txt b/tests/bluetooth/host/ecc/bt_dh_key_gen/CMakeLists.txt deleted file mode 100644 index 9281842df2a3f4..00000000000000 --- a/tests/bluetooth/host/ecc/bt_dh_key_gen/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) - -find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE}) - -project(bt_dh_key_gen) - -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks) -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/ecc mocks) - -target_sources(testbinary PRIVATE - src/main.c - src/test_suite_invalid_inputs.c -) -target_link_libraries(testbinary PRIVATE mocks host_mocks) diff --git a/tests/bluetooth/host/ecc/bt_dh_key_gen/prj.conf b/tests/bluetooth/host/ecc/bt_dh_key_gen/prj.conf deleted file mode 100644 index 9b9d1e2cafc40c..00000000000000 --- a/tests/bluetooth/host/ecc/bt_dh_key_gen/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG_ZTEST=y -CONFIG_BT=y -CONFIG_BT_CENTRAL=y -CONFIG_BT_MAX_PAIRED=7 -CONFIG_ASSERT=y -CONFIG_ASSERT_LEVEL=2 -CONFIG_ASSERT_VERBOSE=y -CONFIG_ASSERT_ON_ERRORS=y diff --git a/tests/bluetooth/host/ecc/bt_dh_key_gen/src/main.c b/tests/bluetooth/host/ecc/bt_dh_key_gen/src/main.c deleted file mode 100644 index 20638ad580db4f..00000000000000 --- a/tests/bluetooth/host/ecc/bt_dh_key_gen/src/main.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "mocks/ecc_help_utils.h" -#include "mocks/hci_core.h" -#include "mocks/hci_core_expects.h" -#include "mocks/net_buf.h" -#include "mocks/net_buf_expects.h" - -#include -#include -#include - -#include -#include - -DEFINE_FFF_GLOBALS; - -static void fff_reset_rule_before(const struct ztest_unit_test *test, void *fixture) -{ - bt_dh_key_cb_t *dh_key_cb = bt_ecc_get_dh_key_cb(); - - *dh_key_cb = NULL; - memset(&bt_dev, 0x00, sizeof(struct bt_dev)); - - HCI_CORE_FFF_FAKES_LIST(RESET_FAKE); -} - -ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); - -ZTEST_SUITE(bt_dh_key_gen, NULL, NULL, NULL, NULL, NULL); - -static void bt_dh_key_unreachable_cb(const uint8_t key[BT_DH_KEY_LEN]) -{ - zassert_unreachable("Unexpected call to '%s()' occurred", __func__); -} - -/* - * Test DH key generation succeeds - * - * Constraints: - * - 'BT_DEV_HAS_PUB_KEY' flag is set - * - 'BT_DEV_PUB_KEY_BUSY' flag isn't set - * - 'CONFIG_BT_USE_DEBUG_KEYS' isn't enabled - * - * Expected behaviour: - * - bt_dh_key_gen() returns 0 (success) - */ -ZTEST(bt_dh_key_gen, test_generate_dh_key_passes) -{ - int result; - struct net_buf net_buff = {0}; - struct bt_hci_cp_le_generate_dhkey cp = {0}; - const uint8_t remote_pk[BT_PUB_KEY_LEN] = {0}; - - Z_TEST_SKIP_IFDEF(CONFIG_BT_USE_DEBUG_KEYS); - - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - atomic_clear_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - - /* This makes hci_generate_dhkey_v1() succeeds and returns 0 */ - net_buf_simple_add_fake.return_val = &cp; - bt_hci_cmd_create_fake.return_val = &net_buff; - bt_hci_cmd_send_sync_fake.return_val = 0; - - result = bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_cb); - - expect_single_call_net_buf_simple_add(&net_buff.b, sizeof(cp)); - expect_single_call_bt_hci_cmd_create(BT_HCI_OP_LE_GENERATE_DHKEY, sizeof(cp)); - expect_single_call_bt_hci_cmd_send_sync(BT_HCI_OP_LE_GENERATE_DHKEY); - - zassert_ok(result, "Unexpected error code '%d' was returned", result); -} - -/* - * Test DH key generation succeeds with 'CONFIG_BT_USE_DEBUG_KEYS' enabled - * - * Constraints: - * - 'BT_DEV_HAS_PUB_KEY' flag is set - * - 'BT_DEV_PUB_KEY_BUSY' flag isn't set - * - 'CONFIG_BT_USE_DEBUG_KEYS' is enabled - * - * Expected behaviour: - * - bt_dh_key_gen() returns 0 (success) - */ -ZTEST(bt_dh_key_gen, test_generate_dh_key_passes_with_debug_keys_enabled) -{ - int result; - struct net_buf net_buff = {0}; - struct bt_hci_cp_le_generate_dhkey_v2 cp = {0}; - const uint8_t remote_pk[BT_PUB_KEY_LEN] = {0}; - - Z_TEST_SKIP_IFNDEF(CONFIG_BT_USE_DEBUG_KEYS); - - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - atomic_clear_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - - /* Set "ECC Debug Keys" command support bit */ - bt_dev.supported_commands[41] |= BIT(2); - - /* This makes hci_generate_dhkey_v2() succeeds and returns 0 */ - net_buf_simple_add_fake.return_val = &cp; - bt_hci_cmd_create_fake.return_val = &net_buff; - bt_hci_cmd_send_sync_fake.return_val = 0; - - result = bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_cb); - - expect_single_call_net_buf_simple_add(&net_buff.b, sizeof(cp)); - expect_single_call_bt_hci_cmd_create(BT_HCI_OP_LE_GENERATE_DHKEY_V2, sizeof(cp)); - expect_single_call_bt_hci_cmd_send_sync(BT_HCI_OP_LE_GENERATE_DHKEY_V2); - - zassert_ok(result, "Unexpected error code '%d' was returned", result); -} diff --git a/tests/bluetooth/host/ecc/bt_dh_key_gen/src/test_suite_invalid_inputs.c b/tests/bluetooth/host/ecc/bt_dh_key_gen/src/test_suite_invalid_inputs.c deleted file mode 100644 index b8da191fe3f9f1..00000000000000 --- a/tests/bluetooth/host/ecc/bt_dh_key_gen/src/test_suite_invalid_inputs.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "host_mocks/assert.h" -#include "mocks/ecc_help_utils.h" -#include "mocks/hci_core.h" -#include "mocks/hci_core_expects.h" -#include "mocks/net_buf.h" -#include "mocks/net_buf_expects.h" - -#include -#include - -#include -#include - -ZTEST_SUITE(bt_dh_key_gen_invalid_cases, NULL, NULL, NULL, NULL, NULL); - -static void bt_dh_key_unreachable_cb(const uint8_t key[BT_DH_KEY_LEN]) -{ - zassert_unreachable("Unexpected call to '%s()' occurred", __func__); -} - -/* - * Test passing NULL reference for the 'remote_pk' argument - * - * Constraints: - * - NULL reference is used for the 'remote_pk' argument - * - * Expected behaviour: - * - An assertion is raised and execution stops - */ -ZTEST(bt_dh_key_gen_invalid_cases, test_null_remote_pk_reference) -{ - expect_assert(); - bt_dh_key_gen(NULL, bt_dh_key_unreachable_cb); -} - -/* - * Test passing NULL reference for the 'dh_key_cb' argument - * - * Constraints: - * - NULL reference is used for the 'dh_key_cb' argument - * - * Expected behaviour: - * - An assertion is raised and execution stops - */ -ZTEST(bt_dh_key_gen_invalid_cases, test_null_dh_key_cb_reference) -{ - const uint8_t remote_pk[BT_PUB_KEY_LEN] = {0}; - - expect_assert(); - bt_dh_key_gen(remote_pk, NULL); -} - -/* - * Test DH key generation fails if the callback is already registered - * - * Constraints: - * - 'BT_DEV_HAS_PUB_KEY' flag is set - * - 'BT_DEV_PUB_KEY_BUSY' flag isn't set - * - * Expected behaviour: - * - bt_dh_key_gen() returns a negative error code (-EALREADY) - */ -ZTEST(bt_dh_key_gen_invalid_cases, test_callback_already_registered) -{ - int result; - struct net_buf net_buff = {0}; - struct bt_hci_cp_le_generate_dhkey cp = {0}; - const uint8_t remote_pk[BT_PUB_KEY_LEN] = {0}; - - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - atomic_clear_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - - /* This makes hci_generate_dhkey_v1() succeeds and returns 0 */ - net_buf_simple_add_fake.return_val = &cp; - bt_hci_cmd_create_fake.return_val = &net_buff; - bt_hci_cmd_send_sync_fake.return_val = 0; - - /* Pass first call that will set dh_key_cb = cb*/ - bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_cb); - result = bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_cb); - - zassert_true(result == -EALREADY, "Unexpected error code '%d' was returned", result); -} - -static void bt_dh_key_unreachable_2nd_trial_cb(const uint8_t key[BT_DH_KEY_LEN]) -{ - zassert_unreachable("Unexpected call to '%s()' occurred", __func__); -} - -/* - * Test DH key generation fails if a current key generation cycle hasn't been finished yet and - * 'dh_key_cb' isn't NULL. - * - * Constraints: - * - 'BT_DEV_HAS_PUB_KEY' flag is set - * - 'BT_DEV_PUB_KEY_BUSY' flag isn't set - * - * Expected behaviour: - * - bt_dh_key_gen() returns a negative error code (-EBUSY) - */ -ZTEST(bt_dh_key_gen_invalid_cases, test_generate_key_parallel_with_running_one) -{ - int result; - struct net_buf net_buff = {0}; - struct bt_hci_cp_le_generate_dhkey cp = {0}; - const uint8_t remote_pk[BT_PUB_KEY_LEN] = {0}; - - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - atomic_clear_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - - /* This makes hci_generate_dhkey_v1() succeeds and returns 0 */ - net_buf_simple_add_fake.return_val = &cp; - bt_hci_cmd_create_fake.return_val = &net_buff; - bt_hci_cmd_send_sync_fake.return_val = 0; - - /* Pass first call that will set dh_key_cb = cb*/ - bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_cb); - result = bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_2nd_trial_cb); - - zassert_true(result == -EBUSY, "Unexpected error code '%d' was returned", result); -} - -/* - * Test DH key generation fails if a current key generation cycle hasn't been finished yet and - * 'dh_key_cb' isn't NULL. - * - * Constraints: - * - 'BT_DEV_PUB_KEY_BUSY' flag is set - * - * Expected behaviour: - * - bt_dh_key_gen() returns a negative error code (-EBUSY) - */ -ZTEST(bt_dh_key_gen_invalid_cases, test_bt_dev_pub_key_busy_set) -{ - int result; - const uint8_t remote_pk[BT_PUB_KEY_LEN] = {0}; - - atomic_set_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - - result = bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_cb); - - zassert_true(result == -EBUSY, "Unexpected error code '%d' was returned", result); -} - -/* - * Test DH key generation fails if the 'BT_DEV_HAS_PUB_KEY' flag isn't set - * - * Constraints: - * - 'BT_DEV_HAS_PUB_KEY' flag isn't set - * - 'BT_DEV_PUB_KEY_BUSY' flag isn't set - * - * Expected behaviour: - * - bt_dh_key_gen() returns a negative error code (-EADDRNOTAVAIL) - */ -ZTEST(bt_dh_key_gen_invalid_cases, test_device_has_no_pub_key) -{ - int result; - const uint8_t remote_pk[BT_PUB_KEY_LEN] = {0}; - - atomic_clear_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - atomic_clear_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - - result = bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_cb); - - zassert_true(result == -EADDRNOTAVAIL, "Unexpected error code '%d' was returned", result); -} - -/* - * Test DH key generation fails when hci_generate_dhkey_v1/2() fails - * - * Constraints: - * - 'BT_DEV_HAS_PUB_KEY' flag is set - * - 'BT_DEV_PUB_KEY_BUSY' flag isn't set - * - 'hci_generate_dhkey_v1/2()' fails and returns a negative error code (-ENOBUFS) - * - * Expected behaviour: - * - bt_dh_key_gen() returns a negative error code (-ENOBUFS) - */ -ZTEST(bt_dh_key_gen_invalid_cases, test_hci_generate_dhkey_vx_fails) -{ - int result; - bt_dh_key_cb_t *dh_key_cb; - const uint8_t remote_pk[BT_PUB_KEY_LEN] = {0}; - - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - atomic_clear_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - - if (IS_ENABLED(CONFIG_BT_USE_DEBUG_KEYS)) { - /* Set "ECC Debug Keys" command support bit */ - bt_dev.supported_commands[41] |= BIT(2); - } - - /* This makes hci_generate_dhkey_vx() fails and returns (-ENOBUFS) */ - bt_hci_cmd_create_fake.return_val = NULL; - - result = bt_dh_key_gen(remote_pk, bt_dh_key_unreachable_cb); - - zassert_true(result == -ENOBUFS, "Unexpected error code '%d' was returned", result); - - dh_key_cb = bt_ecc_get_dh_key_cb(); - zassert_is_null(*dh_key_cb, "Unexpected callback reference was set"); -} diff --git a/tests/bluetooth/host/ecc/bt_dh_key_gen/testcase.yaml b/tests/bluetooth/host/ecc/bt_dh_key_gen/testcase.yaml deleted file mode 100644 index aa2253d38ba066..00000000000000 --- a/tests/bluetooth/host/ecc/bt_dh_key_gen/testcase.yaml +++ /dev/null @@ -1,13 +0,0 @@ -common: - tags: - - test_framework - - bluetooth - - host -tests: - bluetooth.host.bt_dh_key_gen.default: - type: unit - bluetooth.host.bt_dh_key_gen.bt_use_debug_keys_enabled: - type: unit - extra_configs: - - CONFIG_BT_SMP=y - - CONFIG_BT_USE_DEBUG_KEYS=y diff --git a/tests/bluetooth/host/ecc/bt_pub_key_gen/CMakeLists.txt b/tests/bluetooth/host/ecc/bt_pub_key_gen/CMakeLists.txt deleted file mode 100644 index e34559da11a38e..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_gen/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) - -find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE}) - -project(bt_pub_key_gen) - -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks) -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/ecc mocks) - -target_sources(testbinary PRIVATE - src/main.c - src/test_suite_invalid_inputs.c -) -target_link_libraries(testbinary PRIVATE mocks host_mocks) diff --git a/tests/bluetooth/host/ecc/bt_pub_key_gen/prj.conf b/tests/bluetooth/host/ecc/bt_pub_key_gen/prj.conf deleted file mode 100644 index 9b9d1e2cafc40c..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_gen/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG_ZTEST=y -CONFIG_BT=y -CONFIG_BT_CENTRAL=y -CONFIG_BT_MAX_PAIRED=7 -CONFIG_ASSERT=y -CONFIG_ASSERT_LEVEL=2 -CONFIG_ASSERT_VERBOSE=y -CONFIG_ASSERT_ON_ERRORS=y diff --git a/tests/bluetooth/host/ecc/bt_pub_key_gen/src/main.c b/tests/bluetooth/host/ecc/bt_pub_key_gen/src/main.c deleted file mode 100644 index 45d4f572331369..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_gen/src/main.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "mocks/ecc_help_utils.h" -#include "mocks/hci_core.h" -#include "mocks/hci_core_expects.h" - -#include -#include -#include - -#include -#include - -DEFINE_FFF_GLOBALS; - -static void fff_reset_rule_before(const struct ztest_unit_test *test, void *fixture) -{ - sys_slist_t *pub_key_cb_slist = bt_ecc_get_pub_key_cb_slist(); - - memset(&bt_dev, 0x00, sizeof(struct bt_dev)); - sys_slist_init(pub_key_cb_slist); - - HCI_CORE_FFF_FAKES_LIST(RESET_FAKE); -} - -ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); - -ZTEST_SUITE(bt_pub_key_gen, NULL, NULL, NULL, NULL, NULL); - -static void bt_pub_key_gen_debug_key_callback(const uint8_t key[BT_PUB_KEY_LEN]) -{ - uint8_t const *internal_dbg_key = bt_ecc_get_internal_debug_public_key(); - const char *func_name = "bt_pub_key_gen_null_key_callback"; - - zassert_equal_ptr(key, internal_dbg_key, "'%s()' was called with incorrect '%s' value", - func_name, "key"); -} - -/* - * Test using the internal debug public key - * - * Constraints: - * - "LE Read Local P-256 Public Key" command is supported - * - "LE Generate DH Key" command is supported - * - "ECC Debug Keys" command is supported - * - 'CONFIG_BT_USE_DEBUG_KEYS' is enabled - * - * Expected behaviour: - * - bt_pub_key_gen() returns 0 (success) - */ -ZTEST(bt_pub_key_gen, test_using_internal_debug_public_key) -{ - int result; - bool flags_check; - struct bt_pub_key_cb new_cb = {0}; - - Z_TEST_SKIP_IFNDEF(CONFIG_BT_USE_DEBUG_KEYS); - - new_cb.func = bt_pub_key_gen_debug_key_callback; - - /* Set "LE Read Local P-256 Public Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(1); - /* Set "LE Generate DH Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(2); - /* Set "ECC Debug Keys" command support bit */ - bt_dev.supported_commands[41] |= BIT(2); - - atomic_clear_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - bt_hci_cmd_send_sync_fake.return_val = 0; - - result = bt_pub_key_gen(&new_cb); - - expect_not_called_bt_hci_cmd_send_sync(); - - zassert_ok(result, "Unexpected error code '%d' was returned", result); - - flags_check = atomic_test_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - zassert_true(flags_check, "Flags were not correctly set"); -} - -static void bt_pub_key_gen_callback(const uint8_t key[BT_PUB_KEY_LEN]) -{ - zassert_unreachable("Unexpected call to '%s()' occurred", __func__); -} - -/* - * Test generating a public key request - * - * Constraints: - * - "LE Read Local P-256 Public Key" command is supported - * - "LE Generate DH Key" command is supported - * - bt_hci_cmd_send_sync() succeeds and returns 0 - * - * Expected behaviour: - * - bt_pub_key_gen() returns 0 (success) - */ -ZTEST(bt_pub_key_gen, test_public_key_generation_request_passes) -{ - int result; - bool flags_check; - struct bt_pub_key_cb new_cb = {0}; - - new_cb.func = bt_pub_key_gen_callback; - - /* Set "LE Read Local P-256 Public Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(1); - /* Set "LE Generate DH Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(2); - - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - bt_hci_cmd_send_sync_fake.return_val = 0; - - result = bt_pub_key_gen(&new_cb); - - expect_single_call_bt_hci_cmd_send_sync(BT_HCI_OP_LE_P256_PUBLIC_KEY); - - zassert_ok(result, "Unexpected error code '%d' was returned", result); - - flags_check = atomic_test_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - zassert_false(flags_check, "Flags were not correctly set"); - - flags_check = atomic_test_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - zassert_true(flags_check, "Flags were not correctly set"); -} - -/* - * Test generating a public key request while 'BT_DEV_PUB_KEY_BUSY' flag is set - * - * Constraints: - * - "LE Read Local P-256 Public Key" command is supported - * - "LE Generate DH Key" command is supported - * - bt_hci_cmd_send_sync() isn't called - * - * Expected behaviour: - * - bt_pub_key_gen() returns 0 (success) - */ -ZTEST(bt_pub_key_gen, test_no_public_key_generation_request_duplication) -{ - int result; - bool flags_check; - struct bt_pub_key_cb new_cb = {0}; - - new_cb.func = bt_pub_key_gen_callback; - - /* Set "LE Read Local P-256 Public Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(1); - /* Set "LE Generate DH Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(2); - - atomic_set_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - - result = bt_pub_key_gen(&new_cb); - - expect_not_called_bt_hci_cmd_send_sync(); - - zassert_ok(result, "Unexpected error code '%d' was returned", result); - - flags_check = atomic_test_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - zassert_true(flags_check, "Flags were not correctly set"); -} diff --git a/tests/bluetooth/host/ecc/bt_pub_key_gen/src/test_suite_invalid_inputs.c b/tests/bluetooth/host/ecc/bt_pub_key_gen/src/test_suite_invalid_inputs.c deleted file mode 100644 index 97bc5b3020e352..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_gen/src/test_suite_invalid_inputs.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "host_mocks/assert.h" -#include "mocks/ecc_help_utils.h" -#include "mocks/hci_core.h" -#include "mocks/hci_core_expects.h" - -#include -#include - -#include -#include - -ZTEST_SUITE(bt_pub_key_gen_invalid_cases, NULL, NULL, NULL, NULL, NULL); - -/* - * Test passing NULL reference for the callback function pointer argument - * - * Constraints: - * - NULL reference is used for the callback function pointer argument - * - * Expected behaviour: - * - An assertion is raised and execution stops - */ -ZTEST(bt_pub_key_gen_invalid_cases, test_null_key_reference) -{ - expect_assert(); - bt_pub_key_gen(NULL); -} - -/* - * Test using the internal debug public key, but the callback is set to NULL - * - * Constraints: - * - "LE Read Local P-256 Public Key" command is supported - * - "LE Generate DH Key" command is supported - * - "ECC Debug Keys" command is supported - * - 'CONFIG_BT_USE_DEBUG_KEYS' is enabled - * - * Expected behaviour: - * - An assertion is raised and execution stops - */ -ZTEST(bt_pub_key_gen_invalid_cases, test_using_internal_debug_public_key) -{ - struct bt_pub_key_cb new_cb = {0}; - - Z_TEST_SKIP_IFNDEF(CONFIG_BT_USE_DEBUG_KEYS); - - expect_assert(); - new_cb.func = NULL; - - /* Set "LE Read Local P-256 Public Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(1); - /* Set "LE Generate DH Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(2); - /* Set "ECC Debug Keys" command support bit */ - bt_dev.supported_commands[41] |= BIT(2); - - bt_pub_key_gen(&new_cb); -} - -/* - * Test public key generation isn't supported if "LE Read Local P-256 Public Key" command - * isn't supported - * - * Constraints: - * - "LE Read Local P-256 Public Key" command isn't supported - * - "LE Generate DH Key" command is supported - * - * Expected behaviour: - * - bt_pub_key_gen() returns a negative error code (-ENOTSUP) - */ -ZTEST(bt_pub_key_gen_invalid_cases, test_le_read_local_p_256_pub_key_cmd_not_supported) -{ - int result; - struct bt_pub_key_cb new_cb = {0}; - - /* Clear "LE Read Local P-256 Public Key" command support bit */ - bt_dev.supported_commands[34] &= ~BIT(1); - /* Set "LE Generate DH Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(2); - - result = bt_pub_key_gen(&new_cb); - - zassert_true(result == -ENOTSUP, "Unexpected error code '%d' was returned", result); -} - -/* - * Test public key generation isn't supported if "LE Generate DH Key command isn't supported - * - * Constraints: - * - "LE Read Local P-256 Public Key" command is supported - * - "LE Generate DH Key" command isn't supported - * - * Expected behaviour: - * - bt_pub_key_gen() returns a negative error code (-ENOTSUP) - */ -ZTEST(bt_pub_key_gen_invalid_cases, test_le_generate_dh_key_cmd_not_supported) -{ - int result; - struct bt_pub_key_cb new_cb = {0}; - - /* Set "LE Read Local P-256 Public Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(1); - /* Clear "LE Generate DH Key" command support bit */ - bt_dev.supported_commands[34] &= ~BIT(2); - - result = bt_pub_key_gen(&new_cb); - - zassert_true(result == -ENOTSUP, "Unexpected error code '%d' was returned", result); -} - -/* - * Test public key generation fails if the callback is already registered - * - * Constraints: - * - "LE Read Local P-256 Public Key" command is supported - * - "LE Generate DH Key" command is supported - * - Callback passed is already registered - * - * Expected behaviour: - * - bt_pub_key_gen() returns a negative error code (-EALREADY) - */ -ZTEST(bt_pub_key_gen_invalid_cases, test_callback_already_registered) -{ - int result; - struct bt_pub_key_cb new_cb = {0}; - - /* Set "LE Read Local P-256 Public Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(1); - /* Set "LE Generate DH Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(2); - - bt_pub_key_gen(&new_cb); - result = bt_pub_key_gen(&new_cb); - - zassert_true(result == -EALREADY, "Unexpected error code '%d' was returned", result); -} - -static void bt_pub_key_gen_null_key_callback(const uint8_t key[BT_PUB_KEY_LEN]) -{ - const char *func_name = "bt_pub_key_gen_null_key_callback"; - - zassert_is_null(key, "'%s()' was called with incorrect '%s' value", func_name, "key"); -} - -/* - * Test public key generation fails when reading public key fails - * - * Constraints: - * - "LE Read Local P-256 Public Key" command is supported - * - "LE Generate DH Key" command is supported - * - bt_hci_cmd_send_sync() fails and returns a negative error code - * - * Expected behaviour: - * - bt_pub_key_gen() returns a negative error code - */ -ZTEST(bt_pub_key_gen_invalid_cases, test_reading_le_read_local_p_256_pub_key_fails) -{ - int result; - bool flags_check; - struct bt_pub_key_cb new_cb = {0}; - sys_slist_t *pub_key_cb_slist = bt_ecc_get_pub_key_cb_slist(); - - new_cb.func = bt_pub_key_gen_null_key_callback; - - /* Set "LE Read Local P-256 Public Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(1); - /* Set "LE Generate DH Key" command support bit */ - bt_dev.supported_commands[34] |= BIT(2); - - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - bt_hci_cmd_send_sync_fake.return_val = -1; - - result = bt_pub_key_gen(&new_cb); - - expect_single_call_bt_hci_cmd_send_sync(BT_HCI_OP_LE_P256_PUBLIC_KEY); - - zassert_true(result < 0, "Unexpected error code '%d' was returned", result); - - flags_check = atomic_test_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - zassert_false(flags_check, "Flags were not correctly set"); - - flags_check = atomic_test_bit(bt_dev.flags, BT_DEV_PUB_KEY_BUSY); - zassert_false(flags_check, "Flags were not correctly set"); - - zassert_is_null(pub_key_cb_slist->head, "Incorrect value was set to list head"); - zassert_is_null(pub_key_cb_slist->tail, "Incorrect value was set to list tail"); -} diff --git a/tests/bluetooth/host/ecc/bt_pub_key_gen/testcase.yaml b/tests/bluetooth/host/ecc/bt_pub_key_gen/testcase.yaml deleted file mode 100644 index a6b39863ddfbf8..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_gen/testcase.yaml +++ /dev/null @@ -1,13 +0,0 @@ -common: - tags: - - test_framework - - bluetooth - - host -tests: - bluetooth.host.bt_pub_key_gen.default: - type: unit - bluetooth.host.bt_pub_key_gen.bt_use_debug_keys_enabled: - type: unit - extra_configs: - - CONFIG_BT_SMP=y - - CONFIG_BT_USE_DEBUG_KEYS=y diff --git a/tests/bluetooth/host/ecc/bt_pub_key_get/CMakeLists.txt b/tests/bluetooth/host/ecc/bt_pub_key_get/CMakeLists.txt deleted file mode 100644 index a8461a1056e0d6..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_get/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) - -find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE}) - -project(bt_pub_key_get) - -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks) -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/ecc mocks) - -target_sources(testbinary PRIVATE - src/main.c - src/test_suite_invalid_inputs.c -) -target_link_libraries(testbinary PRIVATE mocks host_mocks) diff --git a/tests/bluetooth/host/ecc/bt_pub_key_get/prj.conf b/tests/bluetooth/host/ecc/bt_pub_key_get/prj.conf deleted file mode 100644 index 9b9d1e2cafc40c..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_get/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG_ZTEST=y -CONFIG_BT=y -CONFIG_BT_CENTRAL=y -CONFIG_BT_MAX_PAIRED=7 -CONFIG_ASSERT=y -CONFIG_ASSERT_LEVEL=2 -CONFIG_ASSERT_VERBOSE=y -CONFIG_ASSERT_ON_ERRORS=y diff --git a/tests/bluetooth/host/ecc/bt_pub_key_get/src/main.c b/tests/bluetooth/host/ecc/bt_pub_key_get/src/main.c deleted file mode 100644 index 9ba0d051ef8d03..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_get/src/main.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "mocks/ecc_help_utils.h" - -#include -#include -#include - -#include -#include - -DEFINE_FFF_GLOBALS; - -static void fff_reset_rule_before(const struct ztest_unit_test *test, void *fixture) -{ - memset(&bt_dev, 0x00, sizeof(struct bt_dev)); -} - -ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); - -ZTEST_SUITE(bt_pub_key_get, NULL, NULL, NULL, NULL, NULL); - -/* - * Test getting currently used public key if 'BT_DEV_HAS_PUB_KEY' is set and - * 'CONFIG_BT_USE_DEBUG_KEYS' isn't enabled - * - * Constraints: - * - 'BT_DEV_HAS_PUB_KEY' flag is set - * - 'CONFIG_BT_USE_DEBUG_KEYS' isn't enabled - * - * Expected behaviour: - * - A valid reference value is returned - */ -ZTEST(bt_pub_key_get, test_bt_dev_has_pub_key_set) -{ - const uint8_t *pub_key; - - Z_TEST_SKIP_IFDEF(CONFIG_BT_USE_DEBUG_KEYS); - - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - - pub_key = bt_pub_key_get(); - - zassert_equal(pub_key, bt_ecc_get_public_key(), "Incorrect reference was returned"); -} - -/* - * Test getting currently used debug public key if 'CONFIG_BT_USE_DEBUG_KEYS' is enabled and - * "ECC Debug Keys" command is supported - * - * Constraints: - * - 'CONFIG_BT_USE_DEBUG_KEYS' is enabled - * - "ECC Debug Keys" command is supported - * - 'BT_DEV_HAS_PUB_KEY' flag is set (just for testing and it shouldn't affect the result) - * - * Expected behaviour: - * - A valid reference value is returned - */ -ZTEST(bt_pub_key_get, test_get_debug_pub_key1) -{ - const uint8_t *pub_key; - - Z_TEST_SKIP_IFNDEF(CONFIG_BT_USE_DEBUG_KEYS); - - /* Set "ECC Debug Keys" command support bit */ - bt_dev.supported_commands[41] |= BIT(2); - atomic_set_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - - pub_key = bt_pub_key_get(); - - zassert_equal(pub_key, bt_ecc_get_internal_debug_public_key(), - "Incorrect reference was returned"); -} diff --git a/tests/bluetooth/host/ecc/bt_pub_key_get/src/test_suite_invalid_inputs.c b/tests/bluetooth/host/ecc/bt_pub_key_get/src/test_suite_invalid_inputs.c deleted file mode 100644 index 5e53460b6c2c90..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_get/src/test_suite_invalid_inputs.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include - -#include -#include - -ZTEST_SUITE(bt_pub_key_get_invalid_cases, NULL, NULL, NULL, NULL, NULL); - -/* - * Test getting currently used public key if 'BT_DEV_HAS_PUB_KEY' isn't set and - * 'CONFIG_BT_USE_DEBUG_KEYS' isn't enabled - * - * Constraints: - * - 'BT_DEV_HAS_PUB_KEY' flag isn't set - * - 'CONFIG_BT_USE_DEBUG_KEYS' isn't enabled - * - * Expected behaviour: - * - NULL value is returned - */ -ZTEST(bt_pub_key_get_invalid_cases, test_bt_dev_has_pub_key_not_set) -{ - const uint8_t *pub_key; - - Z_TEST_SKIP_IFDEF(CONFIG_BT_USE_DEBUG_KEYS); - - atomic_clear_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - - pub_key = bt_pub_key_get(); - - zassert_is_null(pub_key, "Incorrect reference was returned"); -} - -/* - * Test getting currently used debug public key if 'CONFIG_BT_USE_DEBUG_KEYS' is enabled, but - * "ECC Debug Keys" command isn't supported - * - * Constraints: - * - 'CONFIG_BT_USE_DEBUG_KEYS' is enabled - * - "ECC Debug Keys" command isn't supported - * - 'BT_DEV_HAS_PUB_KEY' flag isn't set - * - * Expected behaviour: - * - NULL value is returned - */ -ZTEST(bt_pub_key_get_invalid_cases, test_get_debug_pub_key) -{ - const uint8_t *pub_key; - - Z_TEST_SKIP_IFNDEF(CONFIG_BT_USE_DEBUG_KEYS); - - /* Clear "ECC Debug Keys" command support bit */ - bt_dev.supported_commands[41] &= ~BIT(2); - atomic_clear_bit(bt_dev.flags, BT_DEV_HAS_PUB_KEY); - - pub_key = bt_pub_key_get(); - - zassert_is_null(pub_key, "Incorrect reference was returned"); -} diff --git a/tests/bluetooth/host/ecc/bt_pub_key_get/testcase.yaml b/tests/bluetooth/host/ecc/bt_pub_key_get/testcase.yaml deleted file mode 100644 index a9234c93b69137..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_get/testcase.yaml +++ /dev/null @@ -1,13 +0,0 @@ -common: - tags: - - test_framework - - bluetooth - - host -tests: - bluetooth.host.bt_pub_key_get.default: - type: unit - bluetooth.host.bt_pub_key_get.bt_use_debug_keys_enabled: - type: unit - extra_configs: - - CONFIG_BT_SMP=y - - CONFIG_BT_USE_DEBUG_KEYS=y diff --git a/tests/bluetooth/host/ecc/bt_pub_key_is_debug/CMakeLists.txt b/tests/bluetooth/host/ecc/bt_pub_key_is_debug/CMakeLists.txt deleted file mode 100644 index 1e8c9dafe66c75..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_is_debug/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) - -find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE}) - -project(bt_pub_key_is_debug) - -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks) -add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/ecc mocks) - -target_sources(testbinary PRIVATE src/main.c) -target_link_libraries(testbinary PRIVATE mocks host_mocks) diff --git a/tests/bluetooth/host/ecc/bt_pub_key_is_debug/prj.conf b/tests/bluetooth/host/ecc/bt_pub_key_is_debug/prj.conf deleted file mode 100644 index 9b9d1e2cafc40c..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_is_debug/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG_ZTEST=y -CONFIG_BT=y -CONFIG_BT_CENTRAL=y -CONFIG_BT_MAX_PAIRED=7 -CONFIG_ASSERT=y -CONFIG_ASSERT_LEVEL=2 -CONFIG_ASSERT_VERBOSE=y -CONFIG_ASSERT_ON_ERRORS=y diff --git a/tests/bluetooth/host/ecc/bt_pub_key_is_debug/src/main.c b/tests/bluetooth/host/ecc/bt_pub_key_is_debug/src/main.c deleted file mode 100644 index 6de7b459970092..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_is_debug/src/main.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "mocks/ecc_help_utils.h" - -#include -#include - -#include - -DEFINE_FFF_GLOBALS; - -ZTEST_SUITE(bt_pub_key_is_debug, NULL, NULL, NULL, NULL, NULL); - -/* - * Test bt_pub_key_is_debug() returns 'true' if key passed matches the internal debug key - * - * Constraints: - * - The key passed matches the internal debug key - * - * Expected behaviour: - * - bt_pub_key_is_debug() returns 'true' - */ -ZTEST(bt_pub_key_is_debug, test_key_matches_internal_key) -{ - bool result; - uint8_t const *internal_dbg_public_key = bt_ecc_get_internal_debug_public_key(); - uint8_t testing_public_key[BT_PUB_KEY_LEN] = {0}; - - memcpy(testing_public_key, internal_dbg_public_key, BT_PUB_KEY_LEN); - - result = bt_pub_key_is_debug(testing_public_key); - - zassert_true(result, "Unexpected error code '%d' was returned", result); -} - -/* - * Test bt_pub_key_is_debug() returns 'false' if key passed doesn't match the internal debug key - * - * Constraints: - * - The key passed doesn't match the internal debug key - * - * Expected behaviour: - * - bt_pub_key_is_debug() returns 'false' - */ -ZTEST(bt_pub_key_is_debug, test_key_mismatches_internal_key) -{ - bool result; - uint8_t testing_public_key[BT_PUB_KEY_LEN] = {0}; - - result = bt_pub_key_is_debug(testing_public_key); - - zassert_false(result, "Unexpected error code '%d' was returned", result); -} diff --git a/tests/bluetooth/host/ecc/bt_pub_key_is_debug/testcase.yaml b/tests/bluetooth/host/ecc/bt_pub_key_is_debug/testcase.yaml deleted file mode 100644 index 633ae6a0ffeea7..00000000000000 --- a/tests/bluetooth/host/ecc/bt_pub_key_is_debug/testcase.yaml +++ /dev/null @@ -1,8 +0,0 @@ -common: - tags: - - test_framework - - bluetooth - - host -tests: - bluetooth.host.bt_pub_key_is_debug.default: - type: unit diff --git a/tests/bluetooth/host/ecc/mocks/ecc_help_utils.c b/tests/bluetooth/host/ecc/mocks/ecc_help_utils.c deleted file mode 100644 index daff4dd7173dcd..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/ecc_help_utils.c +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "ecc_help_utils.h" - -#include - -#include diff --git a/tests/bluetooth/host/ecc/mocks/ecc_help_utils.h b/tests/bluetooth/host/ecc/mocks/ecc_help_utils.h deleted file mode 100644 index 2d7ba49e737b94..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/ecc_help_utils.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -typedef void (*bt_dh_key_cb_t)(const uint8_t *key); - -/* ecc.c declarations */ -uint8_t const *bt_ecc_get_public_key(void); -uint8_t const *bt_ecc_get_internal_debug_public_key(void); -sys_slist_t *bt_ecc_get_pub_key_cb_slist(void); -bt_dh_key_cb_t *bt_ecc_get_dh_key_cb(void); diff --git a/tests/bluetooth/host/ecc/mocks/hci_core.c b/tests/bluetooth/host/ecc/mocks/hci_core.c deleted file mode 100644 index 4deee11a4960ad..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/hci_core.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "mocks/hci_core.h" - -#include -#include - -#include - -struct bt_dev bt_dev = { - .manufacturer = 0x1234, -}; - -DEFINE_FAKE_VALUE_FUNC(struct net_buf *, bt_hci_cmd_create, uint16_t, uint8_t); -DEFINE_FAKE_VALUE_FUNC(int, bt_hci_cmd_send_sync, uint16_t, struct net_buf *, struct net_buf **); diff --git a/tests/bluetooth/host/ecc/mocks/hci_core.h b/tests/bluetooth/host/ecc/mocks/hci_core.h deleted file mode 100644 index fd78465062c9eb..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/hci_core.h +++ /dev/null @@ -1,16 +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 HCI_CORE_FFF_FAKES_LIST(FAKE) \ - FAKE(bt_hci_cmd_create) \ - FAKE(bt_hci_cmd_send_sync) - -DECLARE_FAKE_VALUE_FUNC(struct net_buf *, bt_hci_cmd_create, uint16_t, uint8_t); -DECLARE_FAKE_VALUE_FUNC(int, bt_hci_cmd_send_sync, uint16_t, struct net_buf *, struct net_buf **); diff --git a/tests/bluetooth/host/ecc/mocks/hci_core_expects.c b/tests/bluetooth/host/ecc/mocks/hci_core_expects.c deleted file mode 100644 index d2d07bab6563a1..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/hci_core_expects.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "mocks/hci_core.h" -#include "mocks/hci_core_expects.h" - -#include -#include - -void expect_single_call_bt_hci_cmd_create(uint16_t opcode, uint8_t param_len) -{ - const char *func_name = "bt_hci_cmd_create"; - - zassert_equal(bt_hci_cmd_create_fake.call_count, 1, "'%s()' was called more than once", - func_name); - - zassert_equal(bt_hci_cmd_create_fake.arg0_val, opcode, - "'%s()' was called with incorrect '%s' value", func_name, "opcode"); - zassert_equal(bt_hci_cmd_create_fake.arg1_val, param_len, - "'%s()' was called with incorrect '%s' value", func_name, "param_len"); -} - -void expect_not_called_bt_hci_cmd_create(void) -{ - const char *func_name = "bt_hci_cmd_create"; - - zassert_equal(bt_hci_cmd_create_fake.call_count, 0, "'%s()' was called unexpectedly", - func_name); -} - -void expect_single_call_bt_hci_cmd_send_sync(uint16_t opcode) -{ - const char *func_name = "bt_hci_cmd_send_sync"; - - zassert_equal(bt_hci_cmd_send_sync_fake.call_count, 1, "'%s()' was called more than once", - func_name); - - zassert_equal(bt_hci_cmd_send_sync_fake.arg0_val, opcode, - "'%s()' was called with incorrect '%s' value", func_name, "opcode"); -} - -void expect_not_called_bt_hci_cmd_send_sync(void) -{ - const char *func_name = "bt_hci_cmd_send_sync"; - - zassert_equal(bt_hci_cmd_send_sync_fake.call_count, 0, "'%s()' was called unexpectedly", - func_name); -} diff --git a/tests/bluetooth/host/ecc/mocks/hci_core_expects.h b/tests/bluetooth/host/ecc/mocks/hci_core_expects.h deleted file mode 100644 index 08dc8c7af04c4c..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/hci_core_expects.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -/* - * Validate expected behaviour when bt_hci_cmd_create() is called - * - * Expected behaviour: - * - bt_hci_cmd_create() to be called once with correct parameters - */ -void expect_single_call_bt_hci_cmd_create(uint16_t opcode, uint8_t param_len); - -/* - * Validate expected behaviour when bt_hci_cmd_create() isn't called - * - * Expected behaviour: - * - bt_hci_cmd_create() isn't called at all - */ -void expect_not_called_bt_hci_cmd_create(void); - -/* - * Validate expected behaviour when bt_hci_cmd_send_sync() is called - * - * Expected behaviour: - * - bt_hci_cmd_send_sync() to be called once with correct parameters - */ -void expect_single_call_bt_hci_cmd_send_sync(uint16_t opcode); - -/* - * Validate expected behaviour when bt_hci_cmd_send_sync() isn't called - * - * Expected behaviour: - * - bt_hci_cmd_send_sync() isn't called at all - */ -void expect_not_called_bt_hci_cmd_send_sync(void); diff --git a/tests/bluetooth/host/ecc/mocks/net_buf.c b/tests/bluetooth/host/ecc/mocks/net_buf.c deleted file mode 100644 index 5a64ac1459aa18..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/net_buf.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -#include - -DEFINE_FAKE_VALUE_FUNC(void *, net_buf_simple_add, struct net_buf_simple *, size_t); diff --git a/tests/bluetooth/host/ecc/mocks/net_buf.h b/tests/bluetooth/host/ecc/mocks/net_buf.h deleted file mode 100644 index bcf78fa83aa095..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/net_buf.h +++ /dev/null @@ -1,13 +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_simple_add) - -DECLARE_FAKE_VALUE_FUNC(void *, net_buf_simple_add, struct net_buf_simple *, size_t); diff --git a/tests/bluetooth/host/ecc/mocks/net_buf_expects.c b/tests/bluetooth/host/ecc/mocks/net_buf_expects.c deleted file mode 100644 index 2e9ee3484adf27..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/net_buf_expects.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "mocks/net_buf.h" -#include "mocks/net_buf_expects.h" - -#include -#include - -void expect_single_call_net_buf_simple_add(struct net_buf_simple *buf, size_t len) -{ - const char *func_name = "net_buf_simple_add"; - - zassert_equal(net_buf_simple_add_fake.call_count, 1, "'%s()' was called more than once", - func_name); - - zassert_equal(net_buf_simple_add_fake.arg0_val, buf, - "'%s()' was called with incorrect '%s' value", func_name, "buf"); - zassert_equal(net_buf_simple_add_fake.arg1_val, len, - "'%s()' was called with incorrect '%s' value", func_name, "len"); -} - -void expect_not_called_net_buf_simple_add(void) -{ - const char *func_name = "net_buf_simple_add"; - - zassert_equal(net_buf_simple_add_fake.call_count, 0, "'%s()' was called unexpectedly", - func_name); -} diff --git a/tests/bluetooth/host/ecc/mocks/net_buf_expects.h b/tests/bluetooth/host/ecc/mocks/net_buf_expects.h deleted file mode 100644 index a6b76220f17925..00000000000000 --- a/tests/bluetooth/host/ecc/mocks/net_buf_expects.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -/* - * Validate expected behaviour when net_buf_simple_add() is called - * - * Expected behaviour: - * - net_buf_simple_add() to be called once with correct parameters - */ -void expect_single_call_net_buf_simple_add(struct net_buf_simple *buf, size_t len); - -/* - * Validate expected behaviour when net_buf_simple_add() isn't called - * - * Expected behaviour: - * - net_buf_simple_add() isn't called at all - */ -void expect_not_called_net_buf_simple_add(void); diff --git a/tests/bluetooth/host/ecc/testing_common_defs.h b/tests/bluetooth/host/ecc/testing_common_defs.h deleted file mode 100644 index 5407ea3e2e8c49..00000000000000 --- a/tests/bluetooth/host/ecc/testing_common_defs.h +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */