diff --git a/cmake/modules/BinaryTest.cmake b/cmake/modules/BinaryTest.cmake --- a/cmake/modules/BinaryTest.cmake +++ b/cmake/modules/BinaryTest.cmake @@ -1,8 +1,24 @@ # Facilities to run tests on the executable binaries. +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(UNIT_TEST_NAME "test_PE") +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(UNIT_TEST_NAME "test_ELF") +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(UNIT_TEST_NAME "test_MACHO") +endif() + macro(add_to_symbols_check BINARY) if(NOT TARGET symbol-check) add_custom_target(symbol-check) + + add_custom_target(test-symbol-check + COMMENT "Running test-symbol-check (${UNIT_TEST_NAME})" + COMMAND + "${Python_EXECUTABLE}" + "${CMAKE_SOURCE_DIR}/contrib/devtools/test-symbol-check.py" + "TestSymbolChecks.${UNIT_TEST_NAME}") + add_dependencies(symbol-check test-symbol-check) endif() set(CUSTOM_TARGET_NAME "symbol-check-${BINARY}") @@ -22,8 +38,17 @@ macro(add_to_security_check BINARY) if(NOT TARGET security-check) add_custom_target(security-check) + + add_custom_target(test-security-check + COMMENT "Running test-security-check (${UNIT_TEST_NAME})" + COMMAND + "${Python_EXECUTABLE}" + "${CMAKE_SOURCE_DIR}/contrib/devtools/test-security-check.py" + "TestSecurityChecks.${UNIT_TEST_NAME}") + add_dependencies(security-check test-security-check) endif() + set(CUSTOM_TARGET_NAME "security-check-${BINARY}") add_custom_target("${CUSTOM_TARGET_NAME}" COMMENT "Running security-check.py on ${BINARY}..." diff --git a/contrib/devtools/test-security-check.py b/contrib/devtools/test-security-check.py --- a/contrib/devtools/test-security-check.py +++ b/contrib/devtools/test-security-check.py @@ -43,7 +43,7 @@ subprocess.run([*cc, source, "-o", executable] + env_flags + options, check=True) p = subprocess.run( - ["./contrib/devtools/security-check.py", executable], + [os.path.join(os.path.dirname(__file__), "security-check.py"), executable], stdout=subprocess.PIPE, universal_newlines=True, ) diff --git a/contrib/devtools/test-symbol-check.py b/contrib/devtools/test-symbol-check.py --- a/contrib/devtools/test-symbol-check.py +++ b/contrib/devtools/test-symbol-check.py @@ -26,7 +26,7 @@ subprocess.run([*cc, source, "-o", executable] + env_flags + options, check=True) p = subprocess.run( - ["./contrib/devtools/symbol-check.py", executable], + [os.path.join(os.path.dirname(__file__), "symbol-check.py"), executable], stdout=subprocess.PIPE, universal_newlines=True, )