summaryrefslogtreecommitdiffstats
path: root/src/testlib/selfcover.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib/selfcover.cmake')
-rw-r--r--src/testlib/selfcover.cmake40
1 files changed, 40 insertions, 0 deletions
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()