Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 9107ad9

Browse files
author
George Karpenkov
committedOct 26, 2017
[Analyzer] [Tests] Consistently use exit codes. Use code=42 to signify different results
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316632 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent f19ada1 commit 9107ad9

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed
 

‎utils/analyzer/SATestBuild.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def getProjectMapPath():
7171
if not os.path.exists(ProjectMapPath):
7272
print "Error: Cannot find the Project Map file " + ProjectMapPath +\
7373
"\nRunning script for the wrong directory?"
74-
sys.exit(-1)
74+
sys.exit(1)
7575
return ProjectMapPath
7676

7777

@@ -97,7 +97,7 @@ def getSBOutputDirName(IsReferenceBuild):
9797
Clang = SATestUtils.which("clang", os.environ['PATH'])
9898
if not Clang:
9999
print "Error: cannot find 'clang' in PATH"
100-
sys.exit(-1)
100+
sys.exit(1)
101101

102102
# Number of jobs.
103103
Jobs = int(math.ceil(multiprocessing.cpu_count() * 0.75))
@@ -196,7 +196,7 @@ def downloadAndPatch(Dir, PBuildLogFile):
196196
if not os.path.exists(CachedSourceDirPath):
197197
print "Error: '%s' not found after download." % (
198198
CachedSourceDirPath)
199-
exit(-1)
199+
exit(1)
200200

201201
PatchedSourceDirPath = os.path.join(Dir, PatchedSourceDirName)
202202

@@ -225,7 +225,7 @@ def applyPatch(Dir, PBuildLogFile):
225225
shell=True)
226226
except:
227227
print "Error: Patch failed. See %s for details." % (PBuildLogFile.name)
228-
sys.exit(-1)
228+
sys.exit(1)
229229

230230

231231
def runScanBuild(Dir, SBOutputDir, PBuildLogFile):
@@ -236,7 +236,7 @@ def runScanBuild(Dir, SBOutputDir, PBuildLogFile):
236236
BuildScriptPath = os.path.join(Dir, BuildScript)
237237
if not os.path.exists(BuildScriptPath):
238238
print "Error: build script is not defined: %s" % BuildScriptPath
239-
sys.exit(-1)
239+
sys.exit(1)
240240

241241
AllCheckers = Checkers
242242
if 'SA_ADDITIONAL_CHECKERS' in os.environ:
@@ -473,7 +473,7 @@ def checkBuild(SBOutputDir):
473473
shutil.copyfileobj(FailLogI, SummaryLog)
474474

475475
print "Error: analysis failed. See ", SummaryPath
476-
sys.exit(-1)
476+
sys.exit(1)
477477

478478

479479
def runCmpResults(Dir, Strictness=0):
@@ -503,7 +503,10 @@ def runCmpResults(Dir, Strictness=0):
503503
RefList.remove(RefLogDir)
504504
NewList.remove(os.path.join(NewDir, LogFolderName))
505505

506-
assert(len(RefList) == len(NewList))
506+
if len(RefList) != len(NewList):
507+
print "Mismatch in number of results folders: %s vs %s" % (
508+
RefList, NewList)
509+
sys.exit(1)
507510

508511
# There might be more then one folder underneath - one per each scan-build
509512
# command (Ex: one for configure and one for make).
@@ -656,4 +659,4 @@ def testAll(IsReferenceBuild=False, Strictness=0):
656659
TestsPassed = testAll(IsReference, Strictness)
657660
if not TestsPassed:
658661
print "ERROR: Tests failed."
659-
sys.exit(-1)
662+
sys.exit(42)

‎utils/analyzer/SATestUpdateDiffs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def updateReferenceResults(ProjName, ProjBuildMode):
3232
if not os.path.exists(CreatedResultsPath):
3333
print >> sys.stderr, "New results not found, was SATestBuild.py "\
3434
"previously run?"
35-
sys.exit(-1)
35+
sys.exit(1)
3636

3737
# Remove reference results: in git, and then again for a good measure
3838
# with rm, as git might not remove things fully if there are empty
@@ -75,7 +75,7 @@ def main(argv):
7575
print >> sys.stderr, "Update static analyzer reference results based "\
7676
"\non the previous run of SATestBuild.py.\n"\
7777
"\nN.B.: Assumes that SATestBuild.py was just run"
78-
sys.exit(-1)
78+
sys.exit(1)
7979

8080
with SATestBuild.projectFileHandler() as f:
8181
for (ProjName, ProjBuildMode) in SATestBuild.iterateOverProjects(f):

0 commit comments

Comments
 (0)