test: update how unit tests set sources

Replaces cases of setting SOURCES before calling find_package with
proper target_sources.

Signed-off-by: Yuval Peress <peress@google.com>
This commit is contained in:
Yuval Peress 2022-10-17 22:15:21 -06:00 committed by Carles Cufí
parent ffb861d1a3
commit f460c21578
39 changed files with 205 additions and 136 deletions

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_api)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ctrl_ull_conn)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.13.1)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_cis_create)
find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.13.1)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_cis_terminate)
find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,12 +2,14 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_collision)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ctrl_ull_conn)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -5,12 +5,14 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_le_cte_req)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)
set(CMAKE_BUILD_TYPE Debug)

View file

@ -2,9 +2,6 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
if(CONFIG_BT_CTLR_PHY_CODED)
add_compile_definitions(CONFIG_BT_CTLR_PHY_CODED)
endif(CONFIG_BT_CTLR_PHY_CODED)
@ -19,4 +16,10 @@ include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
if(NOT CONFIG_BT_CTLR_PHY)
list(REMOVE_ITEM ll_sw_sources ${ZEPHYR_BASE}/subsys/bluetooth/controller/ll_sw/ull_llcp_phy.c)
endif()
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_encrypt)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,14 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_feature_exchange)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
src/main_hci.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_feature_exchange)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,12 +2,14 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_invalid)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_le_ping)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_min_used_chans)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_phy_update)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_terminate)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,9 +2,6 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
if(CONFIG_BT_CTLR_LLCP_PER_CONN_TX_CTRL_BUF_NUM GREATER_EQUAL 0)
add_compile_definitions(CONFIG_BT_CTLR_LLCP_PER_CONN_TX_CTRL_BUF_NUM=${CONFIG_BT_CTLR_LLCP_PER_CONN_TX_CTRL_BUF_NUM})
endif(CONFIG_BT_CTLR_LLCP_PER_CONN_TX_CTRL_BUF_NUM)
@ -12,4 +9,10 @@ endif(CONFIG_BT_CTLR_LLCP_PER_CONN_TX_CTRL_BUF_NUM)
project(bluetooth_ull_llcp_tx_buffer_alloc)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_tx_queue)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,10 +2,6 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
# Propagate NO_ENC to compile
if(NO_ENC)
add_compile_definitions(NO_ENC)
@ -40,4 +36,10 @@ if(NO_PHY)
list(REMOVE_ITEM ll_sw_sources ${ZEPHYR_BASE}/subsys/bluetooth/controller/ll_sw/ull_llcp_phy.c)
endif()
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,11 +2,13 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES
src/*.c
)
project(bluetooth_ull_llcp_version)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
include(${ZEPHYR_BASE}/tests/bluetooth/controller/common/defaults_cmake.txt)
target_sources(testbinary PRIVATE ${ll_sw_sources} ${mock_sources} ${common_sources})
target_sources(testbinary
PRIVATE
src/main.c
${ll_sw_sources}
${mock_sources}
${common_sources}
)

View file

@ -2,8 +2,6 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES src/*.c)
project(bluetooth_bt_buf_get_cmd_complete)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
@ -12,3 +10,7 @@ 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
)

View file

@ -2,8 +2,6 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES src/*.c)
project(bluetooth_bt_buf_get_evt)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
@ -12,3 +10,9 @@ 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
)

View file

@ -2,8 +2,6 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES src/*.c)
project(bluetooth_bt_buf_get_rx)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
@ -12,3 +10,8 @@ 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
)

View file

@ -2,8 +2,6 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES src/*.c)
project(bluetooth_bt_buf_get_type)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
@ -12,3 +10,7 @@ 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
)

View file

@ -2,12 +2,15 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES src/*.c)
project(bt_keys_foreach_bond)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/keys mocks)
target_sources(testbinary
PRIVATE
src/main.c
src/test_suite_foreach_bond_invalid_inputs.c
)
target_link_libraries(testbinary PRIVATE mocks host_mocks)

View file

@ -2,8 +2,6 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES src/*.c)
project(bt_keys_foreach_type)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
@ -11,3 +9,8 @@ add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/keys mocks)
target_link_libraries(testbinary PRIVATE mocks host_mocks)
target_sources(testbinary
PRIVATE
src/main.c
src/test_suite_foreach_type_invalid_inputs.c
)

View file

@ -2,12 +2,17 @@
cmake_minimum_required(VERSION 3.20.0)
FILE(GLOB SOURCES src/*.c)
project(bt_keys_get_addr)
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
project(bt_keys_get_addr)
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/keys mocks)
target_link_libraries(testbinary PRIVATE mocks host_mocks)
target_sources(testbinary
PRIVATE
src/main.c
src/test_suite_full_list_invalid_values.c
src/test_suite_full_list_no_overwrite.c
src/test_suite_full_list_overwrite_oldest.c
)

View file

@ -3,5 +3,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(base64)
set(SOURCES main.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c)

View file

@ -3,5 +3,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(lib_os_cbprintf)
set(SOURCES main.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c)

View file

@ -3,5 +3,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(crc)
set(SOURCES main.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c)

View file

@ -3,7 +3,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(base64)
set(SOURCES
main.c
)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c)

View file

@ -3,10 +3,11 @@
cmake_minimum_required(VERSION 3.20.0)
project(list)
set(SOURCES
main.c
slist.c
dlist.c
sflist.c
)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary
PRIVATE
main.c
slist.c
dlist.c
sflist.c
)

View file

@ -3,5 +3,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(math_extras)
set(SOURCES main.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c)

View file

@ -3,5 +3,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(lib_net_timeout)
set(SOURCES main.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c)

View file

@ -3,5 +3,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(rbtree)
set(SOURCES main.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c)

View file

@ -4,5 +4,12 @@
cmake_minimum_required(VERSION 3.20.0)
project(timeutil)
set(SOURCES main.c test_gmtime.c test_s32.c test_s64.c test_sync.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary
PRIVATE
main.c
test_gmtime.c
test_s32.c
test_s64.c
test_sync.c
)

View file

@ -3,5 +3,5 @@
cmake_minimum_required(VERSION 3.20.0)
project(util)
set(SOURCES main.c maincxx.cxx ../../../lib/os/dec.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c maincxx.cxx ${ZEPHYR_BASE}/lib/os/dec.c)

View file

@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
project(winstream)
cmake_minimum_required(VERSION 3.20.0)
set(SOURCES main.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
target_sources(testbinary PRIVATE main.c)

View file

@ -2,14 +2,12 @@
cmake_minimum_required(VERSION 3.20.0)
if(BOARD STREQUAL unit_testing)
# Add the sources
list(APPEND SOURCES src/main.c)
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(base)
# This test suite depends on having this CONFIG_ value, so define it
add_definitions( -DCONFIG_BUGxxxxx )
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(base)
target_sources(testbinary PRIVATE src/main.c)
else()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(base)