From ffb08c7c81e680fc905b8746ef8b7862244e7dea Mon Sep 17 00:00:00 2001 From: dhurd Date: Mon, 23 Jul 2012 09:54:33 -0400 Subject: [PATCH 1/5] Updated regression test python script to match NF. --- Testing/script/regression.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Testing/script/regression.py b/Testing/script/regression.py index 236f927e91..d13f8dbc0e 100644 --- a/Testing/script/regression.py +++ b/Testing/script/regression.py @@ -124,7 +124,7 @@ def getImageSize(inFile, list): size += os.path.getsize(inFile) return size -def testCompareToGold(inFile, ignoreUnalloc): +def testCompareToGold(inFile, ignoreUnalloc, list): print "-----------------------------------------------" print "Comparing results for " + inFile + " with gold." @@ -416,7 +416,7 @@ def main(): elif (arg == "--rebuild") or (arg == "-r"): #check for rebuild flag rebuild = True print "Running in REBUILD mode" - elif (arg == "--ponies") or (arg == "-p"): #check for ignore unallocated space flag + elif (arg == "-u"): #check for ignore unallocated space flag ignoreUnalloc = True print "Ignoring unallocated space" elif (arg == "--ignore") or (arg == "-i"): @@ -468,4 +468,4 @@ def main(): print("\t%s" % errString) if __name__ == "__main__": - main() + main() \ No newline at end of file From bb66169509666852a1bc94485c83ef958a3e88e4 Mon Sep 17 00:00:00 2001 From: 0xNF Date: Mon, 23 Jul 2012 11:22:30 -0400 Subject: [PATCH 2/5] Fixed some bugs in regression.py the single file command is now -f, changed from -i --- Testing/script/regression.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Testing/script/regression.py b/Testing/script/regression.py index d1481ffeb9..ff4d292f2e 100644 --- a/Testing/script/regression.py +++ b/Testing/script/regression.py @@ -11,19 +11,21 @@ import xml from xml.dom.minidom import parse, parseString -# Last modified 7/17/12 @5pm -# Usage: ./regression.py [-s FILE] OR [-l CONFIG] [OPTIONS] +# Last modified 7/23/12 @11:30am +# Usage: ./regression.py [-f FILE] OR [-l CONFIG] [OPTIONS] # Run the RegressionTest.java file, and compare the result with a gold standard -# When the -i flag is set, this script only tests the image given by FILE. +# When the -f flag is set, this script only tests the image given by FILE. # An indexed NSRL database is expected at ./input/nsrl.txt-md5.idx, # and an indexed notable hash database at ./input/notablehashes.txt-md5.idx # In addition, any keywords to search for must be in ./input/notablekeywords.xml # When the -l flag is set, the script looks for a config.xml file of the given name -# where images are stored. For usage notes please see the example "config.xml" in +# where images are stored. The above input files can be outsourced to different locations +# from the config.xml. For usage notes please see the example "config.xml" in # the /script folder. # Options: # -r, --rebuild Rebuild the gold standards from the test results for each image -# -i, --ignore Ignores unallocated space when ingesting. Faster, but less accurate results. +# -i, --ignore Ignores the ./input directory when searching for files +# -u, --unallocated Ignores unallocated space when ingesting. Faster, but less accurate results. hadErrors = False # If any of the tests failed @@ -119,8 +121,8 @@ def getImageSize(inFile, list): filename = os.path.splitext(files)[0] if filename == name: filepath = os.path.join(path, files) - if not os.path.samefile(filepath, inFile): - size += os.path.getsize(filepath) + if not os.path.samefile(filepath, inFile): + size += os.path.getsize(filepath) size += os.path.getsize(inFile) return size @@ -365,19 +367,22 @@ def testFile(image, rebuild, ignoreUnalloc, list): def usage(): usage = "\ - Usage: ./regression.py [-s FILE] [OPTIONS] \n\n\ + Usage: ./regression.py [-f FILE] [OPTIONS] \n\n\ Run the RegressionTest.java file, and compare the result with a gold standard \n\n\ - When the -i flag is set, this script only tests the image given by FILE.\n\ + When the -f flag is set, this script only tests the image given by FILE.\n\ By default, it tests every image in ./input/\n\n\ An indexed NSRL database is expected at ./input/nsrl.txt-md5.idx,\n\ and an indexed notable hash database at ./input/notablehashes.txt-md5.idx\n\ In addition, any keywords to search for must be in ./input/notablekeywords.xml\n\n\ When the -l flag is set, the script looks for a config.xml file of the given name\n\ - where images are stored. For usage notes please see the example config.xml in\n\ + where images are stored. The above input files may be outsources to a different folder\n\ + via the config file. For usage notes please see the example \"config.xml\" in\n\ the /script folder.\ Options:\n\n\ - -r, --rebuild\t\tRebuild the gold standards from the test results for each image\n\n\ - -u, --ignore\t\tIgnore unallocated space while ingesting" + -r, --rebuild\t\tRebuild the gold standards from the test results for each image.\n\n\ + -i, --ignore\t\tIgnores the ./input directory when searching for files. ONLY use in combinatin with a config file.\n\n\ + -u, --unallocated\t\tIgnores unallocated space when ingesting. Faster, but less accurate results." + return usage def main(): @@ -393,13 +398,13 @@ def main(): cwd = wgetcwd() while argi < len(sys.argv): arg = sys.argv[argi] - if arg == "-s" and argi+1 < len(sys.argv): #check for single + if arg == "-f" and argi+1 < len(sys.argv): #check for single single = True test = False argi+=1 image = sys.argv[argi] print "Running on single image: " + image - if arg == "-l" or arg == "--list": #check for config file + elif arg == "-l" or arg == "--list": #check for config file list = True argi+=1 @@ -416,7 +421,7 @@ def main(): elif (arg == "--rebuild") or (arg == "-r"): #check for rebuild flag rebuild = True print "Running in REBUILD mode" - elif (arg == "-u"): #check for ignore unallocated space flag + elif (arg == "-u") or (arg == "--unallocated"): #check for ignore unallocated space flag ignoreUnalloc = True print "Ignoring unallocated space" elif (arg == "--ignore") or (arg == "-i"): From 539695bcfd2fe16a5fadbc96b52d5881d3b3fb02 Mon Sep 17 00:00:00 2001 From: 0xNF Date: Mon, 23 Jul 2012 15:10:14 -0400 Subject: [PATCH 3/5] Added -d argument to delete keyword search files after ingest. --- Testing/script/regression.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Testing/script/regression.py b/Testing/script/regression.py index ff4d292f2e..fde887b781 100644 --- a/Testing/script/regression.py +++ b/Testing/script/regression.py @@ -11,7 +11,7 @@ import xml from xml.dom.minidom import parse, parseString -# Last modified 7/23/12 @11:30am +# Last modified 7/23/12 @3:00pm # Usage: ./regression.py [-f FILE] OR [-l CONFIG] [OPTIONS] # Run the RegressionTest.java file, and compare the result with a gold standard # When the -f flag is set, this script only tests the image given by FILE. @@ -26,6 +26,7 @@ from xml.dom.minidom import parse, parseString # -r, --rebuild Rebuild the gold standards from the test results for each image # -i, --ignore Ignores the ./input directory when searching for files # -u, --unallocated Ignores unallocated space when ingesting. Faster, but less accurate results. +# -d, --delete Deletes the Keyword Search directory generated by Ingest. Reduces disk space used. hadErrors = False # If any of the tests failed @@ -236,6 +237,17 @@ def copyReportToGold(inFile, ignoreUnalloc, list): return else: shutil.copy(testReport, goldReport) + +def deleteKeywordFiles(inFile, ignoreUnalloc, list): + print "------------------------------------------------" + print "Deleting Keyword Search files" + inFile = imageName(inFile) + if ignoreUnalloc: + inFile += "-u" + if list: + inFile += "-l" + cwd = wgetcwd() + shutil.rmtree(os.path.join("./", outDir, inFile, "AutopsyTestCase", "KeywordSearch")) def testCompareReports(inFile, ignoreUnalloc, list): print "------------------------------------------------" @@ -343,6 +355,8 @@ def wabspath(inFile): proc = subprocess.Popen(("cygpath", "-m", os.path.abspath(inFile)), stdout=subprocess.PIPE) out,err = proc.communicate() return out.rstrip() + + def copyLogs(inFile, ignoreUnalloc, list): name = imageName(inFile) @@ -353,7 +367,7 @@ def copyLogs(inFile, ignoreUnalloc, list): logDir = os.path.join("..","build","test","qa-functional","work","userdir0","var","log") shutil.copytree(logDir,os.path.join(outDir,name,"logs")) -def testFile(image, rebuild, ignoreUnalloc, list): +def testFile(image, rebuild, ignoreUnalloc, list, delete): if imageType(image) != ImgType.UNKNOWN: testAddImageIngest(image, ignoreUnalloc, list) copyLogs(image, ignoreUnalloc, list) @@ -361,6 +375,8 @@ def testFile(image, rebuild, ignoreUnalloc, list): clearGoldDir(image, ignoreUnalloc, list) copyTestToGold(image, ignoreUnalloc, list) copyReportToGold(image, ignoreUnalloc, list) + if delete: + deleteKeywordFiles(image, ignoreUnalloc, list) else: testCompareToGold(image, ignoreUnalloc, list) testCompareReports(image, ignoreUnalloc, list) @@ -381,7 +397,8 @@ def usage(): Options:\n\n\ -r, --rebuild\t\tRebuild the gold standards from the test results for each image.\n\n\ -i, --ignore\t\tIgnores the ./input directory when searching for files. ONLY use in combinatin with a config file.\n\n\ - -u, --unallocated\t\tIgnores unallocated space when ingesting. Faster, but less accurate results." + -u, --unallocated\t\tIgnores unallocated space when ingesting. Faster, but less accurate results.\n\n\ + -d, --delete\t\tDeletes the Keyword Search directory generated by Ingest. Reduces disk space used." return usage @@ -392,6 +409,7 @@ def main(): ignoreUnalloc = False list = False test = True + delete = False argi = 1 Config = None #file pointed to by --list imgListB = [] #list of legal images from config @@ -406,7 +424,6 @@ def main(): print "Running on single image: " + image elif arg == "-l" or arg == "--list": #check for config file list = True - argi+=1 #check for file in ./ if(os.path.isfile(os.path.join("./", sys.argv[argi]))): @@ -427,12 +444,15 @@ def main(): elif (arg == "--ignore") or (arg == "-i"): ignoreInput = True print "Ignoring /script/input directory" + elif (arg == "--delete") or (arg == "-d"): + delete = True + print "Will delete keyword search files after each ingest" else: test = False print usage() argi+=1 if single: - testFile(image, rebuild, ignoreUnalloc, list) + testFile(image, rebuild, ignoreUnalloc, list, delete) if list: listImages = [] errors = 0 @@ -451,14 +471,14 @@ def main(): errors+=1 print "Illegal files specified: " + str(errors) for image in listImages: - testFile(image, rebuild, ignoreUnalloc, list) + testFile(image, rebuild, ignoreUnalloc, list, delete) if not ignoreInput: global inDir inDir = os.path.join(cwd, "input") test = True if test: for inFile in os.listdir(inDir): - testFile(os.path.join(inDir,inFile), rebuild, ignoreUnalloc, list) + testFile(os.path.join(inDir,inFile), rebuild, ignoreUnalloc, list, delete) if hadErrors == True: print "**********************************************" From db17e3520c317b43ac2276f9a39d59ac4a78c968 Mon Sep 17 00:00:00 2001 From: 0xNF Date: Mon, 23 Jul 2012 15:16:51 -0400 Subject: [PATCH 4/5] Changed deletion of Solr index to be default, disabled via -d instead. --- Testing/script/regression.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Testing/script/regression.py b/Testing/script/regression.py index fde887b781..63263104ba 100644 --- a/Testing/script/regression.py +++ b/Testing/script/regression.py @@ -26,7 +26,7 @@ from xml.dom.minidom import parse, parseString # -r, --rebuild Rebuild the gold standards from the test results for each image # -i, --ignore Ignores the ./input directory when searching for files # -u, --unallocated Ignores unallocated space when ingesting. Faster, but less accurate results. -# -d, --delete Deletes the Keyword Search directory generated by Ingest. Reduces disk space used. +# -d, --delete Disables the deletion of Solr indexing directory generated by Ingest. Uses more disk space.. hadErrors = False # If any of the tests failed @@ -398,7 +398,7 @@ def usage(): -r, --rebuild\t\tRebuild the gold standards from the test results for each image.\n\n\ -i, --ignore\t\tIgnores the ./input directory when searching for files. ONLY use in combinatin with a config file.\n\n\ -u, --unallocated\t\tIgnores unallocated space when ingesting. Faster, but less accurate results.\n\n\ - -d, --delete\t\tDeletes the Keyword Search directory generated by Ingest. Reduces disk space used." + -d, --delete\t\tDisables the deletion of Solr indexing directory generated by Ingest. Uses more disk space." return usage @@ -409,7 +409,7 @@ def main(): ignoreUnalloc = False list = False test = True - delete = False + delete = True argi = 1 Config = None #file pointed to by --list imgListB = [] #list of legal images from config @@ -446,7 +446,7 @@ def main(): print "Ignoring /script/input directory" elif (arg == "--delete") or (arg == "-d"): delete = True - print "Will delete keyword search files after each ingest" + print "Will not delete keyword search Solr index" else: test = False print usage() From 96bba9aa75a357d3bba914604def647d83aeafed Mon Sep 17 00:00:00 2001 From: dhurd Date: Mon, 23 Jul 2012 16:33:35 -0400 Subject: [PATCH 5/5] NF's new script. --- Testing/script/regression.py | 67 +++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/Testing/script/regression.py b/Testing/script/regression.py index d1481ffeb9..dd6c7d6fb2 100644 --- a/Testing/script/regression.py +++ b/Testing/script/regression.py @@ -11,19 +11,22 @@ import xml from xml.dom.minidom import parse, parseString -# Last modified 7/17/12 @5pm -# Usage: ./regression.py [-s FILE] OR [-l CONFIG] [OPTIONS] +# Last modified 7/23/12 @3:00pm +# Usage: ./regression.py [-f FILE] OR [-l CONFIG] [OPTIONS] # Run the RegressionTest.java file, and compare the result with a gold standard -# When the -i flag is set, this script only tests the image given by FILE. +# When the -f flag is set, this script only tests the image given by FILE. # An indexed NSRL database is expected at ./input/nsrl.txt-md5.idx, # and an indexed notable hash database at ./input/notablehashes.txt-md5.idx # In addition, any keywords to search for must be in ./input/notablekeywords.xml # When the -l flag is set, the script looks for a config.xml file of the given name -# where images are stored. For usage notes please see the example "config.xml" in +# where images are stored. The above input files can be outsourced to different locations +# from the config.xml. For usage notes please see the example "config.xml" in # the /script folder. # Options: # -r, --rebuild Rebuild the gold standards from the test results for each image -# -i, --ignore Ignores unallocated space when ingesting. Faster, but less accurate results. +# -i, --ignore Ignores the ./input directory when searching for files +# -u, --unallocated Ignores unallocated space when ingesting. Faster, but less accurate results. +# -d, --delete Disables the deletion of Solr indexing directory generated by Ingest. Uses more disk space.. hadErrors = False # If any of the tests failed @@ -119,8 +122,8 @@ def getImageSize(inFile, list): filename = os.path.splitext(files)[0] if filename == name: filepath = os.path.join(path, files) - if not os.path.samefile(filepath, inFile): - size += os.path.getsize(filepath) + if not os.path.samefile(filepath, inFile): + size += os.path.getsize(filepath) size += os.path.getsize(inFile) return size @@ -234,6 +237,17 @@ def copyReportToGold(inFile, ignoreUnalloc, list): return else: shutil.copy(testReport, goldReport) + +def deleteKeywordFiles(inFile, ignoreUnalloc, list): + print "------------------------------------------------" + print "Deleting Keyword Search files" + inFile = imageName(inFile) + if ignoreUnalloc: + inFile += "-u" + if list: + inFile += "-l" + cwd = wgetcwd() + shutil.rmtree(os.path.join("./", outDir, inFile, "AutopsyTestCase", "KeywordSearch")) def testCompareReports(inFile, ignoreUnalloc, list): print "------------------------------------------------" @@ -341,6 +355,8 @@ def wabspath(inFile): proc = subprocess.Popen(("cygpath", "-m", os.path.abspath(inFile)), stdout=subprocess.PIPE) out,err = proc.communicate() return out.rstrip() + + def copyLogs(inFile, ignoreUnalloc, list): name = imageName(inFile) @@ -351,7 +367,7 @@ def copyLogs(inFile, ignoreUnalloc, list): logDir = os.path.join("..","build","test","qa-functional","work","userdir0","var","log") shutil.copytree(logDir,os.path.join(outDir,name,"logs")) -def testFile(image, rebuild, ignoreUnalloc, list): +def testFile(image, rebuild, ignoreUnalloc, list, delete): if imageType(image) != ImgType.UNKNOWN: testAddImageIngest(image, ignoreUnalloc, list) copyLogs(image, ignoreUnalloc, list) @@ -359,25 +375,31 @@ def testFile(image, rebuild, ignoreUnalloc, list): clearGoldDir(image, ignoreUnalloc, list) copyTestToGold(image, ignoreUnalloc, list) copyReportToGold(image, ignoreUnalloc, list) + if delete: + deleteKeywordFiles(image, ignoreUnalloc, list) else: testCompareToGold(image, ignoreUnalloc, list) testCompareReports(image, ignoreUnalloc, list) def usage(): usage = "\ - Usage: ./regression.py [-s FILE] [OPTIONS] \n\n\ + Usage: ./regression.py [-f FILE] [OPTIONS] \n\n\ Run the RegressionTest.java file, and compare the result with a gold standard \n\n\ - When the -i flag is set, this script only tests the image given by FILE.\n\ + When the -f flag is set, this script only tests the image given by FILE.\n\ By default, it tests every image in ./input/\n\n\ An indexed NSRL database is expected at ./input/nsrl.txt-md5.idx,\n\ and an indexed notable hash database at ./input/notablehashes.txt-md5.idx\n\ In addition, any keywords to search for must be in ./input/notablekeywords.xml\n\n\ When the -l flag is set, the script looks for a config.xml file of the given name\n\ - where images are stored. For usage notes please see the example config.xml in\n\ + where images are stored. The above input files may be outsources to a different folder\n\ + via the config file. For usage notes please see the example \"config.xml\" in\n\ the /script folder.\ Options:\n\n\ - -r, --rebuild\t\tRebuild the gold standards from the test results for each image\n\n\ - -u, --ignore\t\tIgnore unallocated space while ingesting" + -r, --rebuild\t\tRebuild the gold standards from the test results for each image.\n\n\ + -i, --ignore\t\tIgnores the ./input directory when searching for files. ONLY use in combinatin with a config file.\n\n\ + -u, --unallocated\t\tIgnores unallocated space when ingesting. Faster, but less accurate results.\n\n\ + -d, --delete\t\tDisables the deletion of Solr indexing directory generated by Ingest. Uses more disk space." + return usage def main(): @@ -387,21 +409,21 @@ def main(): ignoreUnalloc = False list = False test = True + delete = True argi = 1 Config = None #file pointed to by --list imgListB = [] #list of legal images from config cwd = wgetcwd() while argi < len(sys.argv): arg = sys.argv[argi] - if arg == "-s" and argi+1 < len(sys.argv): #check for single + if arg == "-f" and argi+1 < len(sys.argv): #check for single single = True test = False argi+=1 image = sys.argv[argi] print "Running on single image: " + image - if arg == "-l" or arg == "--list": #check for config file + elif arg == "-l" or arg == "--list": #check for config file list = True - argi+=1 #check for file in ./ if(os.path.isfile(os.path.join("./", sys.argv[argi]))): @@ -416,18 +438,21 @@ def main(): elif (arg == "--rebuild") or (arg == "-r"): #check for rebuild flag rebuild = True print "Running in REBUILD mode" - elif (arg == "-u"): #check for ignore unallocated space flag + elif (arg == "-u") or (arg == "--unallocated"): #check for ignore unallocated space flag ignoreUnalloc = True print "Ignoring unallocated space" elif (arg == "--ignore") or (arg == "-i"): ignoreInput = True print "Ignoring /script/input directory" + elif (arg == "--delete") or (arg == "-d"): + delete = True + print "Will not delete keyword search Solr index" else: test = False print usage() argi+=1 if single: - testFile(image, rebuild, ignoreUnalloc, list) + testFile(image, rebuild, ignoreUnalloc, list, delete) if list: listImages = [] errors = 0 @@ -446,14 +471,14 @@ def main(): errors+=1 print "Illegal files specified: " + str(errors) for image in listImages: - testFile(image, rebuild, ignoreUnalloc, list) + testFile(image, rebuild, ignoreUnalloc, list, delete) if not ignoreInput: global inDir inDir = os.path.join(cwd, "input") test = True if test: for inFile in os.listdir(inDir): - testFile(os.path.join(inDir,inFile), rebuild, ignoreUnalloc, list) + testFile(os.path.join(inDir,inFile), rebuild, ignoreUnalloc, list, delete) if hadErrors == True: print "**********************************************" @@ -468,4 +493,4 @@ def main(): print("\t%s" % errString) if __name__ == "__main__": - main() + main() \ No newline at end of file