summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2015-07-08 18:39:31 +0000
committerGabor Horvath <xazax.hun@gmail.com>2015-07-08 18:39:31 +0000
commitc3177f2ed4c68b6b1b7c6f1b0aae91275b5e4f38 (patch)
treeceff789d53929ada08961226fc127aa373a359e1
parent25bf8cb3c0e3c41231289a6ff0a37b6d49b24011 (diff)
downloadbcm5719-llvm-c3177f2ed4c68b6b1b7c6f1b0aae91275b5e4f38.tar.gz
bcm5719-llvm-c3177f2ed4c68b6b1b7c6f1b0aae91275b5e4f38.zip
[Static Analyzer] Make the paths relative from the project root when generating reference results in the test suite.
llvm-svn: 241706
-rwxr-xr-xclang/utils/analyzer/CmpRuns.py6
-rwxr-xr-xclang/utils/analyzer/SATestBuild.py15
2 files changed, 17 insertions, 4 deletions
diff --git a/clang/utils/analyzer/CmpRuns.py b/clang/utils/analyzer/CmpRuns.py
index a1f7a5649c5..ce5ddfb3add 100755
--- a/clang/utils/analyzer/CmpRuns.py
+++ b/clang/utils/analyzer/CmpRuns.py
@@ -37,7 +37,7 @@ import CmpRuns
class SingleRunInfo:
def __init__(self, path, root="", verboseLog=None):
self.path = path
- self.root = root
+ self.root = root.rstrip("/\\")
self.verboseLog = verboseLog
class AnalysisDiagnostic:
@@ -50,8 +50,8 @@ class AnalysisDiagnostic:
def getFileName(self):
root = self._report.run.root
fileName = self._report.files[self._loc['file']]
- if fileName.startswith(root) :
- return fileName[len(root):]
+ if fileName.startswith(root) and len(root) > 0:
+ return fileName[len(root)+1:]
return fileName
def getLine(self):
diff --git a/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py
index 20839c24e18..2d91ba41e24 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -16,6 +16,7 @@ Repository Directory structure:
- Project Dir2
- ReferenceOutput
..
+Note that the build tree must be inside the project dir.
To test the build of the analyzer one would:
- Copy over a copy of the Repository Directory. (TODO: Prefer to ensure that
@@ -337,6 +338,18 @@ def buildProject(Dir, SBOutputDir, ProjectBuildMode, IsReferenceBuild):
if IsReferenceBuild :
runCleanupScript(Dir, PBuildLogFile)
+
+ # Make the absolute paths relative in the reference results.
+ for (DirPath, Dirnames, Filenames) in os.walk(SBOutputDir):
+ for F in Filenames:
+ if (not F.endswith('plist')):
+ continue
+ Plist = os.path.join(DirPath, F)
+ Data = plistlib.readPlist(Plist)
+ Paths = [SourceFile[len(Dir)+1:] if SourceFile.startswith(Dir)\
+ else SourceFile for SourceFile in Data['files']]
+ Data['files'] = Paths
+ plistlib.writePlist(Data, Plist)
finally:
PBuildLogFile.close()
@@ -450,7 +463,7 @@ def runCmpResults(Dir, Strictness = 0):
print " Comparing Results: %s %s" % (RefDir, NewDir)
DiffsPath = os.path.join(NewDir, DiffsSummaryFileName)
- Opts = CmpRuns.CmpOptions(DiffsPath)
+ Opts = CmpRuns.CmpOptions(DiffsPath, "", Dir)
# Discard everything coming out of stdout (CmpRun produces a lot of them).
OLD_STDOUT = sys.stdout
sys.stdout = Discarder()
OpenPOWER on IntegriCloud