diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index f0a048e5f1..8bd3888cb4 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -134,5 +134,5 @@ list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE list(APPEND CTEST_CUSTOM_MEMCHECK_IGNORE kwsys.testProcess-10 # See Source/kwsys/CTestCustom.cmake.in - RunCMake.InstrumentationInterrupt # interrupts cmake with a real signal + RunCMake.InstrumentationInterruptReal # interrupts cmake with a real signal ) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index f20e91db8e..ead7f745c2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -443,20 +443,27 @@ add_RunCMake_test(FileAPI -DPython_EXECUTABLE=${Python_EXECUTABLE} -DCMake_TEST_MODULE_COMPILATION_RULES=${CMake_TEST_MODULE_COMPILATION_RULES} -DCMake_TEST_CXX_STDLIB_MODULES_JSON=${CMake_TEST_CXX_STDLIB_MODULES_JSON}) if(CMAKE_GENERATOR MATCHES "Make|Ninja|FASTBuild") - add_RunCMake_test(Instrumentation -DPython_EXECUTABLE=${Python_EXECUTABLE} - -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} - -DCMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX} - -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA}) - # The real-signal/console-event interrupt case runs in its own suite so it can - # be excluded from MemCheck (the interrupted cmake is killed by a real signal) - # without dropping leak coverage for the rest of the instrumentation tests. - add_RunCMake_test(InstrumentationInterrupt TEST_DIR Instrumentation - -DINSTRUMENTATION_INTERRUPT_REAL=1 - -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX}) + function(add_RunCMake_Instrumentation_test variant) + add_RunCMake_test(Instrumentation${variant} + TEST_DIR Instrumentation + -DPython_EXECUTABLE=${Python_EXECUTABLE} + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} + -DCMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX} + -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} + -DCMake_TEST_INSTRUMENTATION_VARIANT=${variant} + ) + set_property(TEST RunCMake.Instrumentation${variant} APPEND PROPERTY + LABELS "Instrumentation" + ) + endfunction() + add_RunCMake_Instrumentation_test("") + add_RunCMake_Instrumentation_test(MakeProgram) + # The real-signal/console-event interrupt case runs in its own suite so it + # can be excluded from MemCheck (the interrupted cmake is killed by a real + # signal). + add_RunCMake_Instrumentation_test(InterruptReal) endif() add_RunCMake_test(ConfigDir) if(CMake_TEST_FindPython2) diff --git a/Tests/RunCMake/Instrumentation/RunCMakeTest.cmake b/Tests/RunCMake/Instrumentation/RunCMakeTest.cmake index 32fae0ce89..17426d7e0a 100644 --- a/Tests/RunCMake/Instrumentation/RunCMakeTest.cmake +++ b/Tests/RunCMake/Instrumentation/RunCMakeTest.cmake @@ -36,6 +36,25 @@ function(instrument test) "BAD_QUERY" ) cmake_parse_arguments(ARGS "${OPTIONS}" "CHECK_SCRIPT" "CONFIGURE_ARGS" ${ARGN}) + + if(NOT CMake_TEST_INSTRUMENTATION_VARIANT) + if(ARGS_BUILD_MAKE_PROGRAM OR ARGS_INTERRUPT OR ARGS_INSTALL_INTERRUPT OR ARGS_CTEST_INTERRUPT) + return() + endif() + endif() + + if(CMake_TEST_INSTRUMENTATION_VARIANT STREQUAL "MakeProgram") + if(NOT ARGS_BUILD_MAKE_PROGRAM) + return() + endif() + endif() + + if(CMake_TEST_INSTRUMENTATION_VARIANT STREQUAL "InterruptReal") + if(NOT (ARGS_INTERRUPT OR ARGS_INSTALL_INTERRUPT OR ARGS_CTEST_INTERRUPT)) + return() + endif() + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}) set(v1 ${RunCMake_TEST_BINARY_DIR}/.cmake/instrumentation/v1) set(v1 ${v1} PARENT_SCOPE) @@ -548,17 +567,21 @@ instrument(cmake-command-custom-content CONFIGURE_ARGS "-DN=2" CHECK_SCRIPT check-custom-content.cmake ) -set(indexDir ${v1}/data/index) -set(fakeIndex ${indexDir}/index-0.json) -file(MAKE_DIRECTORY ${indexDir}) -file(TOUCH ${fakeIndex}) +if(NOT CMake_TEST_INSTRUMENTATION_VARIANT) + set(indexDir ${v1}/data/index) + set(fakeIndex ${indexDir}/index-0.json) + file(MAKE_DIRECTORY ${indexDir}) + file(TOUCH ${fakeIndex}) +endif() # fakeIndex newer than all content files prevents their deletion set(EXPECTED_CONTENT_FILES 2) instrument(cmake-command-custom-content NO_CONFIGURE MANUAL_HOOK PRESERVE_DATA CHECK_SCRIPT check-custom-content-removed.cmake ) -file(REMOVE ${fakeIndex}) +if(NOT CMake_TEST_INSTRUMENTATION_VARIANT) + file(REMOVE ${fakeIndex}) +endif() # old content files will be removed if no index file exists set(EXPECTED_CONTENT_FILES 1) instrument(cmake-command-custom-content @@ -658,7 +681,7 @@ endif() # overall cmakeBuild/cmakeInstall snippet, recording the interrupting signal, # and skips the corresponding post-command hook. These cases use the # deterministic test seam (no OS event); the real OS-event counterparts run in -# the separate RunCMake.InstrumentationInterrupt suite. +# the separate RunCMake.InstrumentationInterruptReal suite. instrument(interrupt-build INTERRUPT_SEAM CHECK_SCRIPT check-interrupted.cmake ) @@ -711,34 +734,32 @@ if(NOT Skip_BUILD_MAKE_PROGRAM_Case) endif() endif() -if (INSTRUMENTATION_INTERRUPT_REAL) - # RunCMake.InstrumentationInterrupt runs ONLY the real-signal/ - # console-event interrupt case, as it must be excluded from MemCheck. - # - # POSIX delivers a real SIGINT to a contained process group. On Windows, only - # the Ninja generator is exercised: its native tool reliably stops on the - # console event and does not re-broadcast it to the runner; the other Windows - # make-family generators are covered by the injection seam instead. - if (NOT WIN32 OR RunCMake_GENERATOR MATCHES "Ninja") - instrument(interrupt-build INTERRUPT - CHECK_SCRIPT check-interrupted.cmake - ) - # Interrupt a parallel `cmake --install` with a real OS signal, proving the - # cooperative cancellation stops pending install scripts and skips the hook. - instrument(interrupt-install INSTALL_INTERRUPT - CHECK_SCRIPT check-installation-interrupted.cmake - ) - # Interrupt a `ctest` run with a real OS signal, proving the scheduler stops - # launching pending tests, skips the hook, and preserves the `ctest -F` - # checkpoint so the interrupted test set can be resumed. - instrument(interrupt-test CTEST_INTERRUPT - CHECK_SCRIPT check-test-interrupted.cmake - ) - # Interrupt a `ctest` run and then resume it with `ctest -F`, proving the - # checkpoint keeps the finished test (skipped on resume) but not the - # in-flight test killed by the interrupt (re-run on resume). - instrument(interrupt-test-failover CTEST_FAILOVER - CHECK_SCRIPT check-test-failover.cmake - ) - endif() +# RunCMake.InstrumentationInterruptReal runs ONLY the real-signal/ +# console-event interrupt case, as it must be excluded from MemCheck. +# +# POSIX delivers a real SIGINT to a contained process group. On Windows, only +# the Ninja generator is exercised: its native tool reliably stops on the +# console event and does not re-broadcast it to the runner; the other Windows +# make-family generators are covered by the injection seam instead. +if (NOT WIN32 OR RunCMake_GENERATOR MATCHES "Ninja") + instrument(interrupt-build INTERRUPT + CHECK_SCRIPT check-interrupted.cmake + ) + # Interrupt a parallel `cmake --install` with a real OS signal, proving the + # cooperative cancellation stops pending install scripts and skips the hook. + instrument(interrupt-install INSTALL_INTERRUPT + CHECK_SCRIPT check-installation-interrupted.cmake + ) + # Interrupt a `ctest` run with a real OS signal, proving the scheduler stops + # launching pending tests, skips the hook, and preserves the `ctest -F` + # checkpoint so the interrupted test set can be resumed. + instrument(interrupt-test CTEST_INTERRUPT + CHECK_SCRIPT check-test-interrupted.cmake + ) + # Interrupt a `ctest` run and then resume it with `ctest -F`, proving the + # checkpoint keeps the finished test (skipped on resume) but not the + # in-flight test killed by the interrupt (re-run on resume). + instrument(interrupt-test-failover CTEST_FAILOVER + CHECK_SCRIPT check-test-failover.cmake + ) endif()