Last active
November 5, 2023 17:51
-
-
Save scivision/c180c393f7b86d4071a8a1ceda8bfe54 to your computer and use it in GitHub Desktop.
CTest WILL_FAIL wrapper script for segfault, abort,etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.15) | |
project(buggy LANGUAGES C) | |
enable_testing() | |
include(CheckIncludeFile) | |
check_include_file("signal.h" HAVE_SIGNAL) | |
if(HAVE_SIGNAL) | |
file(GENERATE OUTPUT abrt.c CONTENT "#include <signal.h> | |
int main(void){ raise(SIGABRT); return 0; }") | |
add_executable(abrt ${CMAKE_CURRENT_BINARY_DIR}/abrt.c) | |
add_test(NAME sigabrt COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:abrt>) | |
set_property(TEST sigabrt PROPERTY WILL_FAIL TRUE) | |
endif() | |
file(GENERATE OUTPUT segv.c CONTENT "int main(void){*((char*)0) = 0; return 0;}") | |
add_executable(segv ${CMAKE_CURRENT_BINARY_DIR}/segv.c) | |
add_test(NAME sigsegv COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:segv>) | |
set_property(TEST sigsegv PROPERTY WILL_FAIL TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment