Commit cf3bf0cf authored by Jan Möbius's avatar Jan Möbius

Version 1 of OpenFlipper test framework using ctest

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12865 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1f9abf4b
......@@ -43,6 +43,11 @@ add_subdirectory (OpenMesh/src/OpenMesh/Tools)
add_subdirectory (ACG)
add_subdirectory (OpenFlipper/PluginLib)
# ========================================================================
# Tests
# ========================================================================
add_subdirectory (tests)
# ========================================================================
# Documentation generators
# ========================================================================
......@@ -149,6 +154,10 @@ if (APPLE)
USE_SOURCE_PERMISSIONS)
endif ()
# ========================================================================
# Output log information
# ========================================================================
add_subdirectory (OpenFlipper/Unittests)
# ========================================================================
# Output log information
......
......@@ -39,7 +39,7 @@
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
void SmootherPlugin::initializePlugin()
void SkeletonTestPlugin::initializePlugin()
{
// Create the Toolbox Widget
QWidget* toolBox = new QWidget();
......@@ -69,7 +69,7 @@ void SmootherPlugin::initializePlugin()
/** \brief
*
*/
void SmootherPlugin::simpleLaplace() {
void SkeletonTestPlugin::simpleLaplace() {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS);
o_it != PluginFunctions::objectsEnd(); ++o_it) {
......@@ -205,5 +205,5 @@ void SmootherPlugin::simpleLaplace() {
}
Q_EXPORT_PLUGIN2( smootherplugin , SmootherPlugin );
Q_EXPORT_PLUGIN2( smootherplugin , SkeletonTestPlugin );
......@@ -6,7 +6,7 @@
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/common/Types.hh>
class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface
class SkeletonTestPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
......
......@@ -154,7 +154,7 @@ private slots:
/// Compute mean edge length and set values
void computeInitValues();
void slotAdaptiveRemeshing(int _objectId,
void slotAdaptiveRemeshing(int _objectId,
double _error,
double _min_edge_length,
double _max_edge_length,
......
# Include Testing package
INCLUDE(CTest)
if(BUILD_TESTING)
# ========================================================================
# Copy converter files from ctest output to junit output
# ========================================================================
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTest2JUnit.py
${CMAKE_BINARY_DIR}/tests/CTest2JUnit.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTest2JUnit.xsl
${CMAKE_BINARY_DIR}/tests//CTest2JUnit.xsl COPYONLY)
# ========================================================================
# ========================================================================
# Internal global tests start here
# ========================================================================
# ========================================================================
# ========================================================================
# Start OpenFlipper Headless in batch mode, to see if all plugins
# that pretend to be scriptable without ui are correct and the core
# can start
# ========================================================================
ADD_TEST(BatchStart ${CMAKE_BINARY_DIR}/Build/bin/OpenFlipper -b -c )
set_tests_properties (
BatchStart PROPERTIES
TIMEOUT 1
RUN_SERIAL TRUE
PROCESSORS 1
)
# ========================================================================
# ========================================================================
# ========================================================================
# Add tests from subdirectories
# ========================================================================
# ========================================================================
# ========================================================================
# search all libs in the libs directory
file (
GLOB _local_tests_in
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/*/CMakeLists.txt"
)
# add all found tests to the build
foreach (_localTest ${_local_tests_in})
get_filename_component (_local_test_dir ${_localTest} PATH)
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/${_local_test_dir})
endforeach ()
endif()
from lxml import etree
import StringIO
import sys
TAGfile = open(sys.argv[1]+"/Testing/TAG", 'r')
dirname = TAGfile.readline().strip()
xmlfile = open(sys.argv[1]+"/Testing/"+dirname+"/Test.xml", 'r')
xslfile = open(sys.argv[2], 'r')
xmlcontent = xmlfile.read()
xslcontent = xslfile.read()
xmldoc = etree.parse(StringIO.StringIO(xmlcontent))
xslt_root = etree.XML(xslcontent)
transform = etree.XSLT(xslt_root)
result_tree = transform(xmldoc)
print(result_tree)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/Site">
<testsuite>
<xsl:variable name="BuildName"><xsl:value-of select="@BuildName"/></xsl:variable>
<xsl:variable name="BuildStamp"><xsl:value-of select="@BuildStamp"/></xsl:variable>
<xsl:variable name="Name"><xsl:value-of select="@Name"/></xsl:variable>
<xsl:variable name="Generator"><xsl:value-of select="@Generator"/></xsl:variable>
<xsl:variable name="CompilerName"><xsl:value-of select="@CompilerName"/></xsl:variable>
<xsl:variable name="OSName"><xsl:value-of select="@OSName"/></xsl:variable>
<xsl:variable name="Hostname"><xsl:value-of select="@Hostname"/></xsl:variable>
<xsl:variable name="OSRelease"><xsl:value-of select="@OSRelease"/></xsl:variable>
<xsl:variable name="OSVersion"><xsl:value-of select="@OSVersion"/></xsl:variable>
<xsl:variable name="OSPlatform"><xsl:value-of select="@OSPlatform"/></xsl:variable>
<xsl:variable name="Is64Bits"><xsl:value-of select="@Is64Bits"/></xsl:variable>
<xsl:variable name="VendorString"><xsl:value-of select="@VendorString"/></xsl:variable>
<xsl:variable name="VendorID"><xsl:value-of select="@VendorID"/></xsl:variable>
<xsl:variable name="FamilyID"><xsl:value-of select="@FamilyID"/></xsl:variable>
<xsl:variable name="ModelID"><xsl:value-of select="@ModelID"/></xsl:variable>
<xsl:variable name="ProcessorCacheSize"><xsl:value-of select="@ProcessorCacheSize"/></xsl:variable>
<xsl:variable name="NumberOfLogicalCPU"><xsl:value-of select="@NumberOfLogicalCPU"/></xsl:variable>
<xsl:variable name="NumberOfPhysicalCPU"><xsl:value-of select="@NumberOfPhysicalCPU"/></xsl:variable>
<xsl:variable name="TotalVirtualMemory"><xsl:value-of select="@TotalVirtualMemory"/></xsl:variable>
<xsl:variable name="TotalPhysicalMemory"><xsl:value-of select="@TotalPhysicalMemory"/></xsl:variable>
<xsl:variable name="LogicalProcessorsPerPhysical"><xsl:value-of select="@LogicalProcessorsPerPhysical"/></xsl:variable>
<xsl:variable name="ProcessorClockFrequency"><xsl:value-of select="@ProcessorClockFrequency"/></xsl:variable>
<properties>
<property name="BuildName" value="{$BuildName}" />
<property name="BuildStamp" value="{$BuildStamp}" />
<property name="Name" value="{$Name}" />
<property name="Generator" value="{$Generator}" />
<property name="CompilerName" value="{$CompilerName}" />
<property name="OSName" value="{$OSName}" />
<property name="Hostname" value="{$Hostname}" />
<property name="OSRelease" value="{$OSRelease}" />
<property name="OSVersion" value="{$OSVersion}" />
<property name="OSPlatform" value="{$OSPlatform}" />
<property name="Is64Bits" value="{$Is64Bits}" />
<property name="VendorString" value="{$VendorString}" />
<property name="VendorID" value="{$VendorID}" />
<property name="FamilyID" value="{$FamilyID}" />
<property name="ModelID" value="{$ModelID}" />
<property name="ProcessorCacheSize" value="{$ProcessorCacheSize}" />
<property name="NumberOfLogicalCPU" value="{$NumberOfLogicalCPU}" />
<property name="NumberOfPhysicalCPU" value="{$NumberOfPhysicalCPU}" />
<property name="TotalVirtualMemory" value="{$TotalVirtualMemory}" />
<property name="TotalPhysicalMemory" value="{$TotalPhysicalMemory}" />
<property name="LogicalProcessorsPerPhysical" value="{$LogicalProcessorsPerPhysical}" />
<property name="ProcessorClockFrequency" value="{$ProcessorClockFrequency}" />
</properties>
<xsl:apply-templates select="Testing/Test"/>
<system-out>
BuildName: <xsl:value-of select="$BuildName" />
BuildStamp: <xsl:value-of select="$BuildStamp" />
Name: <xsl:value-of select="$Name" />
Generator: <xsl:value-of select="$Generator" />
CompilerName: <xsl:value-of select="$CompilerName" />
OSName: <xsl:value-of select="$OSName" />
Hostname: <xsl:value-of select="$Hostname" />
OSRelease: <xsl:value-of select="$OSRelease" />
OSVersion: <xsl:value-of select="$OSVersion" />
OSPlatform: <xsl:value-of select="$OSPlatform" />
Is64Bits: <xsl:value-of select="$Is64Bits" />
VendorString: <xsl:value-of select="$VendorString" />
VendorID: <xsl:value-of select="$VendorID" />
FamilyID: <xsl:value-of select="$FamilyID" />
ModelID: <xsl:value-of select="$ModelID" />
ProcessorCacheSize: <xsl:value-of select="$ProcessorCacheSize" />
NumberOfLogicalCPU: <xsl:value-of select="$NumberOfLogicalCPU" />
NumberOfPhysicalCPU: <xsl:value-of select="$NumberOfPhysicalCPU" />
TotalVirtualMemory: <xsl:value-of select="$TotalVirtualMemory" />
TotalPhysicalMemory: <xsl:value-of select="$TotalPhysicalMemory" />
LogicalProcessorsPerPhysical: <xsl:value-of select="$LogicalProcessorsPerPhysical" />
ProcessorClockFrequency: <xsl:value-of select="$ProcessorClockFrequency" />
</system-out>
</testsuite>
</xsl:template>
<xsl:template match="Testing/Test">
<xsl:variable name="testcasename"><xsl:value-of select= "Name"/></xsl:variable>
<xsl:variable name="exectime">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Execution Time'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<testcase name="{$testcasename}" classname="TestSuite" time="{$exectime}">
<xsl:if test="@Status = 'passed'">
</xsl:if>
<xsl:if test="@Status = 'failed'">
<xsl:variable name="failtype">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Exit Code'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="failcode">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Exit Value'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<error message="{$failtype} ({$failcode})"><xsl:value-of select="Results/Measurement/Value/text()" /></error>
</xsl:if>
<xsl:if test="@Status = 'notrun'">
<skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
</xsl:if>
</testcase>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
if(BUILD_TESTING)
add_executable (test_example test_example.cc )
set_target_properties (
test_example PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests"
)
ADD_TEST(NAME "Test_Example"
COMMAND ${CMAKE_BINARY_DIR}/tests/test_example )
set_tests_properties(
Test_Example PROPERTIES
TIMEOUT 10
)
endif()
// C++ Hello World
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
}
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