diff options
| author | Reid Kleckner <rnk@google.com> | 2017-04-05 18:56:48 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2017-04-05 18:56:48 +0000 |
| commit | 2ae37c15c3fdd202deef5fa3b2fd0da4ecc6c7d8 (patch) | |
| tree | bc95abf7fddb4f5893eab0a968de9faf78a64005 | |
| parent | 02185c04b2334d962c2a8918c16cf3d5182c5fbb (diff) | |
| download | bcm5719-llvm-2ae37c15c3fdd202deef5fa3b2fd0da4ecc6c7d8.tar.gz bcm5719-llvm-2ae37c15c3fdd202deef5fa3b2fd0da4ecc6c7d8.zip | |
[lit] Fix Analysis test format pickling error
Move the test format into a standalone .py file and add it to the site
module search path. This allows us to run the test on Windows, and it
makes it compatible with the multiprocessing.Pool lit test execution
strategy.
I think this test was only passing everywhere else because
multiprocessing uses 'fork' to spawn workers, so the test format never
needs to be pickled.
llvm-svn: 299577
| -rw-r--r-- | clang/test/Analysis/analyzer_test.py | 28 | ||||
| -rw-r--r-- | clang/test/Analysis/lit.local.cfg | 37 |
2 files changed, 36 insertions, 29 deletions
diff --git a/clang/test/Analysis/analyzer_test.py b/clang/test/Analysis/analyzer_test.py new file mode 100644 index 00000000000..58df11a4ba4 --- /dev/null +++ b/clang/test/Analysis/analyzer_test.py @@ -0,0 +1,28 @@ +import lit.formats +import lit.TestRunner + +# Custom format class for static analyzer tests +class AnalyzerTest(lit.formats.ShTest): + + def execute(self, test, litConfig): + result = self.executeWithAnalyzeSubstitution( + test, litConfig, '-analyzer-constraints=range') + + if result.code == lit.Test.FAIL: + return result + + # If z3 backend available, add an additional run line for it + if test.config.clang_staticanalyzer_z3 == '1': + result = self.executeWithAnalyzeSubstitution( + test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3') + + return result + + def executeWithAnalyzeSubstitution(self, test, litConfig, substitution): + saved_substitutions = list(test.config.substitutions) + test.config.substitutions.append(('%analyze', substitution)) + result = lit.TestRunner.executeShTest(test, litConfig, + self.execute_external) + test.config.substitutions = saved_substitutions + + return result diff --git a/clang/test/Analysis/lit.local.cfg b/clang/test/Analysis/lit.local.cfg index 563d4188ab3..a594c5dada5 100644 --- a/clang/test/Analysis/lit.local.cfg +++ b/clang/test/Analysis/lit.local.cfg @@ -1,34 +1,13 @@ -import lit.TestRunner -import sys +# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: -# Custom format class for static analyzer tests -class AnalyzerTest(lit.formats.ShTest, object): +import site - def execute(self, test, litConfig): - result = self.executeWithAnalyzeSubstitution(test, litConfig, '-analyzer-constraints=range') - - if result.code == lit.Test.FAIL: - return result - - # If z3 backend available, add an additional run line for it - if test.config.clang_staticanalyzer_z3 == '1': - result = self.executeWithAnalyzeSubstitution(test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3') - - return result - - def executeWithAnalyzeSubstitution(self, test, litConfig, substitution): - saved_substitutions = list(test.config.substitutions) - test.config.substitutions.append(('%analyze', substitution)) - result = lit.TestRunner.executeShTest(test, litConfig, self.execute_external) - test.config.substitutions = saved_substitutions - - return result - -# This results in a pickling-related failure on Windows -if (not sys.platform in ['win32']): - config.test_format = AnalyzerTest(config.test_format.execute_external) -else: - config.substitutions.append(('%analyze', '-analyzer-constraints=range')) +# Load the custom analyzer test format, which runs the test again with Z3 if it +# is available. +site.addsitedir(os.path.dirname(__file__)) +import analyzer_test +config.test_format = analyzer_test.AnalyzerTest( + config.test_format.execute_external) if not config.root.clang_staticanalyzer: config.unsupported = True |

