Reid Kleckner | 2ae37c1 | 2017-04-05 18:56:48 +0000 | [diff] [blame^] | 1 | import lit.formats |
| 2 | import lit.TestRunner |
| 3 | |
| 4 | # Custom format class for static analyzer tests |
| 5 | class AnalyzerTest(lit.formats.ShTest): |
| 6 | |
| 7 | def execute(self, test, litConfig): |
| 8 | result = self.executeWithAnalyzeSubstitution( |
| 9 | test, litConfig, '-analyzer-constraints=range') |
| 10 | |
| 11 | if result.code == lit.Test.FAIL: |
| 12 | return result |
| 13 | |
| 14 | # If z3 backend available, add an additional run line for it |
| 15 | if test.config.clang_staticanalyzer_z3 == '1': |
| 16 | result = self.executeWithAnalyzeSubstitution( |
| 17 | test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3') |
| 18 | |
| 19 | return result |
| 20 | |
| 21 | def executeWithAnalyzeSubstitution(self, test, litConfig, substitution): |
| 22 | saved_substitutions = list(test.config.substitutions) |
| 23 | test.config.substitutions.append(('%analyze', substitution)) |
| 24 | result = lit.TestRunner.executeShTest(test, litConfig, |
| 25 | self.execute_external) |
| 26 | test.config.substitutions = saved_substitutions |
| 27 | |
| 28 | return result |