summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-08-13 23:12:43 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-08-13 23:12:43 +0000
commit4fb8974a97cc95e76b5f1c5ac04dc97abc621366 (patch)
treeecb960ba6fb5b65a59538a34d6093d5e22010b42
parent09d5c6b600bdab633bffe2b2df25a7fbb8cad784 (diff)
[analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3
Current testing setup for analyzer tests with Z3 is rather inconvenient: There's no way to run the analyzer tests separately (I use LIT_FILTER=Analysis ninja check-clang, but a direct target is nicer). When Clang is built with Z3 support, there's no way to *not* run tests with Z3 solver, and this is often desired, as tests with Z3 solver take a very long time. This patch introduces two extra targets: - check-clang-analyzer - check-clang-analyzer-z3 which solve those problems. Differential Revision: https://reviews.llvm.org/D50594 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339629 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Analysis/analyzer_test.py7
-rw-r--r--test/Analysis/lit.local.cfg2
-rw-r--r--test/CMakeLists.txt25
-rw-r--r--test/lit.site.cfg.py.in2
4 files changed, 34 insertions, 2 deletions
diff --git a/test/Analysis/analyzer_test.py b/test/Analysis/analyzer_test.py
index 0aa2dbc1bb..03124333fe 100644
--- a/test/Analysis/analyzer_test.py
+++ b/test/Analysis/analyzer_test.py
@@ -4,6 +4,10 @@ import lit.TestRunner
# Custom format class for static analyzer tests
class AnalyzerTest(lit.formats.ShTest):
+ def __init__(self, execute_external, use_z3_solver=False):
+ super(AnalyzerTest, self).__init__(execute_external)
+ self.use_z3_solver = use_z3_solver
+
def execute(self, test, litConfig):
results = []
@@ -19,7 +23,8 @@ class AnalyzerTest(lit.formats.ShTest):
return results[-1]
# If z3 backend available, add an additional run line for it
- if test.config.clang_staticanalyzer_z3 == '1':
+ if self.use_z3_solver == '1':
+ assert(test.config.clang_staticanalyzer_z3 == '1')
results.append(self.executeWithAnalyzeSubstitution(
saved_test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3'))
diff --git a/test/Analysis/lit.local.cfg b/test/Analysis/lit.local.cfg
index a594c5dada..16021133f9 100644
--- a/test/Analysis/lit.local.cfg
+++ b/test/Analysis/lit.local.cfg
@@ -7,7 +7,7 @@ import site
site.addsitedir(os.path.dirname(__file__))
import analyzer_test
config.test_format = analyzer_test.AnalyzerTest(
- config.test_format.execute_external)
+ config.test_format.execute_external, config.use_z3_solver)
if not config.root.clang_staticanalyzer:
config.unsupported = True
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4951d86698..95225d80c5 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -88,8 +88,15 @@ endif ()
set(CLANG_TEST_PARAMS
clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+ USE_Z3_SOLVER=0
)
+set(ANALYZER_TEST_PARAMS
+ USE_Z3_SOLVER=0)
+
+set(ANALYZER_TEST_PARAMS_Z3
+ USE_Z3_SOLVER=1)
+
if( NOT CLANG_BUILT_STANDALONE )
list(APPEND CLANG_TEST_DEPS
llvm-config
@@ -126,6 +133,24 @@ add_lit_testsuite(check-clang "Running the Clang regression tests"
)
set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
+if (CLANG_ENABLE_STATIC_ANALYZER)
+ add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests"
+ ${CMAKE_CURRENT_BINARY_DIR}/Analysis
+ PARAMS ${ANALYZER_TEST_PARAMS}
+ DEPENDS ${CLANG_TEST_DEPS})
+ set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests")
+
+
+ if (CLANG_ANALYZER_WITH_Z3)
+ add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer tests, using Z3 as a solver"
+ ${CMAKE_CURRENT_BINARY_DIR}/Analysis
+ PARAMS ${ANALYZER_TEST_PARAMS_Z3}
+ DEPENDS ${CLANG_TEST_DEPS})
+ set_target_properties(check-clang-analyzer-z3 PROPERTIES FOLDER "Clang tests")
+ endif()
+
+endif()
+
add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
PARAMS ${CLANG_TEST_PARAMS}
DEPENDS ${CLANG_TEST_DEPS}
diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in
index 361d4e44d6..7bd8846dbd 100644
--- a/test/lit.site.cfg.py.in
+++ b/test/lit.site.cfg.py.in
@@ -26,6 +26,7 @@ config.enable_shared = @ENABLE_SHARED@
config.enable_backtrace = @ENABLE_BACKTRACES@
config.host_arch = "@HOST_ARCH@"
config.python_executable = "@PYTHON_EXECUTABLE@"
+config.use_z3_solver = "@USE_Z3_SOLVER@"
# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
@@ -34,6 +35,7 @@ try:
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
+ config.use_z3_solver = lit_config.params['USE_Z3_SOLVER']
except KeyError:
e = sys.exc_info()[1]
key, = e.args