mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-26 19:36:28 +00:00
[CMake] Refactor testing infrastructure
The code for the two OpenMP runtime libraries was very similar. Move to common CMake file that is included and provides a simple interface for adding testsuites. Also add a common check-openmp target that runs all testsuites that have been registered. Note that this renames all test options to the common OPENMP namespace, for example OPENMP_TEST_C_COMPILER instead of LIBOMP_TEST_COMPILER and so on. Differential Revision: https://reviews.llvm.org/D40082 llvm-svn: 319343
This commit is contained in:
parent
5af381acad
commit
18bec60bc2
@ -19,17 +19,38 @@ if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_S
|
||||
set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING
|
||||
"suffix of lib installation directory, e.g. 64 => lib64")
|
||||
|
||||
# Group test settings.
|
||||
set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING
|
||||
"C compiler to use for testing OpenMP runtime libraries.")
|
||||
set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
|
||||
"C++ compiler to use for testing OpenMP runtime libraries.")
|
||||
set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.")
|
||||
else()
|
||||
set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
|
||||
# If building in tree, we honor the same install suffix LLVM uses.
|
||||
set(OPENMP_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX})
|
||||
|
||||
if (NOT MSVC)
|
||||
set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
|
||||
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
|
||||
else()
|
||||
set(OPENMP_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
|
||||
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check and set up common compiler flags.
|
||||
include(config-ix)
|
||||
include(HandleOpenMPOptions)
|
||||
|
||||
# Set up testing infrastructure.
|
||||
include(OpenMPTesting)
|
||||
|
||||
set(OPENMP_TEST_FLAGS "" CACHE STRING
|
||||
"Extra compiler flags to send to the test compiler.")
|
||||
set(OPENMP_TEST_OPENMP_FLAGS "-fopenmp" CACHE STRING
|
||||
"OpenMP compiler flag to use for testing OpenMP runtime libraries.")
|
||||
|
||||
|
||||
# Build host runtime library.
|
||||
add_subdirectory(runtime)
|
||||
@ -55,3 +76,6 @@ if (OPENMP_ENABLE_LIBOMPTARGET)
|
||||
|
||||
add_subdirectory(libomptarget)
|
||||
endif()
|
||||
|
||||
# Now that we have seen all testuites, create the check-openmp target.
|
||||
construct_check_openmp_target()
|
||||
|
104
openmp/cmake/OpenMPTesting.cmake
Normal file
104
openmp/cmake/OpenMPTesting.cmake
Normal file
@ -0,0 +1,104 @@
|
||||
# Keep track if we have all dependencies.
|
||||
set(ENABLE_CHECK_TARGETS TRUE)
|
||||
|
||||
# Function to find required dependencies for testing.
|
||||
function(find_standalone_test_dependencies)
|
||||
include(FindPythonInterp)
|
||||
|
||||
if (NOT PYTHONINTERP_FOUND)
|
||||
message(STATUS "Could not find Python.")
|
||||
message(WARNING "The check targets will not be available!")
|
||||
set(ENABLE_CHECK_TARGETS FALSE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Find executables.
|
||||
find_program(OPENMP_LLVM_LIT_EXECUTABLE
|
||||
NAMES llvm-lit lit.py lit
|
||||
PATHS ${OPENMP_LLVM_TOOLS_DIR})
|
||||
if (NOT OPENMP_LLVM_LIT_EXECUTABLE)
|
||||
message(STATUS "Cannot find llvm-lit.")
|
||||
message(STATUS "Please put llvm-lit in your PATH, set OPENMP_LLVM_LIT_EXECUTABLE to its full path, or point OPENMP_LLVM_TOOLS_DIR to its directory.")
|
||||
message(WARNING "The check targets will not be available!")
|
||||
set(ENABLE_CHECK_TARGETS FALSE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_program(OPENMP_FILECHECK_EXECUTABLE
|
||||
NAMES FileCheck
|
||||
PATHS ${OPENMP_LLVM_TOOLS_DIR})
|
||||
if (NOT OPENMP_FILECHECK_EXECUTABLE)
|
||||
message(STATUS "Cannot find FileCheck.")
|
||||
message(STATUS "Please put FileCheck in your PATH, set OPENMP_FILECHECK_EXECUTABLE to its full path, or point OPENMP_LLVM_TOOLS_DIR to its directory.")
|
||||
message(WARNING "The check targets will not be available!")
|
||||
set(ENABLE_CHECK_TARGETS FALSE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if (${OPENMP_STANDALONE_BUILD})
|
||||
find_standalone_test_dependencies()
|
||||
|
||||
# Make sure we can use the console pool for recent CMake and Ninja > 1.5.
|
||||
if (CMAKE_VERSION VERSION_LESS 3.1.20141117)
|
||||
set(cmake_3_2_USES_TERMINAL)
|
||||
else()
|
||||
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
|
||||
endif()
|
||||
|
||||
# Set lit arguments.
|
||||
set(DEFAULT_LIT_ARGS "-sv --show-unsupported --show-xfail")
|
||||
if (MSVC OR XCODE)
|
||||
set(DEFAULT_LIT_ARGS "${DEFAULT_LIT_ARGS} --no-progress-bar")
|
||||
endif()
|
||||
# TODO: Remove once bots are updated to use the new option.
|
||||
if (DEFINED LIBOMP_LIT_ARGS)
|
||||
set(DEFAULT_LIT_ARGS ${LIBOMP_LIT_ARGS})
|
||||
endif()
|
||||
set(OPENMP_LIT_ARGS "${DEFAULT_LIT_ARGS}" CACHE STRING "Options for lit.")
|
||||
separate_arguments(OPENMP_LIT_ARGS)
|
||||
else()
|
||||
set(OPENMP_FILECHECK_EXECUTABLE ${LLVM_RUNTIME_OUTPUT_INTDIR}/FileCheck)
|
||||
endif()
|
||||
|
||||
# Function to add a testsuite for an OpenMP runtime library.
|
||||
function(add_openmp_testsuite target comment)
|
||||
if (NOT ENABLE_CHECK_TARGETS)
|
||||
add_custom_target(${target}
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, dependencies not found.")
|
||||
message(STATUS "${target} does nothing.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
|
||||
# EXCLUDE_FROM_ALL excludes the test ${target} out of check-openmp.
|
||||
if (NOT EXCLUDE_FROM_ALL)
|
||||
# Register the testsuites and depends for the check-openmp rule.
|
||||
set_property(GLOBAL APPEND PROPERTY OPENMP_LIT_TESTSUITES ${ARG_UNPARSED_ARGUMENTS})
|
||||
set_property(GLOBAL APPEND PROPERTY OPENMP_LIT_DEPENDS ${ARG_DEPENDS})
|
||||
endif()
|
||||
|
||||
if (${OPENMP_STANDALONE_BUILD})
|
||||
add_custom_target(${target}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${OPENMP_LLVM_LIT_EXECUTABLE} ${OPENMP_LIT_ARGS} ${ARG_UNPARSED_ARGUMENTS}
|
||||
COMMENT ${comment}
|
||||
DEPENDS ${ARG_DEPENDS}
|
||||
${cmake_3_2_USES_TERMINAL}
|
||||
)
|
||||
else()
|
||||
add_lit_testsuite(${target}
|
||||
${comment}
|
||||
${ARG_UNPARSED_ARGUMENTS}
|
||||
DEPENDS clang clang-headers FileCheck ${ARG_DEPENDS}
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(construct_check_openmp_target)
|
||||
get_property(OPENMP_LIT_TESTSUITES GLOBAL PROPERTY OPENMP_LIT_TESTSUITES)
|
||||
get_property(OPENMP_LIT_DEPENDS GLOBAL PROPERTY OPENMP_LIT_DEPENDS)
|
||||
|
||||
# We already added the testsuites themselves, no need to do that again.
|
||||
set(EXCLUDE_FROM_ALL True)
|
||||
add_openmp_testsuite(check-openmp "Running OpenMP tests" ${OPENMP_LIT_TESTSUITES} DEPENDS ${OPENMP_LIT_DEPENDS})
|
||||
endfunction()
|
@ -85,10 +85,10 @@ Build type can be Release, Debug, or RelWithDebInfo.
|
||||
-DOPENMP_ENABLE_WERROR=true|false
|
||||
Should consider warnings as errors.
|
||||
|
||||
-DLIBOMPTARGET_LLVM_LIT_EXECUTABLE=""
|
||||
-DOPENMP_LLVM_LIT_EXECUTABLE=""
|
||||
Full path to the llvm-lit tool. Required for testing in out-of-tree builds.
|
||||
|
||||
-DLIBOMPTARGET_FILECHECK_EXECUTABLE=""
|
||||
-DOPENMP_FILECHECK_EXECUTABLE=""
|
||||
Full path to the FileCheck tool. Required for testing in out-of-tree builds.
|
||||
|
||||
-DLIBOMPTARGET_OPENMP_HEADER_FOLDER=""
|
||||
|
@ -1,14 +1,4 @@
|
||||
# CMakeLists.txt file for unit testing OpenMP Library
|
||||
include(FindPythonInterp)
|
||||
include(CheckTypeSize)
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
libomptarget_warning_say("Could not find Python.")
|
||||
libomptarget_warning_say("The check-libomptarget target will not be available!")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(LIBOMPTARGET_TEST_CFLAGS "" CACHE STRING
|
||||
"Extra compiler flags to send to the test compiler")
|
||||
# CMakeLists.txt file for unit testing OpenMP offloading runtime library.
|
||||
|
||||
if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug)
|
||||
set(LIBOMPTARGET_DEBUG True)
|
||||
@ -17,25 +7,14 @@ else()
|
||||
endif()
|
||||
|
||||
if(${OPENMP_STANDALONE_BUILD})
|
||||
# Make sure we can use the console pool for recent cmake and ninja > 1.5
|
||||
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
|
||||
set(cmake_3_2_USES_TERMINAL)
|
||||
else()
|
||||
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
|
||||
endif()
|
||||
set(LIBOMPTARGET_TEST_C_COMPILER ${CMAKE_C_COMPILER} CACHE STRING
|
||||
"C compiler to use for testing OpenMP offloading library")
|
||||
set(LIBOMPTARGET_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
|
||||
"C++ compiler to use for testing OpenMP offloading library")
|
||||
|
||||
if (NOT(${LIBOMPTARGET_TEST_C_COMPILER} MATCHES "clang" AND ${LIBOMPTARGET_TEST_CXX_COMPILER} MATCHES "clang"))
|
||||
if (NOT(${OPENMP_TEST_C_COMPILER} MATCHES "clang" AND ${OPENMP_TEST_CXX_COMPILER} MATCHES "clang"))
|
||||
libomptarget_say("Can only test with Clang compiler!")
|
||||
libomptarget_warning_say("The check-libomptarget target will not be available!")
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LIBOMPTARGET_TEST_C_COMPILER} --version
|
||||
COMMAND ${OPENMP_TEST_C_COMPILER} --version
|
||||
OUTPUT_VARIABLE TEST_COMPILER_VERSION)
|
||||
string(REGEX MATCH "version ([0-9.]+)" TEST_COMPILER_VERSION ${TEST_COMPILER_VERSION})
|
||||
if (NOT(TEST_COMPILER_VERSION))
|
||||
@ -49,73 +28,19 @@ if(${OPENMP_STANDALONE_BUILD})
|
||||
libomptarget_warning_say("The check-libomptarget target will not be available!")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(LIBOMPTARGET_TEST_OPENMP_FLAG -fopenmp CACHE STRING
|
||||
"OpenMP compiler flag to use for testing OpenMP offloading library")
|
||||
find_program(LIBOMPTARGET_LLVM_LIT_EXECUTABLE
|
||||
NAMES llvm-lit lit.py lit
|
||||
PATHS ${OPENMP_LLVM_TOOLS_DIR})
|
||||
if(NOT LIBOMPTARGET_LLVM_LIT_EXECUTABLE)
|
||||
libomptarget_say("Cannot find llvm-lit.")
|
||||
libomptarget_say("Please put llvm-lit in your PATH or set LIBOMPTARGET_LLVM_LIT_EXECUTABLE to its full path or point OPENMP_LLVM_TOOLS_DIR to its directory")
|
||||
libomptarget_warning_say("The check-libomptarget target will not be available!")
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_program(LIBOMPTARGET_FILECHECK_EXECUTABLE
|
||||
NAMES FileCheck
|
||||
PATHS ${OPENMP_LLVM_TOOLS_DIR})
|
||||
if(NOT LIBOMPTARGET_FILECHECK_EXECUTABLE)
|
||||
libomptarget_say("Cannot find FileCheck.")
|
||||
libomptarget_say("Please put FileCheck in your PATH or set LIBOMPTARGET_FILECHECK_EXECUTABLE to its full path or point OPENMP_LLVM_TOOLS_DIR to its directory")
|
||||
libomptarget_warning_say("The check-libomptarget target will not be available!")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Set lit arguments
|
||||
# The -j 1 lets the actual tests run with the entire machine.
|
||||
# We have one test thread that spawns the tests serially. This allows
|
||||
# Each test to use the entire machine.
|
||||
set(LIBOMPTARGET_LIT_ARGS_DEFAULT "-sv --show-unsupported --show-xfail -j 1")
|
||||
if(MSVC OR XCODE)
|
||||
set(LIBOMPTARGET_LIT_ARGS_DEFAULT "${LIBOMPTARGET_LIT_ARGS_DEFAULT} --no-progress-bar")
|
||||
endif()
|
||||
set(LIBOMPTARGET_LIT_ARGS "${LIBOMPTARGET_LIT_ARGS_DEFAULT}" CACHE STRING
|
||||
"Default options for lit")
|
||||
separate_arguments(LIBOMPTARGET_LIT_ARGS)
|
||||
add_custom_target(check-libomptarget
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${LIBOMPTARGET_LLVM_LIT_EXECUTABLE} ${LIBOMPTARGET_LIT_ARGS} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS omptarget
|
||||
COMMENT "Running libomptarget tests"
|
||||
${cmake_3_2_USES_TERMINAL}
|
||||
)
|
||||
|
||||
add_openmp_testsuite(check-libomptarget "Running libomptarget tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omptarget omp)
|
||||
|
||||
if(${OPENMP_STANDALONE_BUILD})
|
||||
set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../../runtime/src" CACHE STRING
|
||||
"Path to folder containing omp.h")
|
||||
set(LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/../../runtime/src" CACHE STRING
|
||||
"Path to folder containing libomp.so")
|
||||
else()
|
||||
# LLVM source tree build, test just-built clang
|
||||
if(NOT MSVC)
|
||||
set(LIBOMPTARGET_TEST_C_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
|
||||
set(LIBOMPTARGET_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
|
||||
set(LIBOMPTARGET_FILECHECK_EXECUTABLE ${LLVM_RUNTIME_OUTPUT_INTDIR}/FileCheck)
|
||||
else()
|
||||
libomptarget_warning_say("Not prepared to run tests on Windows systems.")
|
||||
endif()
|
||||
set(LIBOMPTARGET_TEST_OPENMP_FLAG -fopenmp=libomp)
|
||||
# Use add_lit_testsuite() from LLVM CMake. This also depends on OpenMP
|
||||
# implementation because it uses omp.h.
|
||||
add_lit_testsuite(check-libomptarget
|
||||
"Running libomptarget tests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS omptarget omp
|
||||
)
|
||||
|
||||
set(LIBOMPTARGET_OPENMP_HEADER_FOLDER "${LIBOMPTARGET_BINARY_DIR}/../runtime/src")
|
||||
endif()
|
||||
|
||||
# Configure the lit.site.cfg.in file
|
||||
set(AUTO_GEN_COMMENT "## Autogenerated by libomptarget configuration.\n# Do not edit!")
|
||||
configure_file(lit.site.cfg.in lit.site.cfg @ONLY)
|
||||
|
||||
|
@ -31,16 +31,15 @@ config.test_exec_root = config.libomptarget_obj_root
|
||||
config.test_format = lit.formats.ShTest()
|
||||
|
||||
# compiler flags
|
||||
config.test_cflags = config.test_openmp_flag + \
|
||||
" -I " + config.test_source_root + \
|
||||
config.test_flags = " -I " + config.test_source_root + \
|
||||
" -I " + config.omp_header_directory + \
|
||||
" -L " + config.library_dir;
|
||||
|
||||
if config.omp_host_rtl_directory:
|
||||
config.test_cflags = config.test_cflags + " -L " + \
|
||||
config.test_flags = config.test_flags + " -L " + \
|
||||
config.omp_host_rtl_directory
|
||||
|
||||
config.test_cflags = config.test_cflags + " " + config.test_extra_cflags
|
||||
config.test_flags = config.test_flags + " " + config.test_extra_flags
|
||||
|
||||
if config.libomptarget_debug:
|
||||
config.available_features.add('libomptarget-debug')
|
||||
@ -53,8 +52,8 @@ elif config.operating_system == 'Darwin':
|
||||
append_dynamic_library_path('DYLD_LIBRARY_PATH', config.library_dir, ":")
|
||||
append_dynamic_library_path('DYLD_LIBRARY_PATH', \
|
||||
config.omp_host_rtl_directory, ";")
|
||||
config.test_cflags += " -Wl,-rpath," + config.library_dir
|
||||
config.test_cflags += " -Wl,-rpath," + config.omp_host_rtl_directory
|
||||
config.test_flags += " -Wl,-rpath," + config.library_dir
|
||||
config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
|
||||
else: # Unices
|
||||
append_dynamic_library_path('LD_LIBRARY_PATH', config.library_dir, ":")
|
||||
append_dynamic_library_path('LD_LIBRARY_PATH', \
|
||||
@ -98,9 +97,9 @@ for libomptarget_target in config.libomptarget_all_targets:
|
||||
libomptarget_target, \
|
||||
"%t-" + libomptarget_target))
|
||||
config.substitutions.append(("%clangxx-" + libomptarget_target, \
|
||||
"%clangxx %cflags -fopenmp-targets=" + libomptarget_target))
|
||||
"%clangxx %openmp_flags %flags -fopenmp-targets=" + libomptarget_target))
|
||||
config.substitutions.append(("%clang-" + libomptarget_target, \
|
||||
"%clang %cflags -fopenmp-targets=" + libomptarget_target))
|
||||
"%clang %openmp_flags %flags -fopenmp-targets=" + libomptarget_target))
|
||||
config.substitutions.append(("%fcheck-" + libomptarget_target, \
|
||||
config.libomptarget_filecheck + " %s"))
|
||||
else:
|
||||
@ -134,5 +133,5 @@ for libomptarget_target in config.libomptarget_all_targets:
|
||||
|
||||
config.substitutions.append(("%clangxx", config.test_cxx_compiler))
|
||||
config.substitutions.append(("%clang", config.test_c_compiler))
|
||||
config.substitutions.append(("%openmp_flag", config.test_openmp_flag))
|
||||
config.substitutions.append(("%cflags", config.test_cflags))
|
||||
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
|
||||
config.substitutions.append(("%flags", config.test_flags))
|
||||
|
@ -1,11 +1,9 @@
|
||||
@AUTO_GEN_COMMENT@
|
||||
|
||||
config.test_c_compiler = "@LIBOMPTARGET_TEST_C_COMPILER@"
|
||||
config.test_cxx_compiler = "@LIBOMPTARGET_TEST_CXX_COMPILER@"
|
||||
config.test_openmp_flag = "@LIBOMPTARGET_TEST_OPENMP_FLAG@"
|
||||
# For the moment we still need to pass libomptarget explicitly. Once the driver
|
||||
# patch, lands, this is not required anymore.
|
||||
config.test_extra_cflags = "-lomptarget @LIBOMPTARGET_TEST_CFLAGS@"
|
||||
config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@"
|
||||
config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@"
|
||||
config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@"
|
||||
config.test_extra_flags = "@OPENMP_TEST_FLAGS@"
|
||||
config.libomptarget_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
|
||||
config.library_dir = "@LIBOMPTARGET_LIBRARY_DIR@"
|
||||
config.omp_header_directory = "@LIBOMPTARGET_OPENMP_HEADER_FOLDER@"
|
||||
@ -13,9 +11,8 @@ config.omp_host_rtl_directory = "@LIBOMPTARGET_OPENMP_HOST_RTL_FOLDER@"
|
||||
config.operating_system = "@CMAKE_SYSTEM_NAME@"
|
||||
config.libomptarget_all_targets = "@LIBOMPTARGET_ALL_TARGETS@".split()
|
||||
config.libomptarget_system_targets = "@LIBOMPTARGET_SYSTEM_TARGETS@".split()
|
||||
config.libomptarget_filecheck = "@LIBOMPTARGET_FILECHECK_EXECUTABLE@"
|
||||
config.libomptarget_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
|
||||
config.libomptarget_debug = @LIBOMPTARGET_DEBUG@
|
||||
|
||||
# Let the main config do the real work.
|
||||
lit_config.load_config(config, "@LIBOMPTARGET_BASE_DIR@/test/lit.cfg")
|
||||
|
||||
|
@ -174,7 +174,7 @@ Specifies install location of Hwloc. The configuration system will look for
|
||||
hwloc.h in ${LIBOMP_HWLOC_INSTALL_DIR}/include and the library in
|
||||
${LIBOMP_HWLOC_INSTALL_DIR}/lib.
|
||||
|
||||
-DLIBOMP_LLVM_LIT_EXECUTABLE=/path/to/llvm-lit
|
||||
-DOPENMP_LLVM_LIT_EXECUTABLE=/path/to/llvm-lit
|
||||
Default: search in PATH
|
||||
Specifiy full path to llvm-lit executable for running tests.
|
||||
|
||||
|
@ -1,15 +1,7 @@
|
||||
# CMakeLists.txt file for unit testing OpenMP Library
|
||||
include(FindPythonInterp)
|
||||
include(CheckTypeSize)
|
||||
# CMakeLists.txt file for unit testing OpenMP host runtime library.
|
||||
include(CheckFunctionExists)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
libomp_warning_say("Could not find Python.")
|
||||
libomp_warning_say("The check-libomp target will not be available!")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Some tests use math functions
|
||||
check_library_exists(m sqrt "" LIBOMP_HAVE_LIBM)
|
||||
# When using libgcc, -latomic may be needed for atomics
|
||||
@ -38,75 +30,8 @@ pythonize_bool(LIBOMP_OMPT_OPTIONAL)
|
||||
pythonize_bool(LIBOMP_HAVE_LIBM)
|
||||
pythonize_bool(LIBOMP_HAVE_LIBATOMIC)
|
||||
|
||||
set(LIBOMP_TEST_CFLAGS "" CACHE STRING
|
||||
"Extra compiler flags to send to the test compiler")
|
||||
|
||||
if(${OPENMP_STANDALONE_BUILD})
|
||||
# Make sure we can use the console pool for recent cmake and ninja > 1.5
|
||||
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
|
||||
set(cmake_3_2_USES_TERMINAL)
|
||||
else()
|
||||
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
|
||||
endif()
|
||||
set(LIBOMP_TEST_COMPILER ${CMAKE_C_COMPILER} CACHE STRING
|
||||
"Compiler to use for testing OpenMP library")
|
||||
set(LIBOMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
|
||||
"Compiler to use for testing OpenMP library")
|
||||
set(LIBOMP_TEST_OPENMP_FLAG -fopenmp CACHE STRING
|
||||
"OpenMP compiler flag to use for testing OpenMP library")
|
||||
find_program(LIBOMP_LLVM_LIT_EXECUTABLE
|
||||
NAMES llvm-lit lit.py lit
|
||||
PATHS ${OPENMP_LLVM_TOOLS_DIR})
|
||||
if(NOT LIBOMP_LLVM_LIT_EXECUTABLE)
|
||||
libomp_say("Cannot find llvm-lit.")
|
||||
libomp_say("Please put llvm-lit in your PATH, set LIBOMP_LLVM_LIT_EXECUTABLE to its full path or point OPENMP_LLVM_TOOLS_DIR to its directory")
|
||||
libomp_warning_say("The check-libomp target will not be available!")
|
||||
return()
|
||||
endif()
|
||||
find_program(FILECHECK_EXECUTABLE
|
||||
NAMES FileCheck
|
||||
PATHS ${OPENMP_LLVM_TOOLS_DIR})
|
||||
if (NOT FILECHECK_EXECUTABLE)
|
||||
# set to empty string so that lit can disable dependent tests
|
||||
set(FILECHECK_EXECUTABLE "")
|
||||
endif()
|
||||
# Set lit arguments
|
||||
# The -j 1 lets the actual tests run with the entire machine.
|
||||
# We have one test thread that spawns the tests serially. This allows
|
||||
# Each test to use the entire machine.
|
||||
set(LIBOMP_LIT_ARGS_DEFAULT "-sv --show-unsupported --show-xfail")
|
||||
if(MSVC OR XCODE)
|
||||
set(LIBOMP_LIT_ARGS_DEFAULT "${LIBOMP_LIT_ARGS_DEFAULT} --no-progress-bar")
|
||||
endif()
|
||||
set(LIBOMP_LIT_ARGS "${LIBOMP_LIT_ARGS_DEFAULT}" CACHE STRING
|
||||
"Default options for lit")
|
||||
separate_arguments(LIBOMP_LIT_ARGS)
|
||||
add_custom_target(check-libomp
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${LIBOMP_LLVM_LIT_EXECUTABLE} ${LIBOMP_LIT_ARGS} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS omp
|
||||
COMMENT "Running libomp tests"
|
||||
${cmake_3_2_USES_TERMINAL}
|
||||
)
|
||||
else()
|
||||
# LLVM source tree build, test just-built clang
|
||||
if(NOT MSVC)
|
||||
set(LIBOMP_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
|
||||
set(LIBOMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++)
|
||||
else()
|
||||
set(LIBOMP_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang.exe)
|
||||
set(LIBOMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
|
||||
endif()
|
||||
set(LIBOMP_TEST_OPENMP_FLAG -fopenmp=libomp)
|
||||
set(FILECHECK_EXECUTABLE ${LLVM_RUNTIME_OUTPUT_INTDIR}/FileCheck)
|
||||
# Use add_lit_testsuite() from LLVM CMake.
|
||||
add_lit_testsuite(check-libomp
|
||||
"Running libomp tests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS clang clang-headers FileCheck omp
|
||||
)
|
||||
endif()
|
||||
add_openmp_testsuite(check-libomp "Running libomp tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omp)
|
||||
|
||||
# Configure the lit.site.cfg.in file
|
||||
set(AUTO_GEN_COMMENT "## Autogenerated by libomp configuration.\n# Do not edit!")
|
||||
configure_file(lit.site.cfg.in lit.site.cfg @ONLY)
|
||||
|
||||
|
@ -42,10 +42,10 @@ config.test_exec_root = config.libomp_obj_root
|
||||
config.test_format = lit.formats.ShTest()
|
||||
|
||||
# compiler flags
|
||||
config.test_cflags = " -I " + config.test_source_root + \
|
||||
config.test_flags = " -I " + config.test_source_root + \
|
||||
" -I " + config.omp_header_directory + \
|
||||
" -L " + config.library_dir + \
|
||||
" " + config.test_extra_cflags
|
||||
" " + config.test_extra_flags
|
||||
|
||||
# extra libraries
|
||||
libs = ""
|
||||
@ -56,7 +56,7 @@ if config.has_libatomic:
|
||||
|
||||
# Allow XFAIL to work
|
||||
config.target_triple = [ ]
|
||||
if re.search('gcc', config.test_compiler) is not None:
|
||||
if re.search('gcc', config.test_c_compiler) is not None:
|
||||
config.available_features.add('gcc')
|
||||
|
||||
# Setup environment to find dynamic library at runtime
|
||||
@ -67,9 +67,9 @@ if config.using_hwloc:
|
||||
|
||||
# Rpath modifications for Darwin
|
||||
if config.operating_system == 'Darwin':
|
||||
config.test_cflags += " -Wl,-rpath," + config.library_dir
|
||||
config.test_flags += " -Wl,-rpath," + config.library_dir
|
||||
if config.using_hwloc:
|
||||
config.test_cflags += " -Wl,-rpath," + config.hwloc_library_dir
|
||||
config.test_flags += " -Wl,-rpath," + config.hwloc_library_dir
|
||||
|
||||
# Find the SDK on Darwin
|
||||
if config.operating_system == 'Darwin':
|
||||
@ -79,7 +79,7 @@ if config.operating_system == 'Darwin':
|
||||
out = out.strip()
|
||||
res = cmd.wait()
|
||||
if res == 0 and out:
|
||||
config.test_cflags += " -isysroot " + out
|
||||
config.test_flags += " -isysroot " + out
|
||||
|
||||
# Disable OMPT tests if FileCheck was not found
|
||||
if config.has_ompt and config.test_filecheck == "":
|
||||
@ -89,7 +89,7 @@ if config.has_ompt and config.test_filecheck == "":
|
||||
if config.has_ompt:
|
||||
config.available_features.add("ompt")
|
||||
# for callback.h
|
||||
config.test_cflags += " -I " + config.test_source_root + "/ompt"
|
||||
config.test_flags += " -I " + config.test_source_root + "/ompt"
|
||||
|
||||
if 'Linux' in config.operating_system:
|
||||
config.available_features.add("linux")
|
||||
@ -105,14 +105,14 @@ config.substitutions.append(("%libomp-compile-and-run", \
|
||||
config.substitutions.append(("%libomp-cxx-compile-and-run", \
|
||||
"%libomp-cxx-compile && %libomp-run"))
|
||||
config.substitutions.append(("%libomp-cxx-compile", \
|
||||
"%clangXX %openmp_flag %cflags -std=c++11 %s -o %t" + libs))
|
||||
"%clangXX %openmp_flags %flags -std=c++11 %s -o %t" + libs))
|
||||
config.substitutions.append(("%libomp-compile", \
|
||||
"%clang %openmp_flag %cflags %s -o %t" + libs))
|
||||
"%clang %openmp_flags %flags %s -o %t" + libs))
|
||||
config.substitutions.append(("%libomp-run", "%t"))
|
||||
config.substitutions.append(("%clangXX", config.test_cxx_compiler))
|
||||
config.substitutions.append(("%clang", config.test_compiler))
|
||||
config.substitutions.append(("%openmp_flag", config.test_openmp_flag))
|
||||
config.substitutions.append(("%cflags", config.test_cflags))
|
||||
config.substitutions.append(("%clang", config.test_c_compiler))
|
||||
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
|
||||
config.substitutions.append(("%flags", config.test_flags))
|
||||
|
||||
if config.has_ompt:
|
||||
config.substitutions.append(("FileCheck", config.test_filecheck))
|
||||
|
@ -1,10 +1,10 @@
|
||||
@AUTO_GEN_COMMENT@
|
||||
|
||||
config.test_compiler = "@LIBOMP_TEST_COMPILER@"
|
||||
config.test_cxx_compiler = "@LIBOMP_TEST_CXX_COMPILER@"
|
||||
config.test_filecheck = "@FILECHECK_EXECUTABLE@"
|
||||
config.test_openmp_flag = "@LIBOMP_TEST_OPENMP_FLAG@"
|
||||
config.test_extra_cflags = "@LIBOMP_TEST_CFLAGS@"
|
||||
config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@"
|
||||
config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@"
|
||||
config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
|
||||
config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@"
|
||||
config.test_extra_flags = "@OPENMP_TEST_FLAGS@"
|
||||
config.libomp_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
|
||||
config.library_dir = "@LIBOMP_LIBRARY_DIR@"
|
||||
config.omp_header_directory = "@LIBOMP_BINARY_DIR@/src"
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
// Note: We should compile the tool without -fopenmp as other tools developer
|
||||
// would do. Otherwise this test may pass for the wrong reasons on Darwin.
|
||||
// RUN: %clang %cflags -DTOOL -shared -fPIC %s -o %T/tool.so
|
||||
// RUN: %clang %flags -DTOOL -shared -fPIC %s -o %T/tool.so
|
||||
// 2. "introducing a dynamically-linked library that includes the tool’s definition of ompt_start_tool into the application’s address space"
|
||||
// 2.1 Link with tool during compilation
|
||||
// RUN: %libomp-compile -DCODE %T/tool.so && %libomp-run | FileCheck %s
|
||||
|
Loading…
x
Reference in New Issue
Block a user