mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
Refactored Regression.py:
Will more easily accept future additional argument parameters, Appends the parameter to the folder names
This commit is contained in:
parent
b3b4162560
commit
61c4a2b15c
@ -34,6 +34,8 @@ def testAddImageIngest(inFile, ignoreUnalloc):
|
|||||||
|
|
||||||
# Set up case directory path
|
# Set up case directory path
|
||||||
testCaseName = imageName(inFile)
|
testCaseName = imageName(inFile)
|
||||||
|
if ignoreUnalloc:
|
||||||
|
testCaseName+="-u"
|
||||||
if os.path.exists(os.path.join(outDir,testCaseName)):
|
if os.path.exists(os.path.join(outDir,testCaseName)):
|
||||||
shutil.rmtree(os.path.join(outDir,testCaseName))
|
shutil.rmtree(os.path.join(outDir,testCaseName))
|
||||||
os.makedirs(os.path.join(outDir,testCaseName))
|
os.makedirs(os.path.join(outDir,testCaseName))
|
||||||
@ -101,13 +103,14 @@ def getImageSize(inFile):
|
|||||||
size += os.path.getsize(inFile)
|
size += os.path.getsize(inFile)
|
||||||
return size
|
return size
|
||||||
|
|
||||||
def testCompareToGold(inFile):
|
def testCompareToGold(inFile, ignore):
|
||||||
print "-----------------------------------------------"
|
print "-----------------------------------------------"
|
||||||
print "Comparing results for " + inFile + " with gold."
|
print "Comparing results for " + inFile + " with gold."
|
||||||
|
|
||||||
name = imageName(inFile)
|
name = imageName(inFile)
|
||||||
|
if ignore:
|
||||||
|
name += ("-u")
|
||||||
cwd = wgetcwd()
|
cwd = wgetcwd()
|
||||||
|
|
||||||
goldFile = os.path.join("./",goldDir,name,"standard.db")
|
goldFile = os.path.join("./",goldDir,name,"standard.db")
|
||||||
testFile = os.path.join("./",outDir,name,"AutopsyTestCase","autopsy.db")
|
testFile = os.path.join("./",outDir,name,"AutopsyTestCase","autopsy.db")
|
||||||
if os.path.isfile(goldFile) == False:
|
if os.path.isfile(goldFile) == False:
|
||||||
@ -163,26 +166,32 @@ def testCompareToGold(inFile):
|
|||||||
else:
|
else:
|
||||||
print("Object counts match!")
|
print("Object counts match!")
|
||||||
|
|
||||||
def clearGoldDir(inFile):
|
def clearGoldDir(inFile, ignore):
|
||||||
cwd = wgetcwd()
|
cwd = wgetcwd()
|
||||||
inFile = imageName(inFile)
|
inFile = imageName(inFile)
|
||||||
|
if ignore:
|
||||||
|
inFile += "-u"
|
||||||
if os.path.exists(os.path.join(cwd,goldDir,inFile)):
|
if os.path.exists(os.path.join(cwd,goldDir,inFile)):
|
||||||
shutil.rmtree(os.path.join(cwd,goldDir,inFile))
|
shutil.rmtree(os.path.join(cwd,goldDir,inFile))
|
||||||
os.makedirs(os.path.join(cwd,goldDir,inFile))
|
os.makedirs(os.path.join(cwd,goldDir,inFile))
|
||||||
|
|
||||||
def copyTestToGold(inFile):
|
def copyTestToGold(inFile, ignore):
|
||||||
print "------------------------------------------------"
|
print "------------------------------------------------"
|
||||||
print "Recreating gold standard from results."
|
print "Recreating gold standard from results."
|
||||||
inFile = imageName(inFile)
|
inFile = imageName(inFile)
|
||||||
|
if ignore:
|
||||||
|
inFile += "-u"
|
||||||
cwd = wgetcwd()
|
cwd = wgetcwd()
|
||||||
goldFile = os.path.join("./",goldDir,inFile,"standard.db")
|
goldFile = os.path.join("./",goldDir,inFile,"standard.db")
|
||||||
testFile = os.path.join("./",outDir,inFile,"AutopsyTestCase","autopsy.db")
|
testFile = os.path.join("./",outDir,inFile,"AutopsyTestCase","autopsy.db")
|
||||||
shutil.copy(testFile, goldFile)
|
shutil.copy(testFile, goldFile)
|
||||||
|
|
||||||
def copyReportToGold(inFile):
|
def copyReportToGold(inFile, ignore):
|
||||||
print "------------------------------------------------"
|
print "------------------------------------------------"
|
||||||
print "Recreating gold report from results."
|
print "Recreating gold report from results."
|
||||||
inFile = imageName(inFile)
|
inFile = imageName(inFile)
|
||||||
|
if ignore:
|
||||||
|
inFile += "-u"
|
||||||
cwd = wgetcwd()
|
cwd = wgetcwd()
|
||||||
goldReport = os.path.join("./",goldDir,inFile,"report.html")
|
goldReport = os.path.join("./",goldDir,inFile,"report.html")
|
||||||
testReportPath = os.path.join("./",outDir,inFile,"AutopsyTestCase","Reports")
|
testReportPath = os.path.join("./",outDir,inFile,"AutopsyTestCase","Reports")
|
||||||
@ -199,10 +208,12 @@ def copyReportToGold(inFile):
|
|||||||
else:
|
else:
|
||||||
shutil.copy(testReport, goldReport)
|
shutil.copy(testReport, goldReport)
|
||||||
|
|
||||||
def testCompareReports(inFile):
|
def testCompareReports(inFile, ignore):
|
||||||
print "------------------------------------------------"
|
print "------------------------------------------------"
|
||||||
print "Comparing report to golden report."
|
print "Comparing report to golden report."
|
||||||
name = imageName(inFile)
|
name = imageName(inFile)
|
||||||
|
if ignore:
|
||||||
|
name += "-u"
|
||||||
goldReport = os.path.join("./",goldDir,name,"report.html")
|
goldReport = os.path.join("./",goldDir,name,"report.html")
|
||||||
testReportPath = os.path.join("./",outDir,name,"AutopsyTestCase","Reports")
|
testReportPath = os.path.join("./",outDir,name,"AutopsyTestCase","Reports")
|
||||||
# Because Java adds a timestamp to the report file, one can't call it
|
# Because Java adds a timestamp to the report file, one can't call it
|
||||||
@ -293,25 +304,26 @@ def wabspath(inFile):
|
|||||||
out,err = proc.communicate()
|
out,err = proc.communicate()
|
||||||
return out.rstrip()
|
return out.rstrip()
|
||||||
|
|
||||||
def copyLogs(inFile):
|
def copyLogs(inFile, ignore):
|
||||||
|
if ignore:
|
||||||
|
name = imageName(inFile)+"-u"
|
||||||
logDir = os.path.join("..","build","test","qa-functional","work","userdir0","var","log")
|
logDir = os.path.join("..","build","test","qa-functional","work","userdir0","var","log")
|
||||||
shutil.copytree(logDir,os.path.join(outDir,imageName(inFile),"logs"))
|
shutil.copytree(logDir,os.path.join(outDir,name,"logs"))
|
||||||
|
|
||||||
def testFile(image, type):
|
def testFile(image, rebuild, ignore):
|
||||||
if imageType(image) != ImgType.UNKNOWN:
|
if imageType(image) != ImgType.UNKNOWN:
|
||||||
if type == 2:
|
if ignore:
|
||||||
testAddImageIngest(image, True)
|
testAddImageIngest(image, True)
|
||||||
else:
|
else:
|
||||||
testAddImageIngest(image, False)
|
testAddImageIngest(image, False)
|
||||||
#print imageName(image)
|
copyLogs(image, ignore)
|
||||||
copyLogs(image)
|
if rebuild:
|
||||||
if type == 1:
|
clearGoldDir(image, ignore)
|
||||||
clearGoldDir(image)
|
copyTestToGold(image, ignore)
|
||||||
copyTestToGold(image)
|
copyReportToGold(image, ignore)
|
||||||
copyReportToGold(image)
|
|
||||||
else:
|
else:
|
||||||
testCompareToGold(image)
|
testCompareToGold(image, ignore)
|
||||||
testCompareReports(image)
|
testCompareReports(image, ignore)
|
||||||
|
|
||||||
def usage() :
|
def usage() :
|
||||||
usage = "\
|
usage = "\
|
||||||
@ -331,7 +343,6 @@ def main():
|
|||||||
rebuild = False
|
rebuild = False
|
||||||
single = False
|
single = False
|
||||||
ignore = False
|
ignore = False
|
||||||
type = 0
|
|
||||||
test = True
|
test = True
|
||||||
argi = 1
|
argi = 1
|
||||||
while argi < len(sys.argv):
|
while argi < len(sys.argv):
|
||||||
@ -342,11 +353,9 @@ def main():
|
|||||||
image = sys.argv[argi]
|
image = sys.argv[argi]
|
||||||
print "Running on single image: " + image
|
print "Running on single image: " + image
|
||||||
elif (arg == "--rebuild") or (arg == "-r"):
|
elif (arg == "--rebuild") or (arg == "-r"):
|
||||||
type = 1
|
|
||||||
rebuild = True
|
rebuild = True
|
||||||
print "Running in REBUILD mode"
|
print "Running in REBUILD mode"
|
||||||
elif (arg == "--nounalloc") or (arg == "-u"):
|
elif (arg == "--nounalloc") or (arg == "-u"):
|
||||||
type = 2
|
|
||||||
ignore = True
|
ignore = True
|
||||||
print "Ignoring unallocated space"
|
print "Ignoring unallocated space"
|
||||||
else:
|
else:
|
||||||
@ -354,10 +363,10 @@ def main():
|
|||||||
print usage()
|
print usage()
|
||||||
argi+=1
|
argi+=1
|
||||||
if single:
|
if single:
|
||||||
testFile(image, type)
|
testFile(image, rebuild, ignore)
|
||||||
elif test:
|
elif test:
|
||||||
for inFile in os.listdir(inDir):
|
for inFile in os.listdir(inDir):
|
||||||
testFile(os.path.join(inDir,inFile), type)
|
testFile(os.path.join(inDir,inFile), rebuild, ignore)
|
||||||
|
|
||||||
if hadErrors == True:
|
if hadErrors == True:
|
||||||
print "**********************************************"
|
print "**********************************************"
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user