Skip to content

Commit

Permalink
test: settings: functional: fix missing test_main
Browse files Browse the repository at this point in the history
The functional tests for settings subsystem regressed with the
introduction of the weak test_main function. This was caused by
Issue #19582 since the common code was being linked as a library.

Update the logic of the common code to directly add the sources
to the `app` target. This resolved both Issue #19582 and #42396

Signed-off-by: Yuval Peress <peress@google.com>
  • Loading branch information
yperess authored and nashif committed Feb 11, 2022
1 parent 7b1a56f commit 7f90587
Show file tree
Hide file tree
Showing 16 changed files with 6 additions and 78 deletions.
4 changes: 0 additions & 4 deletions tests/subsys/settings/fcb/raw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(settings_fcb_raw)

add_subdirectory(../src fcb_test_bindir)
target_link_libraries(app PRIVATE settings_fcb_test)

# The code is in the library common to several tests.
target_sources(app PRIVATE placeholder.c)

if(TEST)
target_compile_definitions(app PRIVATE
Expand Down
2 changes: 0 additions & 2 deletions tests/subsys/settings/fcb/raw/placeholder.c

This file was deleted.

5 changes: 1 addition & 4 deletions tests/subsys/settings/fcb/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Intel Corporation

zephyr_library_named(settings_fcb_test)

add_subdirectory(../../src settings_test_bindir)
target_link_libraries(settings_fcb_test PRIVATE settings_test)

zephyr_include_directories(
${ZEPHYR_BASE}/subsys/settings/include
Expand All @@ -13,4 +10,4 @@ zephyr_include_directories(
)

FILE(GLOB mysources *.c)
zephyr_library_sources(${mysources})
target_sources(app PRIVATE ${mysources})
12 changes: 1 addition & 11 deletions tests/subsys/settings/fs/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Nordic Semiconductor ASA

zephyr_library_named(settings_test_fs)

# zephyr_library() is here in "app-mode", see
# https://github.com/zephyrproject-rtos/zephyr/issues/19582
# Random build failures without this, depends on the number of threads.
add_dependencies(settings_test_fs
zephyr_generated_headers
)

FILE(GLOB fssources *.c )
zephyr_library_sources(${fssources})
zephyr_library_link_libraries(kernel)
target_sources(app PRIVATE ${fssources})
1 change: 0 additions & 1 deletion tests/subsys/settings/functional/fcb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ project(functional_fcb)
target_sources(app PRIVATE placeholder.c)

add_subdirectory(../src func_test_bindir)
target_link_libraries(app PRIVATE settings_func_test)

if(TEST)
target_compile_definitions(app PRIVATE
Expand Down
1 change: 0 additions & 1 deletion tests/subsys/settings/functional/nvs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ project(functional_nvs)
target_sources(app PRIVATE placeholder.c)

add_subdirectory(../src func_test_bindir)
target_link_libraries(app PRIVATE settings_func_test)

if(TEST)
target_compile_definitions(app PRIVATE
Expand Down
12 changes: 1 addition & 11 deletions tests/subsys/settings/functional/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_library_named( settings_func_test)

zephyr_include_directories(
${ZEPHYR_BASE}/subsys/settings/include
${ZEPHYR_BASE}/subsys/settings/src
)

zephyr_library_sources(settings_basic_test.c)

# zephyr_library() is here in "app-mode", see
# https://github.com/zephyrproject-rtos/zephyr/issues/19582
# Random build failures without this, depends on the number of threads.
add_dependencies(
settings_func_test
zephyr_generated_headers
)
target_sources(app PRIVATE settings_basic_test.c)
4 changes: 0 additions & 4 deletions tests/subsys/settings/littlefs/base64/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(littlefs)

add_subdirectory(../src littlefs_test_bindir)
target_link_libraries(app PRIVATE settings_littlefs_test)

# The code is in the library common to several tests.
target_sources(app PRIVATE placeholder.c)

if(TEST)
target_compile_definitions(app PRIVATE
Expand Down
2 changes: 0 additions & 2 deletions tests/subsys/settings/littlefs/base64/placeholder.c

This file was deleted.

5 changes: 0 additions & 5 deletions tests/subsys/settings/littlefs/raw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ project(littlefs_raw)

add_subdirectory(../src littlefs_test_bindir)

target_link_libraries(app PRIVATE settings_littlefs_test)

# The code is in the library common to several tests.
target_sources(app PRIVATE placeholder.c)

if(TEST)
target_compile_definitions(app PRIVATE
-DTEST_${TEST}
Expand Down
5 changes: 0 additions & 5 deletions tests/subsys/settings/littlefs/raw/placeholder.c

This file was deleted.

8 changes: 1 addition & 7 deletions tests/subsys/settings/littlefs/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Nordic Semiconductor ASA

zephyr_library_named(settings_littlefs_test)

add_subdirectory(../../src settings_test_bindir)
add_subdirectory(../../fs/src settings_test_fs_bindir)

target_link_libraries(settings_littlefs_test PRIVATE LITTLEFS)
target_link_libraries(settings_littlefs_test PRIVATE settings_test)
target_link_libraries(settings_littlefs_test PRIVATE settings_test_fs)

zephyr_include_directories(
${ZEPHYR_BASE}/subsys/settings/include
${ZEPHYR_BASE}/subsys/settings/src
Expand All @@ -19,4 +13,4 @@ zephyr_include_directories(


FILE(GLOB mysources *.c)
zephyr_library_sources(${mysources})
target_sources(app PRIVATE ${mysources})
4 changes: 0 additions & 4 deletions tests/subsys/settings/nvs/raw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(test_settings_nvs_raw)

add_subdirectory(../src nvs_test_bindir)
target_link_libraries(app PRIVATE settings_nvs_test)

# The code is in the library common to several tests.
target_sources(app PRIVATE placeholder.c)

if(TEST)
target_compile_definitions(app PRIVATE
Expand Down
2 changes: 0 additions & 2 deletions tests/subsys/settings/nvs/raw/placeholder.c

This file was deleted.

5 changes: 1 addition & 4 deletions tests/subsys/settings/nvs/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Intel Corporation

zephyr_library_named(settings_nvs_test)

zephyr_include_directories(
${ZEPHYR_BASE}/subsys/settings/include
${ZEPHYR_BASE}/subsys/settings/src
${ZEPHYR_BASE}/tests/subsys/settings/nvs/src
)

zephyr_library_sources(settings_test_nvs.c)
target_sources(app PRIVATE settings_test_nvs.c)

add_subdirectory(../../src settings_test_bindir)
target_link_libraries(settings_nvs_test PRIVATE settings_test)
12 changes: 1 addition & 11 deletions tests/subsys/settings/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Intel Corporation

zephyr_library_named(settings_test)

# zephyr_library() is here in "app-mode", see
# https://github.com/zephyrproject-rtos/zephyr/issues/19582
# Random build failures without this, depends on the number of threads.
add_dependencies(
settings_test
zephyr_generated_headers
)

FILE(GLOB mysources *.c )
zephyr_library_sources(${mysources})
target_sources(app PRIVATE ${mysources})

0 comments on commit 7f90587

Please sign in to comment.