cmake_policy(SET CMP0054 NEW) math(EXPR testExecutableIndex "${CMAKE_ARGC} - 1") math(EXPR separatorIndex "${CMAKE_ARGC} - 2") if(NOT CMAKE_ARGV${separatorIndex} STREQUAL "--") message(FATAL_ERROR "Expected the test executable after --") endif() set(TEST_EXECUTABLE "${CMAKE_ARGV${testExecutableIndex}}") file(MAKE_DIRECTORY "${WORK_DIR}") execute_process(COMMAND "${PATCHER}" --write-export-list "${LIBC}" "${WORK_DIR}/libc.exports" RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE error) if(NOT status STREQUAL "0") message(FATAL_ERROR "libc export list failed: ${output}${error}") endif() foreach(module LIBC KERNEL INTERNAL) get_filename_component(name "${${module}}" NAME) get_filename_component(library "${${module}}" NAME_WE) file(COPY_FILE "${${module}}" "${WORK_DIR}/${name}") if(module STREQUAL "LIBC") execute_process(COMMAND "${PATCHER}" "${library}" "${WORK_DIR}/${name}" RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE error) else() execute_process(COMMAND "${PATCHER}" "${library}" --preserve-export-list "${WORK_DIR}/libc.exports" "${WORK_DIR}/${name}" RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE error) endif() if(NOT status STREQUAL "0") message(FATAL_ERROR "${library} patch failed: ${output}${error}") endif() endforeach() get_filename_component(probeName "${EXCEPTION_PROBE}" NAME) file(COPY_FILE "${EXCEPTION_PROBE}" "${WORK_DIR}/${probeName}") if(WIN32) set(searchDirectories "${WORK_DIR}") foreach(binary LIBC KERNEL INTERNAL EXCEPTION_PROBE TEST_EXECUTABLE) get_filename_component(directory "${${binary}}" DIRECTORY) list(APPEND searchDirectories "${directory}") endforeach() if(ALLOCATOR_DIRECTORY) list(APPEND searchDirectories "${ALLOCATOR_DIRECTORY}") endif() list(REMOVE_DUPLICATES searchDirectories) list(JOIN searchDirectories ";" searchPath) set(environment "PATH=${searchPath};$ENV{PATH}") else() set(environment "LD_LIBRARY_PATH=${WORK_DIR}:$ENV{LD_LIBRARY_PATH}") endif() foreach(order Internal-first libc-first) set(arguments "${WORK_DIR}" "${probeName}") if(order STREQUAL "libc-first") list(APPEND arguments libc-first) endif() execute_process(COMMAND "${CMAKE_COMMAND}" -E env "${environment}" "${TEST_EXECUTABLE}" ${arguments} RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE error) if(NOT status STREQUAL "0") message(FATAL_ERROR "sigvec ${order} lookup failed: ${output}${error}") endif() message("${output}") endforeach()