summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/test
diff options
context:
space:
mode:
authorJonas Hahnfeld <hahnjo@hahnjo.de>2017-11-29 19:31:52 +0000
committerJonas Hahnfeld <hahnjo@hahnjo.de>2017-11-29 19:31:52 +0000
commit18bec60bc2d5c6140cb11c459dc6055e2e8884c9 (patch)
treebebca38a2a0d527f55e749426126b61d275d9941 /openmp/runtime/test
parent5af381acade8a285ff2e3c8c8e6018d5432116d3 (diff)
downloadbcm5719-llvm-18bec60bc2d5c6140cb11c459dc6055e2e8884c9.tar.gz
bcm5719-llvm-18bec60bc2d5c6140cb11c459dc6055e2e8884c9.zip
[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
Diffstat (limited to 'openmp/runtime/test')
-rw-r--r--openmp/runtime/test/CMakeLists.txt79
-rw-r--r--openmp/runtime/test/lit.cfg24
-rw-r--r--openmp/runtime/test/lit.site.cfg.in10
-rw-r--r--openmp/runtime/test/ompt/loadtool/tool_available.c2
4 files changed, 20 insertions, 95 deletions
diff --git a/openmp/runtime/test/CMakeLists.txt b/openmp/runtime/test/CMakeLists.txt
index d384341d715..8f367c56b9d 100644
--- a/openmp/runtime/test/CMakeLists.txt
+++ b/openmp/runtime/test/CMakeLists.txt
@@ -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)
-
diff --git a/openmp/runtime/test/lit.cfg b/openmp/runtime/test/lit.cfg
index d8c3bd993bc..f4b017e4fc0 100644
--- a/openmp/runtime/test/lit.cfg
+++ b/openmp/runtime/test/lit.cfg
@@ -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))
diff --git a/openmp/runtime/test/lit.site.cfg.in b/openmp/runtime/test/lit.site.cfg.in
index 135e01a7cff..729174ae79e 100644
--- a/openmp/runtime/test/lit.site.cfg.in
+++ b/openmp/runtime/test/lit.site.cfg.in
@@ -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"
diff --git a/openmp/runtime/test/ompt/loadtool/tool_available.c b/openmp/runtime/test/ompt/loadtool/tool_available.c
index d148fb7fa96..a6a79fe062f 100644
--- a/openmp/runtime/test/ompt/loadtool/tool_available.c
+++ b/openmp/runtime/test/ompt/loadtool/tool_available.c
@@ -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
OpenPOWER on IntegriCloud