From eca3aff89eb10880a8a1007b579cd4b7dc5837cc Mon Sep 17 00:00:00 2001 From: dhurd Date: Tue, 28 Aug 2012 10:12:58 -0400 Subject: [PATCH] Reverting addition of output argument; added a pause after the Java runs. --- Testing/script/regression.py | 61 ++++++++++++++---------------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/Testing/script/regression.py b/Testing/script/regression.py index 55de55d2a4..89369733b1 100644 --- a/Testing/script/regression.py +++ b/Testing/script/regression.py @@ -11,6 +11,7 @@ import datetime import xml import re import socket +import time from xml.dom.minidom import parse, parseString from sys import platform as _platform @@ -54,8 +55,6 @@ class Args: self.verbose = False self.exception = False self.exception_string = "" - self.output = False - self.output_dir = "" def parse(self): sys.argv.pop(0) @@ -101,22 +100,11 @@ class Args: try: arg = sys.argv.pop(0) printout("Running in exception mode: ") - printout("Printing all exceptions with the string '" + arg + "'.\n") + printout("Printing all exceptions with the string '" + arg + "'\n") self.exception = True self.exception_string = arg except: printerror("Error: No exception string given.") - elif(arg == "-o" or arg == "--output"): - try: - arg = sys.argv.pop(0) - if dir_exists(arg): - printout("Running with output directory set to " + arg + ".\n") - self.output = True - self.output_dir = arg - else: - printerror("Error: Given output directory for -o doesn't exist.") - except: - printerror("Error: No output directory given.\n") elif arg == "-h" or arg == "--help": printout(usage()) return False @@ -379,12 +367,13 @@ def run_test(image_file): # Set the case to work for this test case.image_file = image_file case.image_name = case.get_image_name(image_file) - case.antlog_dir = make_path(case.output_dir, case.image_name, "antlog.txt") + case.antlog_dir = make_local_path(case.output_dir, case.image_name, "antlog.txt") case.known_bad_path = make_path(case.input_dir, "notablehashes.txt-md5.idx") case.keyword_path = make_path(case.input_dir, "notablekeywords.xml") case.nsrl_path = make_path(case.input_dir, "nsrl.txt-md5.idx") run_ant() + time.sleep(2) # Give everything a second to process # After the java has ran: copy_logs() @@ -400,7 +389,7 @@ def run_test(image_file): rebuild() # If NOT keeping Solr index (-k) if not args.keep: - solr_index = make_path(case.output_dir, case.image_name, "AutopsyTestCase", "KeywordSearch") + solr_index = make_local_path(case.output_dir, case.image_name, "AutopsyTestCase", "KeywordSearch") if clear_dir(solr_index): print_report([], "DELETE SOLR INDEX", "Solr index deleted.") elif args.keep: @@ -453,7 +442,7 @@ def run_ant(): case.ant.append("-Dkeyword_path=" + case.keyword_path) case.ant.append("-Dnsrl_path=" + case.nsrl_path) case.ant.append("-Dgold_path=" + make_local_path(case.gold)) - case.ant.append("-Dout_path=" + make_path(case.output_dir, case.image_name)) + case.ant.append("-Dout_path=" + make_local_path(case.output_dir, case.image_name)) case.ant.append("-Dignore_unalloc=" + "%s" % args.unallocated) case.ant.append("-Dtest.timeout=" + str(case.timeout)) @@ -500,9 +489,9 @@ def rebuild(): clear_dir(gold_dir) # Rebuild the database - gold_from = make_path(case.output_dir, case.image_name, + gold_from = make_local_path(case.output_dir, case.image_name, "AutopsyTestCase", "autopsy.db") - gold_to = make_path(case.gold, case.image_name, "standard.db") + gold_to = make_local_path(case.gold, case.image_name, "standard.db") try: copy_file(gold_from, gold_to) except FileNotFoundException as e: @@ -512,7 +501,7 @@ def rebuild(): errors.append(str(e) + "\n") # Rebuild the HTML report - html_path = make_path(case.output_dir, case.image_name, + html_path = make_local_path(case.output_dir, case.image_name, "AutopsyTestCase", "Reports") try: html_from = get_file_in_dir(html_path, ".html") @@ -589,7 +578,7 @@ def compare_to_gold_db(): # the regression test against the gold standard html report def compare_to_gold_html(): gold_html_file = make_local_path(case.gold, case.image_name, "standard.html") - autopsy_html_path = make_path(case.output_dir, case.image_name, + autopsy_html_path = make_local_path(case.output_dir, case.image_name, "AutopsyTestCase", "Reports") try: autopsy_html_file = get_file_in_dir(autopsy_html_path, ".html") @@ -672,7 +661,7 @@ def compare_tsk_objects(): # from each log file generated by Autopsy def generate_common_log(): try: - logs_path = make_path(case.output_dir, case.image_name, "logs") + logs_path = make_local_path(case.output_dir, case.image_name, "logs") common_log = open(case.common_log, "a") common_log.write("--------------------------------------------------\n") common_log.write(case.image_name + "\n") @@ -698,7 +687,7 @@ def generate_common_log(): def fill_case_data(): try: # Open autopsy.log.0 - log_path = make_path(case.output_dir, case.image_name, "logs", "autopsy.log.0") + log_path = make_local_path(case.output_dir, case.image_name, "logs", "autopsy.log.0") log = open(log_path) # Set the case starting time based off the first line of autopsy.log.0 @@ -858,7 +847,7 @@ def csv_header(csv_path): # Returns a list of all the exceptions listed in all the autopsy logs def get_exceptions(): exceptions = [] - logs_path = make_path(case.output_dir, case.image_name, "logs") + logs_path = make_local_path(case.output_dir, case.image_name, "logs") results = [] for file in os.listdir(logs_path): if "autopsy" in file: @@ -894,7 +883,7 @@ def report_all_errors(): # Searched all the known logs for the given regex # The function expects regex = re.compile(...) def regex_search_logs(regex): - logs_path = make_path(case.output_dir, case.image_name, "logs") + logs_path = make_local_path(case.output_dir, case.image_name, "logs") results = [] for file in os.listdir(logs_path): log = open(make_path(logs_path, file), "r") @@ -909,7 +898,7 @@ def regex_search_logs(regex): # Search through all the known log files for a specific string. # Returns a list of all lines with that string def search_logs(string): - logs_path = make_path(case.output_dir, case.image_name, "logs") + logs_path = make_local_path(case.output_dir, case.image_name, "logs") results = [] for file in os.listdir(logs_path): log = open(make_path(logs_path, file), "r") @@ -934,7 +923,7 @@ def search_common_log(string): # Searches the given log for the given string # Returns a list of all lines with that string def search_log(log, string): - logs_path = make_path(case.output_dir, case.image_name, "logs", log) + logs_path = make_local_path(case.output_dir, case.image_name, "logs", log) try: results = [] log = open(logs_path, "r") @@ -951,7 +940,7 @@ def search_log(log, string): # Search through all the the logs of the given type # Types include autopsy, tika, and solr def search_log_set(type, string): - logs_path = make_path(case.output_dir, case.image_name, "logs") + logs_path = make_local_path(case.output_dir, case.image_name, "logs") results = [] for file in os.listdir(logs_path): if type in file: @@ -1027,7 +1016,7 @@ def generate_html(): logs = "
\

Logs

\
" - logs_path = make_path(case.output_dir, case.image_name, "logs") + logs_path = make_local_path(case.output_dir, case.image_name, "logs") for file in os.listdir(logs_path): logs += "

" + file + "

" logs += "
" @@ -1208,7 +1197,7 @@ def wgetcwd(): def copy_logs(): try: log_dir = os.path.join("..","build","test","qa-functional","work","userdir0","var","log") - shutil.copytree(log_dir, make_path(case.output_dir, case.image_name, "logs")) + shutil.copytree(log_dir, make_local_path(case.output_dir, case.image_name, "logs")) except Exception as e: printerror("Error: Failed to copy the logs.") printerror(str(e) + "\n") @@ -1315,7 +1304,6 @@ Options: -v Verbose mode; prints all errors to the screen. -e ex Prints out all errors containing ex. -l cfg Runs from configuration file cfg. - -o dir Uses dir as the output directory. Must be a full path. """ @@ -1378,14 +1366,11 @@ def main(): pass # Otherwise test away! else: - if not args.output: - case.output_dir = make_local_path("output", time.strftime("%Y.%m.%d-%H.%M.%S")) - else: - case.output_dir = make_path(args.output_dir, time.strftime("%Y.%m.%d-%H.%M.%S")) + case.output_dir = make_path("output", time.strftime("%Y.%m.%d-%H.%M.%S")) os.makedirs(case.output_dir) - case.common_log = make_path(case.output_dir, "AutopsyErrors.txt") - case.csv = make_path(case.output_dir, "CSV.txt") - case.html_log = make_path(case.output_dir, "AutopsyTestCase.html") + case.common_log = make_local_path(case.output_dir, "AutopsyErrors.txt") + case.csv = make_local_path(case.output_dir, "CSV.txt") + case.html_log = make_local_path(case.output_dir, "AutopsyTestCase.html") # If user wants to do a single file and a list (contradictory?) if args.single and args.list: