Index: utils/analyzer/SATestBuild.py =================================================================== --- utils/analyzer/SATestBuild.py +++ utils/analyzer/SATestBuild.py @@ -255,7 +255,7 @@ sys.exit(1) -def runScanBuild(Dir, SBOutputDir, PBuildLogFile): +def runScanBuild(Args, Dir, SBOutputDir, PBuildLogFile): """ Build the project with scan-build by reading in the commands and prefixing them with the scan-build options. @@ -281,9 +281,11 @@ ("stable-report-filename", "true"), ("serialize-stats", "true"), ] - - SBOptions += "-analyzer-config '%s' " % ( - ",".join("%s=%s" % (key, value) for (key, value) in AnalyzerConfig)) + AnalyzerConfigSerialized = ",".join( + "%s=%s" % (key, value) for (key, value) in AnalyzerConfig) + if Args.extra_args: + AnalyzerConfigSerialized += "," + Args.extra_args + SBOptions += "-analyzer-config '%s' " % AnalyzerConfigSerialized # Always use ccc-analyze to ensure that we can locate the failures # directory. @@ -407,7 +409,7 @@ check_call(RmCommand, shell=True) -def buildProject(Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild): +def buildProject(Args, Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild): TBegin = time.time() BuildLogPath = getBuildLogPath(SBOutputDir) @@ -431,7 +433,7 @@ if (ProjectBuildMode == 1): downloadAndPatch(Dir, PBuildLogFile) runCleanupScript(Dir, PBuildLogFile) - runScanBuild(Dir, SBOutputDir, PBuildLogFile) + runScanBuild(Args, Dir, SBOutputDir, PBuildLogFile) else: runAnalyzePreprocessed(Dir, SBOutputDir, ProjectBuildMode) @@ -628,12 +630,13 @@ class TestProjectThread(threading.Thread): - def __init__(self, TasksQueue, ResultsDiffer, FailureFlag): + def __init__(self, Args, TasksQueue, ResultsDiffer, FailureFlag): """ :param ResultsDiffer: Used to signify that results differ from the canonical ones. :param FailureFlag: Used to signify a failure during the run. """ + self.Args = Args self.TasksQueue = TasksQueue self.ResultsDiffer = ResultsDiffer self.FailureFlag = FailureFlag @@ -649,7 +652,7 @@ Logger = logging.getLogger(ProjArgs[0]) Local.stdout = StreamToLogger(Logger, logging.INFO) Local.stderr = StreamToLogger(Logger, logging.ERROR) - if not testProject(*ProjArgs): + if not testProject(Args, *ProjArgs): self.ResultsDiffer.set() self.TasksQueue.task_done() except: @@ -657,7 +660,7 @@ raise -def testProject(ID, ProjectBuildMode, IsReferenceBuild=False, Strictness=0): +def testProject(Args, ID, ProjectBuildMode, IsReferenceBuild=False, Strictness=0): """ Test a given project. :return TestsPassed: Whether tests have passed according @@ -675,7 +678,7 @@ RelOutputDir = getSBOutputDirName(IsReferenceBuild) SBOutputDir = os.path.join(Dir, RelOutputDir) - buildProject(Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild) + buildProject(Args, Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild) checkBuild(SBOutputDir) @@ -719,17 +722,17 @@ " (single file), 1 (project), or 2(single file c++11)." raise Exception() -def singleThreadedTestAll(ProjectsToTest): +def singleThreadedTestAll(Args, ProjectsToTest): """ Run all projects. :return: whether tests have passed. """ Success = True for ProjArgs in ProjectsToTest: - Success &= testProject(*ProjArgs) + Success &= testProject(Args, *ProjArgs) return Success -def multiThreadedTestAll(ProjectsToTest, Jobs): +def multiThreadedTestAll(Args, ProjectsToTest, Jobs): """ Run each project in a separate thread. @@ -747,7 +750,7 @@ FailureFlag = threading.Event() for i in range(Jobs): - T = TestProjectThread(TasksQueue, ResultsDiffer, FailureFlag) + T = TestProjectThread(Args, TasksQueue, ResultsDiffer, FailureFlag) T.start() # Required to handle Ctrl-C gracefully. @@ -772,9 +775,9 @@ Args.regenerate, Args.strictness)) if Args.jobs <= 1: - return singleThreadedTestAll(ProjectsToTest) + return singleThreadedTestAll(Args, ProjectsToTest) else: - return multiThreadedTestAll(ProjectsToTest, Args.jobs) + return multiThreadedTestAll(Args, ProjectsToTest, Args.jobs) if __name__ == '__main__': @@ -791,6 +794,9 @@ Parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=0, help='Number of projects to test concurrently') + Parser.add_argument('--extra-analyzer-args', dest='extra_args', + type=str, default="", + help="Extra arguments to add to -analyzer-config") Args = Parser.parse_args() TestsPassed = testAll(Args)