diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/testlib/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/testlib/selfcover.cmake | 40 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/testlib/CMakeLists.txt b/src/testlib/CMakeLists.txt index 0f80af42c9..ba3f861549 100644 --- a/src/testlib/CMakeLists.txt +++ b/src/testlib/CMakeLists.txt @@ -1,5 +1,9 @@ # Generated from testlib.pro. +# special case begin +include(selfcover.cmake) +# special case end + ##################################################################### ## Test Module: ##################################################################### @@ -130,3 +134,6 @@ qt_add_docs(Test doc/qttestlib.qdocconf ) +# special case begin +qt_apply_testlib_coverage_options(Test) +# special case end diff --git a/src/testlib/selfcover.cmake b/src/testlib/selfcover.cmake new file mode 100644 index 0000000000..c04ffa7b01 --- /dev/null +++ b/src/testlib/selfcover.cmake @@ -0,0 +1,40 @@ +# +# Hand crafted file based on selfcover.pri +# + +# Overwrite CMake compiler +function(__qt_testlib_patch_compiler_name variable) + get_filename_component(name ${${variable}} NAME) + set(${variable} cs${name} PARENT_SCOPE) +endfunction() + +if (FEATURE_testlib_selfcover) + __qt_testlib_patch_compiler_name(CMAKE_C_COMPILER) + __qt_testlib_patch_compiler_name(CMAKE_CXX_COMPILER) + __qt_testlib_patch_compiler_name(CMAKE_CXX_COMPILER_AR) + __qt_testlib_patch_compiler_name(CMAKE_CXX_COMPILER_RANLIB) +endif() + +# This enables verification that testlib itself is adequately tested, +# as a grounds for trusting that testing with it is useful. +function(qt_apply_testlib_coverage_options target) + if (NOT FEATURE_testlib_selfcover) + return() + endif() + # Exclude all non-testlib source from coverage instrumentation: + set(testlib_coverage_options + --cs-exclude-file-abs-wildcard="${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/*" + --cs-include-file-abs-wildcard="*/src/testlib/*" + --cs-mcc # enable Multiple Condition Coverage + --cs-mcdc # enable Multiple Condition / Decision Coverage + # (recommended for ISO 26262 ASIL A, B and C -- highly recommended for ASIL D) + # https://doc.froglogic.com/squish-coco/4.1/codecoverage.html#sec%3Amcdc + ) + target_compile_options(${target} PRIVATE + ${testlib_coverage_options} + ) + + target_link_options(${target} PRIVATE + ${testlib_coverage_options} + ) +endfunction() |