Author: rnk Date: Wed Apr 5 13:56:48 2017 New Revision: 299577 URL: http://llvm.org/viewvc/llvm-project?rev=299577&view=rev Log: [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. Added: cfe/trunk/test/Analysis/analyzer_test.py Modified: cfe/trunk/test/Analysis/lit.local.cfg Added: cfe/trunk/test/Analysis/analyzer_test.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer_test.py?rev=299577&view=auto ============================================================================== --- cfe/trunk/test/Analysis/analyzer_test.py (added) +++ cfe/trunk/test/Analysis/analyzer_test.py Wed Apr 5 13:56:48 2017 @@ -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 Modified: cfe/trunk/test/Analysis/lit.local.cfg URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=299577&r1=299576&r2=299577&view=diff ============================================================================== --- cfe/trunk/test/Analysis/lit.local.cfg (original) +++ cfe/trunk/test/Analysis/lit.local.cfg Wed Apr 5 13:56:48 2017 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits