Skip to content

Commit 573d94e

Browse files
committed
Add opt-in mull mutation-testing wiring (Linux only)
1 parent edbe8f8 commit 573d94e

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ if(SENTINEL_ENABLE_FUZZING)
5151
add_link_options(-fsanitize=address)
5252
endif()
5353

54+
# Off by default, Linux-only: see lib/CMakeLists.txt for what this enables
55+
# and docs/architecture.md ("Mutation testing") for how to actually run it
56+
# with mull (https://mull-project.com). MULL_IR_FRONTEND must point at a
57+
# mull-ir-frontend-N binary whose N matches CMAKE_CXX_COMPILER's own LLVM
58+
# version exactly -- mull's plugin ABI is not forward/backward compatible
59+
# even across patch releases built differently (a statically-linked
60+
# official LLVM release binary vs. a distro's dynamically-linked one), so
61+
# reproducing this needs an apt-installed clang, not a hand-downloaded
62+
# LLVM release tarball.
63+
option(SENTINEL_ENABLE_MUTATION_TESTING
64+
"Instrument sentinel-lib for mull mutation testing" OFF)
65+
set(MULL_IR_FRONTEND "" CACHE FILEPATH "Path to a matching mull-ir-frontend-N")
66+
5467
add_subdirectory(lib)
5568
add_subdirectory(tools/cpp-sentinel)
5669

lib/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,18 @@ target_compile_definitions(sentinel-lib PRIVATE
6868
SENTINEL_CLANG_RESOURCE_DIR="${SENTINEL_CLANG_RESOURCE_DIR}"
6969
SENTINEL_VERSION="${PROJECT_VERSION}"
7070
)
71+
72+
# Off by default, Linux-only (see docs/architecture.md "Mutation testing"):
73+
# instruments *only* sentinel-lib (not googletest/yaml-cpp/the test binary
74+
# itself) with mull's IR-frontend plugin, so mull-runner's mutant search
75+
# space stays scoped to code this project actually owns. Applying
76+
# -fpass-plugin globally (e.g. via CMAKE_CXX_FLAGS) instead instruments
77+
# every dependency too, which is what made an early attempt at this OOM.
78+
if(SENTINEL_ENABLE_MUTATION_TESTING)
79+
if(NOT MULL_IR_FRONTEND)
80+
message(FATAL_ERROR
81+
"SENTINEL_ENABLE_MUTATION_TESTING requires -DMULL_IR_FRONTEND=/path/to/mull-ir-frontend-N")
82+
endif()
83+
target_compile_options(sentinel-lib PRIVATE
84+
-fpass-plugin=${MULL_IR_FRONTEND} -g -grecord-command-line)
85+
endif()

mull.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Config for mull (https://mull-project.com), only consulted when
2+
# SENTINEL_ENABLE_MUTATION_TESTING is on -- see docs/architecture.md
3+
# ("Mutation testing") for how to build and run this. Scopes mutants to
4+
# this project's own sources; sentinel-lib is also the only CMake target
5+
# actually compiled with the pass plugin (see lib/CMakeLists.txt), so this
6+
# is a second, belt-and-suspenders filter on top of that, not the only one.
7+
includePaths:
8+
- ".*/lib/.*\\.cpp$"

0 commit comments

Comments
 (0)