Skip to content

Commit

Permalink
Build and run isl_test as part of check-polly
Browse files Browse the repository at this point in the history
Running isl tests is important to gain confidence that the isl build we created
works as expected. Besides the actual isl tests, there are also isl AST
generation tests shipped with isl. This change only adds support for the isl
unit tests. AST generation test support is left for a later commit.

There is a choice to run tests directly through the build system or in the
context of lit. We choose to run tests as part of lit to as this allows us to
easily set environment variables, print output only on error and generally run
the tests directly from the lit command.

Reviewers: brad.king, Meinersbur

Subscribers: modocache, brad.king, pollydev, beanz, llvm-commits, mgorny

Differential Revision: https://reviews.llvm.org/D25155

llvm-svn: 283245
  • Loading branch information
tobiasgrosser committed Oct 4, 2016
1 parent c43fa4f commit e84ee85
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 1 deletion.
16 changes: 15 additions & 1 deletion polly/lib/External/CMakeLists.txt
Expand Up @@ -261,25 +261,39 @@ add_polly_library(PollyISL
${ISL_FILES}
)

add_executable(polly-isl-test
isl/isl_test.c
)

target_link_libraries(polly-isl-test
PollyISL
)

if (MSVC)
# Disable common warnings; ideally, they should be fixed upstream
target_compile_options(PollyISL PRIVATE
set(DISABLE_WARNING_FLAGS
-wd4018 # 'expression' : signed/unsigned mismatch
-wd4090 # 'operation' : different 'modifier' qualifiers
-wd4200 # nonstandard extension used: zero-sized array in struct/union
-wd4201 # nonstandard extension used: nameless struct/union
-wd4334 # 'operator': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
)
target_compile_options(PollyISL PRIVATE ${DISABLE_WARNING_FLAGS})
target_compile_options(polly-isl-test PRIVATE ${DISABLE_WARNING_FLAGS})
endif ()

# ISL requires at least C99 to compile. gcc < 5.0 use -std=gnu89 as default.
target_enable_c99(PollyISL)
target_enable_c99(polly-isl-test)

# Disable warnings which should be coped with upstream for isl and imath.
if (NOT MSVC)
set_target_properties(PollyISL PROPERTIES
COMPILE_FLAGS "-w"
)
set_target_properties(polly-isl-test PROPERTIES
COMPILE_FLAGS "-w"
)
endif ()

set(PET_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pet")
Expand Down
23 changes: 23 additions & 0 deletions polly/test/CMakeLists.txt
Expand Up @@ -97,6 +97,18 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
COMMENT "Running Polly unit tests")
set_target_properties(check-polly-unittests PROPERTIES FOLDER "Polly")
endif ()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/UnitIsl/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg)

add_custom_target(check-polly-isl
command ${LLVM_LIT}
--param polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg
--param build_config=${CMAKE_CFG_INTDIR}
-sv ${POLLY_TEST_EXTRA_ARGS}
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS polly-isl-test
COMMENT "Running isl unit tests")
endif()

else (NOT DEFINED LLVM_MAIN_SRC_DIR)
Expand Down Expand Up @@ -141,6 +153,17 @@ else (NOT DEFINED LLVM_MAIN_SRC_DIR)
set_target_properties(check-polly-unittests PROPERTIES FOLDER "Polly")
endif ()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/UnitIsl/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg)

add_lit_testsuite(check-polly-isl "Running isl unit tests only"
${CMAKE_CURRENT_BINARY_DIR}/UnitIsl
PARAMS polly_site_config=${CMAKE_CURRENT_BINARY_DIR}/UnitIsl/lit.site.cfg
DEPENDS polly-isl-test
)
set_target_properties(check-polly-isl PROPERTIES FOLDER "Polly")

# Run polly-check-format as part of polly-check only if we are compiling with
# clang, so clang-format is available.
# if (TARGET clang-format) would be preferable, but this target is only added
Expand Down
1 change: 1 addition & 0 deletions polly/test/UnitIsl/isl_test.sh
@@ -0,0 +1 @@
; RUN: polly-isl-test
46 changes: 46 additions & 0 deletions polly/test/UnitIsl/lit.cfg
@@ -0,0 +1,46 @@
# -*clang- Python -*-

import os
import platform
import re

import lit.formats
import lit.util

# Configuration file for the 'lit' test runner.

# name: The name of this test suite.
config.name = 'Polly - isl unit tests'

# testFormat: The test format to use to interpret tests.
#
# For now we require '&&' between commands, until they get globally killed and
# the test runner updated.
execute_external = platform.system() != 'Windows'
config.test_format = lit.formats.ShTest(execute_external)

# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.sh']

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
polly_obj_root = getattr(config, 'polly_obj_root', None)
if polly_obj_root is not None:
config.test_exec_root = os.path.join(polly_obj_root, 'test')

# Set llvm_{src,obj}_root for use by others.
config.llvm_src_root = getattr(config, 'llvm_src_root', None)
config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)

# Tweak the PATH to include the tools dir and the scripts dir.
if polly_obj_root is not None:
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
if not llvm_tools_dir:
lit_config.fatal('No LLVM tools dir set!')
path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
config.environment['PATH'] = path

config.environment['srcdir'] = os.path.join(config.test_source_root,
'../../lib/External/isl')
9 changes: 9 additions & 0 deletions polly/test/UnitIsl/lit.site.cfg.in
@@ -0,0 +1,9 @@
@LIT_SITE_CFG_IN_HEADER@

import sys

config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.polly_obj_root = "@POLLY_BINARY_DIR@"

# Let the main config do the real work.
lit_config.load_config(config, "@POLLY_SOURCE_DIR@/test/UnitIsl/lit.cfg")

0 comments on commit e84ee85

Please sign in to comment.