Skip to content
Snippets Groups Projects
Commit c822612a authored by Brian Carrier's avatar Brian Carrier
Browse files

more minor comment / documentation updates to datamodel test

parent b2cb50b2
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="windows-1252"?> <?xml version="1.0" encoding="windows-1252"?>
<project name="TSKTestTargets"> <project name="TSKTestTargets">
<target name="test-precond" <target name="test-precond"
description="Traverses the Images stored in the path represented by test-input variable, creates results files stored in the path represented by test-results, and compares them to the standards stored in the path represented by the test-standards variable, always run test-create-standards at least once before before running test." description="Performs regression tests."
depends="compile-test, copyTSKLibs"> depends="compile-test, copyTSKLibs">
<junit fork="on" haltonfailure="yes" dir="."> <junit fork="on" haltonfailure="yes" dir=".">
<sysproperty key="rslt" value="${test-results}"/> <sysproperty key="rslt" value="${test-results}"/>
...@@ -12,8 +12,9 @@ ...@@ -12,8 +12,9 @@
<test name="org.sleuthkit.datamodel.DataModelTestSuite" /> <test name="org.sleuthkit.datamodel.DataModelTestSuite" />
</junit> </junit>
</target> </target>
<target name="test-create-standards-precond"
description="Traverses the Images stored in the path represented by test-input variable and creates then stores them to the path represented by the test-standards variable, run test-download-imgs at least once before this." <target name="test-rebuild-precond"
description="Rebuilds regression tests."
depends="compile-test, copyTSKLibs"> depends="compile-test, copyTSKLibs">
<java classname="org.sleuthkit.datamodel.DataModelTestSuite" classpathref="libraries" fork="true" failonerror="true"> <java classname="org.sleuthkit.datamodel.DataModelTestSuite" classpathref="libraries" fork="true" failonerror="true">
<sysproperty key="gold" value="${test-standards}"/> <sysproperty key="gold" value="${test-standards}"/>
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
<isset property="env.LIBEWF_HOME"/> <isset property="env.LIBEWF_HOME"/>
</condition> </condition>
<property name="dlls" value="${env.LIBEWF_HOME}/msvscpp/zlib;${env.LIBEWF_HOME}/msvscpp/Release;../../win32/Release"/> <property name="dlls" value="${env.LIBEWF_HOME}/msvscpp/zlib;${env.LIBEWF_HOME}/msvscpp/Release;../../win32/Release"/>
<target name="test-precond" <target name="test-precond"
description="Traverses the Images stored in the path represented by test-input variable, creates results files stored in the path represented by test-results, and compares them to the standards stored in the path represented by the test-standards variable, always run test-create-standards at least once before before running test." description="Runs the regression tests."
depends="compile-test" > depends="compile-test" >
<fail unless="ewfFound" message="LIBEWF_HOME must be set as an environment variable."/> <fail unless="ewfFound" message="LIBEWF_HOME must be set as an environment variable."/>
<junit fork="on" haltonfailure="yes" dir="."> <junit fork="on" haltonfailure="yes" dir=".">
...@@ -20,8 +21,9 @@ ...@@ -20,8 +21,9 @@
<test name="org.sleuthkit.datamodel.DataModelTestSuite" /> <test name="org.sleuthkit.datamodel.DataModelTestSuite" />
</junit> </junit>
</target> </target>
<target name="test-create-standards-precond"
description="Traverses the Images stored in the path represented by test-input variable and creates then stores them to the path represented by the test-standards variable, run test-download-imgs at least once before this." <target name="test-rebuild-precond"
description="Rebuilds gold standards for tests."
depends="compile-test" > depends="compile-test" >
<fail unless="ewfFound" message="LIBEWF_HOME must be set as an environment variable."/> <fail unless="ewfFound" message="LIBEWF_HOME must be set as an environment variable."/>
<java classname="org.sleuthkit.datamodel.DataModelTestSuite" classpathref="libraries" fork="true" failonerror="true"> <java classname="org.sleuthkit.datamodel.DataModelTestSuite" classpathref="libraries" fork="true" failonerror="true">
......
...@@ -112,17 +112,23 @@ pattern="lib/[artifact]-[revision](-[classifier]).[ext]" /> ...@@ -112,17 +112,23 @@ pattern="lib/[artifact]-[revision](-[classifier]).[ext]" />
<mkdir dir="javadoc"/> <mkdir dir="javadoc"/>
<javadoc sourcepath="src" destdir="javadoc" overview="src/overview.html" /> <javadoc sourcepath="src" destdir="javadoc" overview="src/overview.html" />
</target> </target>
<target name="test-download-imgs" description="Get test images and store them in the path represented by the test-input variable.">
<target name="test-download" description="download test images.">
<mkdir dir="${test-input}" /> <mkdir dir="${test-input}" />
<get src="http://digitalcorpora.org/corp/nps/drives/nps-2009-canon2/nps-2009-canon2-gen6.E01" dest="${test-input}"/> <get src="http://digitalcorpora.org/corp/nps/drives/nps-2009-canon2/nps-2009-canon2-gen6.E01" dest="${test-input}"/>
<get src="http://digitalcorpora.org/corp/nps/drives/nps-2009-ntfs1/ntfs1-gen2.E01" dest="${test-input}"/> <get src="http://digitalcorpora.org/corp/nps/drives/nps-2009-ntfs1/ntfs1-gen2.E01" dest="${test-input}"/>
<!--<get src="http://www.cfreds.nist.gov/dfr-images/dfr-16-ext.dd.bz2" dest="${test-input}"/>
<bunzip2 src="${test-input}/dfr-16-ext.dd.bz2" /> -->
</target> </target>
<!-- all of the work is done in test-precond -->
<target name="test" <target name="test"
description="Traverses the Images stored in the path represented by test-input variable, creates results files stored in the path represented by test-results, and compares them to the standards stored in the path represented by the test-standards variable, always run test-create-standards at least once before before running test." description="Runs set of regression tests."
depends="compile-test, test-precond"> depends="compile-test, test-precond">
</target> </target>
<target name="test-create-standards"
description="Traverses the Images stored in the path represented by test-input variable and creates then stores them to the path represented by the test-standards variable, run test-download-imgs at least once before this." <target name="test-rebuild"
depends="compile-test, test-create-standards-precond"> description="Rebuilds gold standards."
depends="compile-test, test-rebuild-precond">
</target> </target>
</project> </project>
This file describes the tests. There are several test that are run, including:
- TopDown that tests getChildren() on each object.
- BottomUp that tests getParent() on each object.
- Sequentail that tests accessing random objects.
- CPPvsJava that verifies that the C++ output is the same as Java.
Not all test compare with a gold standard. Refer to each class for details. The following names are used in the output folder though:
- _TD: TopDown data that contains metadata about each file reached from getChildren(). This is checked in.
- _Seq: Sequentail test data that contains metadata about each file. This is checked in.
- _CPP: Body file format of files. This is not checked in.
- _BU: BottomUp data that contains paths to root from leaf nodes (i.e. files). This is not checked in.
...@@ -30,10 +30,13 @@ ...@@ -30,10 +30,13 @@
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
/** /**
* * Performs a "Bottom Up" test by verifying that calls to getParent() are
* Verifies that getParent works as intended by verifying that it gets the * the same as calls to getChildren() from the root (i.e. the TopDown test).
* same structure as we got from the TopDown tests. Does not compare against * Does not compare against a gold standard.
* a gold standard. * Basic concept is that TopDown test makes a "leaf file"
* with a line for each file that contains the list of parent IDs for the file.
* The code in this test starts at each leaf file, calls getParent() recursively,
* and verifies that the same IDs are reached.
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class BottomUpTest { public class BottomUpTest {
...@@ -103,7 +106,7 @@ public void testBottomUpDiff() { ...@@ -103,7 +106,7 @@ public void testBottomUpDiff() {
} }
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
System.out.println(ex.toString()); System.out.println(ex.toString());
fail("Failed to run BottomUp test"); fail("Failed to run BottomUp test: " + ex.getMessage());
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
List<Exception> inp = new ArrayList<Exception>(); List<Exception> inp = new ArrayList<Exception>();
inp.add(ex); inp.add(ex);
......
...@@ -36,8 +36,10 @@ ...@@ -36,8 +36,10 @@
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
/** /**
* * Compares the Java test output to the C++ test output.
* Compares the Java test output to the C++ test output * Basic concept is to run tsk_gettimes on an image to get the body
* file format and then make equivalent output from Java code. Diff.
* Does not use gold standards.
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class CPPtoJavaCompare extends ImgTraverser { public class CPPtoJavaCompare extends ImgTraverser {
...@@ -90,7 +92,7 @@ public void testCppToJavaDiff() { ...@@ -90,7 +92,7 @@ public void testCppToJavaDiff() {
ret.add(DataModelTestSuite.comparecontent(goldFilePathSorted, outputFilePathSorted)); ret.add(DataModelTestSuite.comparecontent(goldFilePathSorted, outputFilePathSorted));
assertEquals("Java output (" + outputFilePathSorted + ") differ with C++ results (" + goldFilePathSorted + ") .", ret.get(0), true); assertEquals("Java output (" + outputFilePathSorted + ") differ with C++ results (" + goldFilePathSorted + ") .", ret.get(0), true);
} catch (Exception ex) { } catch (Exception ex) {
fail("Couldn't open gold standard file."); fail("Couldn't open gold standard file. " + ex.getMessage());
} }
} }
......
...@@ -38,7 +38,7 @@ public abstract class ImgTraverser{ ...@@ -38,7 +38,7 @@ public abstract class ImgTraverser{
/** /**
* Run a test and compare the unsorted results. * Run a test and compare the unsorted results.
* *
* @return List of test results. Entry 0 is content and 1 is for exceptions. True if test passed. * @return List of test results. Entry 0 is exceptions and 1 is for content. True if test passed.
*/ */
public List<Boolean> basicTest() { public List<Boolean> basicTest() {
String title = DataModelTestSuite.getImgName(imagePaths.get(0)); String title = DataModelTestSuite.getImgName(imagePaths.get(0));
...@@ -51,7 +51,7 @@ public List<Boolean> basicTest() { ...@@ -51,7 +51,7 @@ public List<Boolean> basicTest() {
goldFilePath = DataModelTestSuite.standardFilePath(imagePaths, this.testName); goldFilePath = DataModelTestSuite.standardFilePath(imagePaths, this.testName);
goldExceptionsPath = DataModelTestSuite.exceptionPath(goldFilePath); goldExceptionsPath = DataModelTestSuite.exceptionPath(goldFilePath);
// Generate the sorted output needed for the test // Generate the sorted and unsorted output needed for the test
DataModelTestSuite.createOutput(outputFilePath, outputFolder.getAbsolutePath(), imagePaths, this); DataModelTestSuite.createOutput(outputFilePath, outputFolder.getAbsolutePath(), imagePaths, this);
// compare the unsorted results // compare the unsorted results
......
...@@ -34,12 +34,13 @@ ...@@ -34,12 +34,13 @@
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
/** /**
* * Tests that we get all of the results by directly requesting a specific
* Traverses an image by running through item Ids ascending. * object. Basic concept of test is to sequentially request objects, starting
* at 1. Details of each object are printed and results are compared with
* gold standard.
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class SequentialTraversal extends ImgTraverser { public class SequentialTraversal extends ImgTraverser {
private static final Logger logg = Logger.getLogger(SequentialTraversal.class.getName()); private static final Logger logg = Logger.getLogger(SequentialTraversal.class.getName());
public SequentialTraversal(List<String> imagePaths) { public SequentialTraversal(List<String> imagePaths) {
...@@ -75,7 +76,7 @@ public void testSequentialDiff() { ...@@ -75,7 +76,7 @@ public void testSequentialDiff() {
assertEquals("Generated results (" + outputExceptionsPath + ") differ with gold standard (" + goldExceptionsPath + ") .", test.get(0), true); assertEquals("Generated results (" + outputExceptionsPath + ") differ with gold standard (" + goldExceptionsPath + ") .", test.get(0), true);
assertEquals("Generated results (" + outputFilePath + ") differ with gold standard (" + goldFilePath + ") .", test.get(1), true); assertEquals("Generated results (" + outputFilePath + ") differ with gold standard (" + goldFilePath + ") .", test.get(1), true);
} catch (Exception ex) { } catch (Exception ex) {
fail("Couldn't open gold standard file."); fail("Couldn't open gold standard file." + ex.getMessage());
} }
} }
...@@ -85,8 +86,6 @@ public void testSequentialDiff() { ...@@ -85,8 +86,6 @@ public void testSequentialDiff() {
* *
* @param sk the sleuthkit case used for the traversal * @param sk the sleuthkit case used for the traversal
* @param path the location of the output file * @param path the location of the output file
* @param outputExceptionsPath the outputExceptionsPath to store exceptions, is only used for
* compatability with basic test
* @return the file writer to be closed by testStandard * @return the file writer to be closed by testStandard
*/ */
@Override @Override
...@@ -95,10 +94,14 @@ public OutputStreamWriter traverse(SleuthkitCase sk, String path) { ...@@ -95,10 +94,14 @@ public OutputStreamWriter traverse(SleuthkitCase sk, String path) {
try { try {
Charset chr = Charset.forName("UTF-8"); Charset chr = Charset.forName("UTF-8");
OutputStreamWriter reslt = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(path), 8192*4), chr); OutputStreamWriter reslt = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(path), 8192*4), chr);
int x = 1;
Content c;
try { try {
while ((c = sk.getContentById(x)) != null) { for (int x = 1; ;x++) {
Content c = sk.getContentById(x);
if (c == null) {
break;
}
reslt.append(((AbstractContent) c).toString(false).replaceAll("paths \\[([A-z]:)?.+?\\]", "")); reslt.append(((AbstractContent) c).toString(false).replaceAll("paths \\[([A-z]:)?.+?\\]", ""));
if (c instanceof File) { if (c instanceof File) {
DataModelTestSuite.hashContent(c, reslt, outputExceptionsPath); DataModelTestSuite.hashContent(c, reslt, outputExceptionsPath);
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
import org.junit.runners.Parameterized.Parameters; import org.junit.runners.Parameterized.Parameters;
/** /**
*
* Verifies that the current version of TSK produces the same output of previous * Verifies that the current version of TSK produces the same output of previous
* versions by doing a TopDown Depth first traversal of the given images. * versions by doing a TopDown Depth first traversal of the given images.
* Compares data to gold standards.
* Also generates the leaf file that is used by the BottomUp Test * Also generates the leaf file that is used by the BottomUp Test
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
...@@ -78,7 +78,7 @@ public void testTopDownDiff() { ...@@ -78,7 +78,7 @@ public void testTopDownDiff() {
assertEquals("Generated results (" + outputExceptionsPath + ") differ with gold standard (" + goldExceptionsPath + ") .", test.get(0), true); assertEquals("Generated results (" + outputExceptionsPath + ") differ with gold standard (" + goldExceptionsPath + ") .", test.get(0), true);
assertEquals("Generated results (" + outputFilePath + ") differ with gold standard (" + goldFilePath + ") .", test.get(1), true); assertEquals("Generated results (" + outputFilePath + ") differ with gold standard (" + goldFilePath + ") .", test.get(1), true);
} catch (Exception ex) { } catch (Exception ex) {
fail("Couldn't open gold standard file."); fail("Couldn't open gold standard file. " + ex.getMessage());
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment