Commit f5497eb3 authored by Hossain Mahmud's avatar Hossain Mahmud

1. edited test-campvis::main to generate xml regardless of environment var. 2....

1. edited test-campvis::main to generate xml regardless of environment var. 2. check is the result image null. 3. open and edit the gtest output xml with results from python test
parent e21b41c6
...@@ -38,3 +38,4 @@ if (CAMPVIS_GROUP_SOURCE_FILES) ...@@ -38,3 +38,4 @@ if (CAMPVIS_GROUP_SOURCE_FILES)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(TestCampvisSources ${CampvisHome}/test "") DEFINE_SOURCE_GROUPS_FROM_SUBDIR(TestCampvisSources ${CampvisHome}/test "")
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(TestCampvisHeaders ${CampvisHome}/test "") DEFINE_SOURCE_GROUPS_FROM_SUBDIR(TestCampvisHeaders ${CampvisHome}/test "")
ENDIF() ENDIF()
...@@ -142,7 +142,10 @@ GTEST_API_ int main(int argc, char **argv) { ...@@ -142,7 +142,10 @@ GTEST_API_ int main(int argc, char **argv) {
app = new QApplication(argc, argv); app = new QApplication(argc, argv);
testing::InitGoogleTest(&argc, argv); //testing::InitGoogleTest(&argc, argv);
int _argc = 2;
char *options[] = {"THIS DOESN'T HAVE ANY EFFECT", "--gtest_output=xml:visregtests/result.xml"};
testing::InitGoogleTest(&_argc, options);
int ret; int ret;
......
<testsuites disabled="0" errors="0" failures="2" name="AllTests" tests="49" time="2.535" timestamp="2014-08-24T01:35:42">
<testsuite disabled="0" errors="0" failures="0" name="DataContainerTest" tests="3" time="0.002">
<testcase classname="DataContainerTest" name="miscellaneousTest" status="run" time="0" />
<testcase classname="DataContainerTest" name="getDataHandlesCopyTest" status="run" time="0" />
<testcase classname="DataContainerTest" name="concurrentAccessTest" status="run" time="0.001" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="DataHandleTest" tests="2" time="0.001">
<testcase classname="DataHandleTest" name="getDataTest" status="run" time="0" />
<testcase classname="DataHandleTest" name="getTimestampTest" status="run" time="0" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="ImageDataTest" tests="2" time="0.002">
<testcase classname="ImageDataTest" name="miscellaneousTest" status="run" time="0" />
<testcase classname="ImageDataTest" name="cloneTest" status="run" time="0" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="ImageRepresentationTest" tests="3" time="0.03">
<testcase classname="ImageRepresentationTest" name="conversion_disk_local_gl_test" status="run" time="0.002" />
<testcase classname="ImageRepresentationTest" name="conversion_disk_gl_local_test" status="run" time="0.001" />
<testcase classname="ImageRepresentationTest" name="basetype_conversion_test" status="run" time="0.023" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="ImageSeriesTest" tests="2" time="0.002">
<testcase classname="ImageSeriesTest" name="miscellaneousTest" status="run" time="0" />
<testcase classname="ImageSeriesTest" name="cloneTest" status="run" time="0" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="NumericPropertyTest" tests="4" time="0.004">
<testcase classname="NumericPropertyTest" name="maxTest" status="run" time="0" />
<testcase classname="NumericPropertyTest" name="minTest" status="run" time="0" />
<testcase classname="NumericPropertyTest" name="increaseTest" status="run" time="0" />
<testcase classname="NumericPropertyTest" name="decreaseTest" status="run" time="0" />
</testsuite>
<testsuite disabled="0" errors="0" failures="1" name="StringPropertyTest" tests="3" time="0.004">
<testcase classname="StringPropertyTest" name="getSetValueTest" status="run" time="0.001">
<failure message="..\src\test\core\properties\stringpropertytest.cpp:74&#10;Value of: this-&gt;_strProp1.getValue()&#10; Actual: &quot;anotherValue2&quot;&#10;Expected: &quot;anotherValue&quot;" type="">..\src\test\core\properties\stringpropertytest.cpp:74
Value of: this-&gt;_strProp1.getValue()
Actual: "anotherValue2"
Expected: "anotherValue"</failure>
</testcase>
<testcase classname="StringPropertyTest" name="sharedPropertyTest" status="run" time="0.001" />
<testcase classname="StringPropertyTest" name="unlockTest" status="run" time="0.001" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="ConcurrentHistogram1DTest" tests="1" time="0.002">
<testcase classname="ConcurrentHistogram1DTest" name="concurrentAddSampleTest" status="run" time="0.002" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="ConcurrentHistogram2DTest" tests="1" time="0.099">
<testcase classname="ConcurrentHistogram2DTest" name="concurrentAddSampleTest" status="run" time="0.099" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="ConcurrentHistogram1DTestSpecific" tests="1" time="0.118">
<testcase classname="ConcurrentHistogram1DTestSpecific" name="concurrentAddSampleTest" status="run" time="0.117" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="ConcurrentHistogram2DTestSpecific" tests="1" time="0.131">
<testcase classname="ConcurrentHistogram2DTestSpecific" name="concurrentAddSampleTest" status="run" time="0.129" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="StringUtilTest" tests="6" time="0.005">
<testcase classname="StringUtilTest" name="caseOperationsTest" status="run" time="0" />
<testcase classname="StringUtilTest" name="parseFloatsTest" status="run" time="0" />
<testcase classname="StringUtilTest" name="splitTest" status="run" time="0" />
<testcase classname="StringUtilTest" name="replaceTest" status="run" time="0" />
<testcase classname="StringUtilTest" name="trimTest" status="run" time="0" />
<testcase classname="StringUtilTest" name="toStringTest" status="run" time="0" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="AbstractProcessorTest" tests="2" time="0.002">
<testcase classname="AbstractProcessorTest" name="invalidationTest" status="run" time="0.001" />
<testcase classname="AbstractProcessorTest" name="lockingTest" status="run" time="0.001" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="PipelineWriteResultImageTest" tests="3" time="1.998">
<testcase classname="PipelineWriteResultImageTest" name="VolumeExplorerDemo" status="run" time="1.362" />
<testcase classname="PipelineWriteResultImageTest" name="GeometryRendererDemo" status="run" time="0.311" />
<testcase classname="PipelineWriteResultImageTest" name="SliceVis" status="run" time="0.32" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="2DTest/GlReductionTest" tests="6" time="0.06">
<testcase classname="2DTest/GlReductionTest" name="isScopedLockWorking/0" status="run" time="0" value_param="2" />
<testcase classname="2DTest/GlReductionTest" name="localRepCreationTest/0" status="run" time="0" value_param="2" />
<testcase classname="2DTest/GlReductionTest" name="minTest/0" status="run" time="0.012" value_param="2" />
<testcase classname="2DTest/GlReductionTest" name="maxTest/0" status="run" time="0.012" value_param="2" />
<testcase classname="2DTest/GlReductionTest" name="sumTest/0" status="run" time="0.013" value_param="2" />
<testcase classname="2DTest/GlReductionTest" name="multTest/0" status="run" time="0.012" value_param="2" />
</testsuite>
<testsuite disabled="0" errors="0" failures="0" name="3DTest/GlReductionTest" tests="6" time="0.061">
<testcase classname="3DTest/GlReductionTest" name="isScopedLockWorking/0" status="run" time="0" value_param="3" />
<testcase classname="3DTest/GlReductionTest" name="localRepCreationTest/0" status="run" time="0.001" value_param="3" />
<testcase classname="3DTest/GlReductionTest" name="minTest/0" status="run" time="0.012" value_param="3" />
<testcase classname="3DTest/GlReductionTest" name="maxTest/0" status="run" time="0.012" value_param="3" />
<testcase classname="3DTest/GlReductionTest" name="sumTest/0" status="run" time="0.013" value_param="3" />
<testcase classname="3DTest/GlReductionTest" name="multTest/0" status="run" time="0.014" value_param="3" />
</testsuite>
<testsuite disabled="0" errors="0" failures="1" name="reference/1/" tests="3" time="0"><tastcase classname="reference/1/" name="geometryrendererdemo.png" status="run" time="0" /><tastcase classname="reference/1/" name="slicevis.png" status="run" time="0"><failure message="Image difference is not 0" type="">&lt;![CDATA[MESSAGE]]&gt;</failure></tastcase><tastcase classname="reference/1/" name="volumeexplorerdemo.png" status="run" time="0" /></testsuite></testsuites>
\ No newline at end of file
import os.path
# ================================================================================================ # ================================================================================================
# #
# This file is part of the CAMPVis Software Framework. # This file is part of the CAMPVis Software Framework.
...@@ -25,14 +26,25 @@ ...@@ -25,14 +26,25 @@
__author__="Mahmud" __author__="Mahmud"
__date__ ="$Jul 10, 2014 1:58:04 AM$" __date__ ="$Jul 10, 2014 1:58:04 AM$"
import numpy as np # import numpy as np
import matplotlib # import matplotlib
import matplotlib.pyplot as plt # import matplotlib.pyplot as plt
import matplotlib.image as mpimg # import matplotlib.image as mpimg
import os import os
from skimage import data, img_as_float, io from skimage import io#, img_as_float, data
from skimage.measure import structural_similarity as ssim #from skimage.measure import structural_similarity as ssim
import xml.etree.ElementTree as et
import numpy as np
from xml.etree import ElementTree
from xml.dom import minidom
# Return a pretty-printed XML string for the Element
def prettify(elem):
rough_string = ElementTree.tostring(elem, 'utf-8')
reparsed = minidom.parseString(rough_string)
return reparsed.toprettyxml(indent=" ")
refDir = 'reference/'; refDir = 'reference/';
testDir = 'testruns/'; testDir = 'testruns/';
...@@ -47,15 +59,27 @@ prevResDirs = os.listdir(resultDir); ...@@ -47,15 +59,27 @@ prevResDirs = os.listdir(resultDir);
# Create a new directory to store result # Create a new directory to store result
curRun = 0; curRun = 0;
for i in range(len(prevResDirs)) : for i in range(len(prevResDirs)) :
prevRunDirs[i] = int(prevRunDirs[i][4:]) prevRunDirs[i] = int(prevRunDirs[i][0:])
prevResDirs[i] = int(prevResDirs[i][4:]) prevResDirs[i] = int(prevResDirs[i][0:])
if (prevRunDirs[i] == prevResDirs[i]) : if (prevRunDirs[i] == prevResDirs[i]) :
curRun += 1; curRun += 1;
continue; continue;
break; break;
# List the test runs that are not computed yet
newTestDirs = prevRunDirs[curRun:]; newTestDirs = prevRunDirs[curRun:];
# Find or create results.xml file created by test-campvis
xmlFile = "result.xml";
if (os.path.isfile(xmlFile)) :
tree = et.parse(xmlFile);
root = tree.getroot();
else :
root = et.Element("testsuites", {"tests":"0", "failures":"0", "disabled":"0",
"errors":"0", "timestamp":"2014-08-24T01:35:42", "time":"0", "name":"AllTests"});
tree = et.ElementTree(root);
for test in newTestDirs : for test in newTestDirs :
curTestDir = testDir + str(prevRunDirs[curRun]) + "/"; curTestDir = testDir + str(prevRunDirs[curRun]) + "/";
resultSaveDir = resultDir + str(prevRunDirs[curRun]) + "/"; resultSaveDir = resultDir + str(prevRunDirs[curRun]) + "/";
...@@ -72,6 +96,11 @@ for test in newTestDirs : ...@@ -72,6 +96,11 @@ for test in newTestDirs :
os.mkdir(resCaseDir) os.mkdir(resCaseDir)
files = os.listdir(refCaseDir) files = os.listdir(refCaseDir)
if (len(files) != 0) :
suite = et.SubElement(root, "testsuite", {"name":refCaseDir, "tests":"0",
"failures":"0", "disabled":"0", "errors":"0", "time":"0"});
i = 0;
for file in files : for file in files :
refFilePath = refCaseDir + file; refFilePath = refCaseDir + file;
testFilePath = testCaseDir + file; testFilePath = testCaseDir + file;
...@@ -80,7 +109,8 @@ for test in newTestDirs : ...@@ -80,7 +109,8 @@ for test in newTestDirs :
if (not os.path.isfile(testFilePath)) : if (not os.path.isfile(testFilePath)) :
continue; continue;
if (refFilePath[-4:] != ".jpg" and refFilePath[-4:] != ".png" and refFilePath[-4:] != ".tif") : if (refFilePath[-4:] != ".jpg" and refFilePath[-4:] != ".png"
and refFilePath[-4:] != ".tif") :
continue; continue;
ref = io.imread(refFilePath); ref = io.imread(refFilePath);
...@@ -99,5 +129,23 @@ for test in newTestDirs : ...@@ -99,5 +129,23 @@ for test in newTestDirs :
#plt.tight_layout() #plt.tight_layout()
#plt.show() #plt.show()
case = et.SubElement(suite, "tastcase", {"name":file, "status":"run",
"time":"0", "classname":refCaseDir});
suite.set("tests", str(int(suite.get("tests"))+1));
root.set("tests", str(int(root.get("tests"))+1));
if (np.sum(test) != 0) :#
failure = et.SubElement(case, "failure", {"message":"", "type":""});
failure.set("message", "Image difference is not 0");
failure.text = "<![CDATA[" + \
"MESSAGE" + \
"]]>";
suite.set("failures", str(int(suite.get("failures")) + 1));
root.set("failures", str(int(root.get("failures")) + 1));
tree.write(xmlFile);
print "" print ""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment