Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/Run error injector tests only for Debug build. #652

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ include(CheckLinkerFlag)
check_linker_flag(CXX LINKER:--wrap,celix_nonexistent_symbol LINKER_WRAP_SUPPORTED)
cmake_pop_check_state()

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND LINKER_WRAP_SUPPORTED)
set(EI_TESTS ON)
else ()
set(EI_TESTS OFF)
endif()

# avoid unknown export "celix" error when building nothing
add_library(celix INTERFACE)
add_library(Celix::celix ALIAS celix)
Expand Down
2 changes: 1 addition & 1 deletion bundles/components_ready_check/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ celix_target_bundle_set_definition(test_components_ready NAME INACTIVE_CMP_TEST_
add_test(NAME test_components_ready COMMAND test_components_ready)
setup_target_for_coverage(test_components_ready SCAN_DIR ..)

if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
add_executable(test_components_ready_with_ei src/ComponentsReadyWithErrorInjectionTestSuite.cc)
target_link_libraries(test_components_ready_with_ei PRIVATE
framework_cut
Expand Down
2 changes: 1 addition & 1 deletion bundles/logging/log_helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if (LOG_HELPER)
add_library(Celix::log_helper ALIAS log_helper)

if (ENABLE_TESTING)
if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
add_subdirectory(error_injector)
endif ()
add_subdirectory(gtest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ target_link_libraries(celix_pswp_common_tests PRIVATE celix_pubsub_protocol_lib
add_test(NAME celix_pswp_common_tests COMMAND celix_pswp_common_tests)
setup_target_for_coverage(celix_pswp_common_tests SCAN_DIR ..)

if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
add_executable(celix_pswp_common_ei_tests src/PS_WP_common_ei_tests.cc)
target_include_directories(celix_pswp_common_ei_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src)
target_link_libraries(celix_pswp_common_ei_tests PRIVATE celix_pubsub_protocol_lib GTest::gtest Celix::pubsub_spi GTest::gtest_main Celix::malloc_ei Celix::properties_ei)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ target_compile_definitions(integration_test_discovery_zeroconf PRIVATE -DDISCOVE
add_test(NAME run_integration_test_discovery_zeroconf COMMAND integration_test_discovery_zeroconf)
setup_target_for_coverage(integration_test_discovery_zeroconf SCAN_DIR ..)

if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
####unit test
add_executable(unit_test_discovery_zeroconf
src/DiscoveryZeroconfAnnouncerTestSuite.cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ add_celix_bundle_dependencies(integration_test_rsa_shm Celix::rsa_shm)
add_test(NAME run_integration_test_rsa_shm COMMAND integration_test_rsa_shm)
setup_target_for_coverage(integration_test_rsa_shm SCAN_DIR ..)

if (LINKER_WRAP_SUPPORTED AND BUILD_RSA_JSON_RPC)
if (EI_TESTS AND BUILD_RSA_JSON_RPC)
####unit test
add_executable(unit_test_rsa_shm
src/RsaShmImplUnitTestSuite.cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
add_executable(test_shm_pool
src/ShmPoolTestSuite.cc
src/ShmCacheTestSuite.cc
Expand Down
2 changes: 1 addition & 1 deletion bundles/remote_services/rsa_common/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
####unit test
add_executable(unit_test_rsa_common
src/EndpointDescriptionUnitTestSuite.cc
Expand Down
2 changes: 1 addition & 1 deletion bundles/remote_services/rsa_rpc_json/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ target_compile_definitions(integration_test_rsa_json_rpc PRIVATE -DRSA_JSON_RPC_
add_test(NAME run_integration_test_rsa_json_rpc COMMAND integration_test_rsa_json_rpc)
setup_target_for_coverage(integration_test_rsa_json_rpc SCAN_DIR ..)

if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
####unit test
add_executable(unit_test_rsa_json_rpc
src/RsaJsonRpcUnitTestSuite.cc
Expand Down
2 changes: 1 addition & 1 deletion documents/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void celix_foo_destroy(celix_foo_t* foo) {
## Error Injection

- Use the Apache Celix error_injector libraries to inject errors in unit tests in a controlled way.
- Create a separate test suite for error injection tests and place them under a `LINKER_WRAP_SUPPORTED` cmake condition.
- Create a separate test suite for error injection tests and place them under a `EI_TESTS` cmake condition.
- Reset error injection setup on the `TearDown` function or destructor of the test fixture.
- If an - internal or external - function is missing error injection support, add it to the error_injector library.
- Try to create small error injector libraries for specific functionality.
Expand Down
2 changes: 1 addition & 1 deletion libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (CELIX_CXX14)
endif ()

# Error Injectors
if (ENABLE_TESTING AND LINKER_WRAP_SUPPORTED)
if (ENABLE_TESTING AND EI_TESTS)
add_subdirectory(error_injector)
endif ()

2 changes: 1 addition & 1 deletion libs/dfi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if (CELIX_DFI)
#Alias setup to match external usage
add_library(Celix::dfi ALIAS dfi)

if (ENABLE_TESTING AND LINKER_WRAP_SUPPORTED)
if (ENABLE_TESTING AND EI_TESTS)
add_subdirectory(error_injector)
endif ()
if (ENABLE_TESTING)
Expand Down
2 changes: 1 addition & 1 deletion libs/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if (FRAMEWORK)
#Alias setup to match external usage
add_library(Celix::framework ALIAS framework)

if (ENABLE_TESTING AND LINKER_WRAP_SUPPORTED)
if (ENABLE_TESTING AND EI_TESTS)
add_subdirectory(error_injector)
endif ()
if (ENABLE_TESTING AND CELIX_CXX17) #framework tests are C++17
Expand Down
2 changes: 1 addition & 1 deletion libs/framework/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ endif ()
add_test(NAME test_framework COMMAND test_framework)
setup_target_for_coverage(test_framework SCAN_DIR ..)

if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
add_executable(test_framework_with_ei
src/BundleArchiveWithErrorInjectionTestSuite.cc
src/CelixFrameworkUtilsErrorInjectionTestSuite.cc
Expand Down
2 changes: 1 addition & 1 deletion libs/rcm/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_link_libraries(test_rcm PRIVATE Celix::rcm GTest::gtest GTest::gtest_main
add_test(NAME test_rcm COMMAND test_rcm)
setup_target_for_coverage(test_rcm SCAN_DIR ..)

if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
add_executable(test_rcm_with_error_injection
src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc
)
Expand Down
4 changes: 2 additions & 2 deletions libs/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ if (UTILS)
#Alias setup to match external usage
add_library(Celix::utils ALIAS utils)

if (ENABLE_TESTING AND LINKER_WRAP_SUPPORTED)
if (ENABLE_TESTING AND EI_TESTS)
add_subdirectory(error_injector)
endif ()

Expand Down Expand Up @@ -163,7 +163,7 @@ if (UTILS)
target_link_libraries(version_test CppUTest utils_cut pthread)


if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
add_executable(version_ei_test private/test/version_ei_test.cc)
target_include_directories(version_ei_test PRIVATE include_deprecated)
target_link_libraries(version_ei_test CppUTest utils_cut Celix::malloc_ei Celix::utils_ei pthread)
Expand Down
2 changes: 1 addition & 1 deletion libs/utils/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ add_test(NAME test_utils COMMAND test_utils)
setup_target_for_coverage(test_utils SCAN_DIR ..)


if (LINKER_WRAP_SUPPORTED)
if (EI_TESTS)
add_executable(test_utils_with_ei
src/FileUtilsErrorInjectionTestSuite.cc
src/ConvertUtilsErrorInjectionTestSuite.cc
Expand Down
Loading