diff --git a/Testing/script/regression.py b/Testing/script/regression.py
index 35ed5e2739..c29cff73dd 100644
--- a/Testing/script/regression.py
+++ b/Testing/script/regression.py
@@ -130,6 +130,12 @@ def testCompareToGold(inFile):
else:
print("Object counts match!")
+def clearGoldDir(inFile):
+ cwd = wgetcwd()
+ if os.path.exists(os.path.join(cwd,goldDir,inFile)):
+ shutil.rmtree(os.path.join(cwd,goldDir,inFile))
+ os.makedirs(os.path.join(cwd,goldDir,inFile))
+
def copyTestToGold(inFile):
print "------------------------------------------------"
print "Recreating gold standard from results."
@@ -137,11 +143,70 @@ def copyTestToGold(inFile):
cwd = wgetcwd()
goldFile = os.path.join("./",goldDir,inFile,"standard.db")
testFile = os.path.join("./",outDir,inFile,"AutopsyTestCase","autopsy.db")
- if os.path.exists(os.path.join(cwd,goldDir,inFile)):
- shutil.rmtree(os.path.join(cwd,goldDir,inFile))
- os.makedirs(os.path.join(cwd,goldDir,inFile))
shutil.copy(testFile, goldFile)
+def copyReportToGold(inFile):
+ print "------------------------------------------------"
+ print "Recreating gold report from results."
+ inFile = imageName(inFile)
+ cwd = wgetcwd()
+ goldReport = os.path.join("./",goldDir,inFile,"report.html")
+ testReportPath = os.path.join("./",outDir,inFile,"AutopsyTestCase","Reports")
+ # Because Java adds a timestamp to the report file, one can't call it
+ # directly, so one must get a list of files in the dir, which are only
+ # reports, then filter for the .html report
+ for files in os.listdir(testReportPath):
+ if files.endswith(".html"): # Get the HTML one
+ testReport = os.path.join("./",outDir,inFile,"AutopsyTestCase","Reports",files)
+ shutil.copy(testReport, goldReport)
+
+def testCompareReports(inFile):
+ print "------------------------------------------------"
+ print "Comparing report to golden report."
+ name = imageName(inFile)
+ goldReport = os.path.join("./",goldDir,name,"report.html")
+ testReportPath = os.path.join("./",outDir,name,"AutopsyTestCase","Reports")
+ # Because Java adds a timestamp to the report file, one can't call it
+ # directly, so one must get a list of files in the dir, which are only
+ # reports, then filter for the .html report
+ testReport = None
+ for files in os.listdir(testReportPath):
+ if files.endswith(".html"): # Get the HTML one
+ testReport = os.path.join("./",outDir,name,"AutopsyTestCase","Reports",files)
+ if os.path.isfile(goldReport) == False:
+ markError("No gold report exists", inFile)
+ return
+ if testReport is None:
+ markError("No test report exists", inFile)
+ return
+ # Compare the reports
+ goldFile = open(goldReport)
+ testFile = open(testReport)
+ # Search for
because it is first seen in the report
+ # immediately after the unnecessary metadata, styles, and timestamp
+ gold = goldFile.read()
+ test = testFile.read()
+ gold = gold[gold.find(""):]
+ test = test[test.find(""):]
+ # Splitting allows for printouts of what the difference is
+ goldList = split(gold, 50)
+ testList = split(test, 50)
+ failed = 0
+ for goldSplit, testSplit in zip(goldList, testList):
+ if goldSplit != testSplit:
+ failed = 1
+ #print "Got: " + testSplit
+ #print "Expected: " + goldSplit
+ break
+ if(failed):
+ errString = "Reports do not match."
+ markError(errString, inFile)
+ else:
+ print "Reports match."
+
+def split(input, size):
+ return [input[start:start+size] for start in range(0, len(input), size)]
+
class ImgType:
RAW, ENCASE, SPLIT, UNKNOWN = range(4)
@@ -199,9 +264,12 @@ def testFile(image, rebuild):
#print imageName(image)
copyLogs(image)
if rebuild:
+ clearGoldDir(image)
copyTestToGold(image)
+ copyReportToGold(image)
else:
testCompareToGold(image)
+ testCompareReports(image)
def usage() :
usage = "\
diff --git a/Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/RegressionTest.java b/Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/RegressionTest.java
index 96c91cd119..4c362a91f8 100644
--- a/Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/RegressionTest.java
+++ b/Testing/test/qa-functional/src/org/sleuthkit/autopsy/testing/RegressionTest.java
@@ -25,6 +25,7 @@ import javax.swing.JDialog;
import javax.swing.JTextField;
import junit.framework.Test;
import org.netbeans.jellytools.JellyTestCase;
+import org.netbeans.jellytools.MainWindowOperator;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.WizardOperator;
import org.netbeans.jemmy.Timeout;
@@ -73,7 +74,9 @@ public class RegressionTest extends JellyTestCase{
"testConfigureHash",
"testConfigureIngest2",
"testConfigureSearch",
- "testIngest");
+ "testIngest",
+ "testGenerateReportToolbar",
+ "testGenerateReportButton");
return NbModuleSuite.create(conf);
}
@@ -217,4 +220,34 @@ public class RegressionTest extends JellyTestCase{
logger.info("Ingest (including enqueue) took " + (System.currentTimeMillis()-start) + "ms");
new Timeout("pausing", 5000).sleep(); // allow keyword search to finish saving artifacts, just in case
}
+
+ public void testGenerateReportToolbar() {
+ logger.info("Generate Report Toolbars");
+ // Force the action if necessary:
+ //new Action("Tools|Generate Report", null).perform();
+ //new Timeout("pausing", 1000).sleep();
+ MainWindowOperator mwo = MainWindowOperator.getDefault();
+ JButtonOperator jbo = new JButtonOperator(mwo, "Generate Report");
+ jbo.pushNoBlock();
+ new Timeout("pausing", 1000).sleep();
+ }
+
+ public void testGenerateReportButton() {
+ logger.info("Generate Report Button");
+ JDialog reportDialog = JDialogOperator.waitJDialog("Generate Report", false, false);
+ JDialogOperator reportDialogOperator = new JDialogOperator(reportDialog);
+ JCheckBoxOperator jcbo0 = new JCheckBoxOperator(reportDialogOperator, "Excel");
+ jcbo0.doClick();
+ JCheckBoxOperator jcbo1 = new JCheckBoxOperator(reportDialogOperator, "Default XML");
+ jcbo1.doClick();
+ JButtonOperator jbo0 = new JButtonOperator(reportDialogOperator, "Generate Report");
+ jbo0.pushNoBlock();
+ new Timeout("pausing", 1000).sleep(); // Give it a second to open
+
+ JDialog previewDialog = JDialogOperator.waitJDialog("Report Preview", false, false);
+ JDialogOperator previewDialogOperator = new JDialogOperator(previewDialog);
+ JButtonOperator jbo1 = new JButtonOperator(previewDialogOperator, "Close");
+ jbo1.pushNoBlock();
+ new Timeout("pausing", 1000).sleep(); // Give the program a second to idle for ascetics
+ }
}
\ No newline at end of file