mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
Regression test improvements, now uses zip format
This commit is contained in:
parent
fdfd758911
commit
fd40cde19b
@ -24,6 +24,7 @@ from email.MIMEBase import MIMEBase
|
|||||||
from email import Encoders
|
from email import Encoders
|
||||||
import urllib2
|
import urllib2
|
||||||
import re
|
import re
|
||||||
|
import zipfile
|
||||||
|
|
||||||
#
|
#
|
||||||
# Please read me...
|
# Please read me...
|
||||||
@ -528,16 +529,26 @@ def run_test(image_file, count):
|
|||||||
|
|
||||||
# Now test in comparison to the gold standards
|
# Now test in comparison to the gold standards
|
||||||
if not args.gold_creation:
|
if not args.gold_creation:
|
||||||
compare_to_gold_db()
|
try:
|
||||||
compare_to_gold_html()
|
gold_path = os.path.join(case.gold)
|
||||||
|
img_gold = os.path.join(case.gold, case.image_name)
|
||||||
|
img_archive = os.path.join(case.gold, case.image_name+"-archive.zip")
|
||||||
|
extrctr = zipfile.ZipFile(img_archive, 'r')
|
||||||
|
extrctr.extractall(gold_path)
|
||||||
|
extrctr.close
|
||||||
|
compare_to_gold_db()
|
||||||
|
compare_to_gold_html()
|
||||||
|
compare_errors()
|
||||||
|
del_dir(img_gold)
|
||||||
|
except:
|
||||||
|
print("Tests failed due to an error, try rebuilding or creating gold standards.\n")
|
||||||
# Make the CSV log and the html log viewer
|
# Make the CSV log and the html log viewer
|
||||||
generate_csv(case.csv)
|
generate_csv(case.csv)
|
||||||
if case.global_csv:
|
if case.global_csv:
|
||||||
generate_csv(case.global_csv)
|
generate_csv(case.global_csv)
|
||||||
generate_html()
|
generate_html()
|
||||||
# If running in rebuild mode (-r)
|
# If running in rebuild mode (-r)
|
||||||
if args.rebuild:
|
if args.rebuild or args.gold_creation:
|
||||||
rebuild()
|
rebuild()
|
||||||
# Reset the case and return the tests sucessfully finished
|
# Reset the case and return the tests sucessfully finished
|
||||||
clear_dir(make_local_path(case.output_dir, case.image_name, "AutopsyTestCase", "ModuleOutput", "keywordsearch"))
|
clear_dir(make_local_path(case.output_dir, case.image_name, "AutopsyTestCase", "ModuleOutput", "keywordsearch"))
|
||||||
@ -639,9 +650,23 @@ def rebuild():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append("Error: Unknown fatal error when rebuilding the gold html report.")
|
errors.append("Error: Unknown fatal error when rebuilding the gold html report.")
|
||||||
errors.append(str(e) + "\n")
|
errors.append(str(e) + "\n")
|
||||||
|
oldcwd = os.getcwd()
|
||||||
|
os.chdir(case.gold)
|
||||||
|
img_archive = make_local_path(case.image_name+"-archive.zip")
|
||||||
|
img_gold = os.path.join(case.image_name)
|
||||||
|
comprssr = zipfile.ZipFile(img_archive, 'w')
|
||||||
|
zipdir(img_gold, comprssr)
|
||||||
|
comprssr.close()
|
||||||
|
del_dir(gold_dir)
|
||||||
|
os.chdir(oldcwd)
|
||||||
okay = "Sucessfully rebuilt all gold standards."
|
okay = "Sucessfully rebuilt all gold standards."
|
||||||
print_report(errors, "REBUILDING", okay)
|
print_report(errors, "REBUILDING", okay)
|
||||||
|
|
||||||
|
def zipdir(path, zip):
|
||||||
|
for root, dirs, files in os.walk(path):
|
||||||
|
for file in files:
|
||||||
|
zip.write(os.path.join(root, file))
|
||||||
|
|
||||||
# Using the global case's variables, compare the database file made by the
|
# Using the global case's variables, compare the database file made by the
|
||||||
# regression test to the gold standard database file
|
# regression test to the gold standard database file
|
||||||
# Initializes the global database, which stores the information retrieved
|
# Initializes the global database, which stores the information retrieved
|
||||||
@ -856,7 +881,6 @@ def generate_common_log():
|
|||||||
case.sorted_log = make_local_path(case.output_dir, case.image_name, case.image_name + "SortedErrors.txt")
|
case.sorted_log = make_local_path(case.output_dir, case.image_name, case.image_name + "SortedErrors.txt")
|
||||||
srtcmdlst = ["sort", case.common_log_path, "-o", case.sorted_log]
|
srtcmdlst = ["sort", case.common_log_path, "-o", case.sorted_log]
|
||||||
subprocess.call(srtcmdlst)
|
subprocess.call(srtcmdlst)
|
||||||
compare_errors()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printerror("Error: Unable to generate the common log.")
|
printerror("Error: Unable to generate the common log.")
|
||||||
printerror(str(e) + "\n")
|
printerror(str(e) + "\n")
|
||||||
@ -906,9 +930,10 @@ def fill_case_data():
|
|||||||
start = datetime.datetime.strptime(case.start_date, "%b %d, %Y %I:%M:%S %p")
|
start = datetime.datetime.strptime(case.start_date, "%b %d, %Y %I:%M:%S %p")
|
||||||
end = datetime.datetime.strptime(case.end_date, "%a %b %d %H:%M:%S %Y")
|
end = datetime.datetime.strptime(case.end_date, "%a %b %d %H:%M:%S %Y")
|
||||||
case.total_test_time = str(end - start)
|
case.total_test_time = str(end - start)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Set Autopsy version, heap space, ingest time, and service times
|
# Set Autopsy version, heap space, ingest time, and service times
|
||||||
|
|
||||||
version_line = search_logs("INFO: Application name: Autopsy, version:")[0]
|
version_line = search_logs("INFO: Application name: Autopsy, version:")[0]
|
||||||
case.autopsy_version = get_word_at(version_line, 5).rstrip(",")
|
case.autopsy_version = get_word_at(version_line, 5).rstrip(",")
|
||||||
|
|
||||||
|
@ -296,6 +296,19 @@ public class RegressionTest extends TestCase{
|
|||||||
new Timeout("pausing", 1000).sleep();
|
new Timeout("pausing", 1000).sleep();
|
||||||
JButtonOperator jbo1 = new JButtonOperator(reportDialogOperator, "Finish");
|
JButtonOperator jbo1 = new JButtonOperator(reportDialogOperator, "Finish");
|
||||||
jbo1.pushNoBlock();
|
jbo1.pushNoBlock();
|
||||||
|
boolean waiting = true;
|
||||||
|
long size = 0;
|
||||||
|
java.io.File rprtfldr = new java.io.File(System.getProperty("out_path")+java.io.File.separator+"AutopsyTestCase"+java.io.File.separator+"Reports"+java.io.File.separator+"AutopsyTestCase "+datenotime+java.io.File.separator+"HTML Report");
|
||||||
|
while(waiting)
|
||||||
|
{
|
||||||
|
long currsize = size;
|
||||||
|
size = 0;
|
||||||
|
for(java.io.File elem: rprtfldr.listFiles())
|
||||||
|
{
|
||||||
|
size+=elem.getTotalSpace();
|
||||||
|
}
|
||||||
|
waiting = size>currsize;
|
||||||
|
}
|
||||||
new Timeout("pausing", 20000).sleep(); // Give it a few seconds to generate
|
new Timeout("pausing", 20000).sleep(); // Give it a few seconds to generate
|
||||||
screenshot("Progress");
|
screenshot("Progress");
|
||||||
JDialog previewDialog = JDialogOperator.waitJDialog("Progress", false, false);
|
JDialog previewDialog = JDialogOperator.waitJDialog("Progress", false, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user