From 72e78516a35eef4618df7fdee827d47c85ab8a05 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Tue, 4 Jun 2024 16:57:32 +0200 Subject: [PATCH] tests: Bluetooth: Audio: Move role specific mocks files For the LE Audio unittests there exists a few mock files that implement mock versions, or callbacks, for some of the roles and features tested. These have been moved to where they are actually used, reducing the scope of these files. This both allows the individual tests to implement their own versions of it, but more importantly it prevents issues when adding tests for these roles. For example, due to the bap_unicast_client.c mock file, it is impossible to implement unit tests for the unicast client, as the functions are already defined. Signed-off-by: Emil Gydesen --- .../include/bap_unicast_server.h | 0 .../include/bap_unicast_server_expects.h | 0 tests/bluetooth/audio/ascs/uut/CMakeLists.txt | 3 + .../src => ascs/uut}/bap_unicast_client.c | 0 .../src => ascs/uut}/bap_unicast_server.c | 0 .../include/cap_commander.h | 0 .../audio/cap_commander/uut/CMakeLists.txt | 2 + .../src => cap_commander/uut}/cap_commander.c | 0 .../include/cap_initiator.h | 0 .../audio/cap_initiator/uut/CMakeLists.txt | 3 + .../cap_initiator/uut/bap_unicast_client.c | 69 +++++++++++++++++++ .../src => cap_initiator/uut}/cap_initiator.c | 0 tests/bluetooth/audio/mocks/CMakeLists.txt | 4 -- 13 files changed, 77 insertions(+), 4 deletions(-) rename tests/bluetooth/audio/{mocks => ascs}/include/bap_unicast_server.h (100%) rename tests/bluetooth/audio/{mocks => ascs}/include/bap_unicast_server_expects.h (100%) rename tests/bluetooth/audio/{mocks/src => ascs/uut}/bap_unicast_client.c (100%) rename tests/bluetooth/audio/{mocks/src => ascs/uut}/bap_unicast_server.c (100%) rename tests/bluetooth/audio/{mocks => cap_commander}/include/cap_commander.h (100%) rename tests/bluetooth/audio/{mocks/src => cap_commander/uut}/cap_commander.c (100%) rename tests/bluetooth/audio/{mocks => cap_initiator}/include/cap_initiator.h (100%) create mode 100644 tests/bluetooth/audio/cap_initiator/uut/bap_unicast_client.c rename tests/bluetooth/audio/{mocks/src => cap_initiator/uut}/cap_initiator.c (100%) diff --git a/tests/bluetooth/audio/mocks/include/bap_unicast_server.h b/tests/bluetooth/audio/ascs/include/bap_unicast_server.h similarity index 100% rename from tests/bluetooth/audio/mocks/include/bap_unicast_server.h rename to tests/bluetooth/audio/ascs/include/bap_unicast_server.h diff --git a/tests/bluetooth/audio/mocks/include/bap_unicast_server_expects.h b/tests/bluetooth/audio/ascs/include/bap_unicast_server_expects.h similarity index 100% rename from tests/bluetooth/audio/mocks/include/bap_unicast_server_expects.h rename to tests/bluetooth/audio/ascs/include/bap_unicast_server_expects.h diff --git a/tests/bluetooth/audio/ascs/uut/CMakeLists.txt b/tests/bluetooth/audio/ascs/uut/CMakeLists.txt index ad4aba9a501a9..8153d0f9372b4 100644 --- a/tests/bluetooth/audio/ascs/uut/CMakeLists.txt +++ b/tests/bluetooth/audio/ascs/uut/CMakeLists.txt @@ -17,10 +17,13 @@ add_library(uut STATIC ${ZEPHYR_BASE}/subsys/bluetooth/host/uuid.c ${ZEPHYR_BASE}/subsys/logging/log_minimal.c ${ZEPHYR_BASE}/subsys/net/buf_simple.c + bap_unicast_client.c + bap_unicast_server.c ) add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/audio/mocks mocks) target_link_libraries(uut PUBLIC test_interface mocks) +target_include_directories(uut PRIVATE ${ZEPHYR_BASE}/tests/bluetooth/audio/ascs/include) target_compile_options(uut PRIVATE -std=c11 -include ztest.h) diff --git a/tests/bluetooth/audio/mocks/src/bap_unicast_client.c b/tests/bluetooth/audio/ascs/uut/bap_unicast_client.c similarity index 100% rename from tests/bluetooth/audio/mocks/src/bap_unicast_client.c rename to tests/bluetooth/audio/ascs/uut/bap_unicast_client.c diff --git a/tests/bluetooth/audio/mocks/src/bap_unicast_server.c b/tests/bluetooth/audio/ascs/uut/bap_unicast_server.c similarity index 100% rename from tests/bluetooth/audio/mocks/src/bap_unicast_server.c rename to tests/bluetooth/audio/ascs/uut/bap_unicast_server.c diff --git a/tests/bluetooth/audio/mocks/include/cap_commander.h b/tests/bluetooth/audio/cap_commander/include/cap_commander.h similarity index 100% rename from tests/bluetooth/audio/mocks/include/cap_commander.h rename to tests/bluetooth/audio/cap_commander/include/cap_commander.h diff --git a/tests/bluetooth/audio/cap_commander/uut/CMakeLists.txt b/tests/bluetooth/audio/cap_commander/uut/CMakeLists.txt index 007ea55fb9b9d..80508263d6a3e 100644 --- a/tests/bluetooth/audio/cap_commander/uut/CMakeLists.txt +++ b/tests/bluetooth/audio/cap_commander/uut/CMakeLists.txt @@ -16,6 +16,7 @@ add_library(uut STATIC ${ZEPHYR_BASE}/subsys/net/buf_simple.c bap_broadcast_assistant.c aics.c + cap_commander.c csip.c micp.c vcp.c @@ -25,5 +26,6 @@ add_library(uut STATIC add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/audio/mocks mocks) target_link_libraries(uut PUBLIC test_interface mocks) +target_include_directories(uut PRIVATE ${ZEPHYR_BASE}/tests/bluetooth/audio/cap_commander/include) target_compile_options(uut PRIVATE -std=c11 -include ztest.h) diff --git a/tests/bluetooth/audio/mocks/src/cap_commander.c b/tests/bluetooth/audio/cap_commander/uut/cap_commander.c similarity index 100% rename from tests/bluetooth/audio/mocks/src/cap_commander.c rename to tests/bluetooth/audio/cap_commander/uut/cap_commander.c diff --git a/tests/bluetooth/audio/mocks/include/cap_initiator.h b/tests/bluetooth/audio/cap_initiator/include/cap_initiator.h similarity index 100% rename from tests/bluetooth/audio/mocks/include/cap_initiator.h rename to tests/bluetooth/audio/cap_initiator/include/cap_initiator.h diff --git a/tests/bluetooth/audio/cap_initiator/uut/CMakeLists.txt b/tests/bluetooth/audio/cap_initiator/uut/CMakeLists.txt index 099daf5fc8093..41249c6b89aae 100644 --- a/tests/bluetooth/audio/cap_initiator/uut/CMakeLists.txt +++ b/tests/bluetooth/audio/cap_initiator/uut/CMakeLists.txt @@ -16,11 +16,14 @@ add_library(uut STATIC ${ZEPHYR_BASE}/subsys/bluetooth/common/bt_str.c ${ZEPHYR_BASE}/subsys/logging/log_minimal.c ${ZEPHYR_BASE}/subsys/net/buf_simple.c + bap_unicast_client.c + cap_initiator.c csip.c ) add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/audio/mocks mocks) target_link_libraries(uut PUBLIC test_interface mocks) +target_include_directories(uut PRIVATE ${ZEPHYR_BASE}/tests/bluetooth/audio/cap_initiator/include) target_compile_options(uut PRIVATE -std=c11 -include ztest.h) diff --git a/tests/bluetooth/audio/cap_initiator/uut/bap_unicast_client.c b/tests/bluetooth/audio/cap_initiator/uut/bap_unicast_client.c new file mode 100644 index 0000000000000..ef9ac1328b80e --- /dev/null +++ b/tests/bluetooth/audio/cap_initiator/uut/bap_unicast_client.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Codecoup + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +bool bt_bap_ep_is_unicast_client(const struct bt_bap_ep *ep) +{ + return false; +} + +int bt_bap_unicast_client_config(struct bt_bap_stream *stream, + const struct bt_audio_codec_cfg *codec_cfg) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} + +int bt_bap_unicast_client_qos(struct bt_conn *conn, struct bt_bap_unicast_group *group) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} + +int bt_bap_unicast_client_enable(struct bt_bap_stream *stream, uint8_t meta[], + size_t meta_len) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} + +int bt_bap_unicast_client_metadata(struct bt_bap_stream *stream, uint8_t meta[], + size_t meta_len) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} + +int bt_bap_unicast_client_disable(struct bt_bap_stream *stream) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} + +int bt_bap_unicast_client_connect(struct bt_bap_stream *stream) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} + +int bt_bap_unicast_client_start(struct bt_bap_stream *stream) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} + +int bt_bap_unicast_client_stop(struct bt_bap_stream *stream) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} + +int bt_bap_unicast_client_release(struct bt_bap_stream *stream) +{ + zassert_unreachable("Unexpected call to '%s()' occurred", __func__); + return 0; +} diff --git a/tests/bluetooth/audio/mocks/src/cap_initiator.c b/tests/bluetooth/audio/cap_initiator/uut/cap_initiator.c similarity index 100% rename from tests/bluetooth/audio/mocks/src/cap_initiator.c rename to tests/bluetooth/audio/cap_initiator/uut/cap_initiator.c diff --git a/tests/bluetooth/audio/mocks/CMakeLists.txt b/tests/bluetooth/audio/mocks/CMakeLists.txt index bd46f4d373cc8..ead819b901abc 100644 --- a/tests/bluetooth/audio/mocks/CMakeLists.txt +++ b/tests/bluetooth/audio/mocks/CMakeLists.txt @@ -8,10 +8,6 @@ add_library(mocks STATIC src/bap_stream.c - src/bap_unicast_client.c - src/bap_unicast_server.c - src/cap_commander.c - src/cap_initiator.c src/conn.c src/crypto.c src/fatal.c