Commit 03800dab authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

Merge branch 'feature/asm-for-regression-test' into 'develop'

Feature/asm for regression test

See merge request !22
parents e01b24bb cf38c82b
......@@ -137,34 +137,37 @@ td.simple {
</style>
</head>
<body>
<div class="mainFrame">
<xsl:variable name="duration" select="/log:application/log:timeEnlapsed"/>
<!--
int milisec = (startTime->elapsed());
int mili = milisec % 1000;
int seconds = ((milisec % (3600000)) % (60000)) / 1000;
int minutes = (milisec % (3600000)) / (60000);
int hours = milisec / (3600000);
-->
<div class="mainFrame">
<div class="stateFrame">
<h1><xsl:value-of select="/log:application/log:name"/></h1>
<h2>Log file</h2>
<h3> Runned the <xsl:value-of select="/log:application/log:startDate"/></h3>
<h3> Start: <xsl:value-of select="/log:application/log:startTime"/> Stop: <xsl:value-of select="/log:application/log:endTime"/> </h3>
<h2> duration: <xsl:value-of select="floor($duration div 3600000)"/> h <xsl:value-of select="floor(($duration mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($duration mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($duration mod 1000)"/> ms</h2>
<h3>Input xml file name: <xsl:value-of select="/log:application/log:inputXmlFile"/></h3>
<h2> duration: <xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="/log:application/log:timeEnlapsed"/>
</xsl:call-template>
</h2>
<h3>Input xml file name: <xsl:value-of select="/log:application/log:inputXmlFile"/></h3>
</div>
<div class="stateFrame">
<xsl:variable name="timeStateTotal" select="sum(log:application/log:state/log:timeEnlapsed)"/>
<xsl:variable name="timeActionTotal" select="sum(log:application/log:transition/log:timeEnlapsed)"/>
<h3>Total time within states:
<span class="stateColor"><xsl:value-of select="floor($timeStateTotal div 3600000)"/> h <xsl:value-of select="floor(($timeStateTotal mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($timeStateTotal mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($timeStateTotal mod 1000)"/> (i.e. <xsl:value-of select="$timeStateTotal"/> ms)</span>
<h3>Total time within states (action triggering):
<span class="stateColor">
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="sum(log:application/log:state/log:timeEnlapsed)"/>
</xsl:call-template>
(i.e., <xsl:value-of select="sum(log:application/log:state/log:timeEnlapsed)"/> ms)</span>
</h3>
<h3>Total time on action application:
<span class="actionColor"><xsl:value-of select="floor($timeActionTotal div 3600000)"/> h <xsl:value-of select="floor(($timeActionTotal mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($timeActionTotal mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($timeActionTotal mod 1000)"/> (i.e. <xsl:value-of select="$timeActionTotal"/> ms)</span>
<span class="actionColor">
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="sum(log:application/log:transition/log:timeEnlapsed)"/>
</xsl:call-template>
(i.e., <xsl:value-of select="sum(log:application/log:transition/log:timeEnlapsed)"/> ms)</span>
</h3>
<table>
<tr>
......@@ -191,9 +194,10 @@ td.simple {
</div></span>
</td>
<td>
<xsl:variable name="stateD" select="log:timeEnlapsed"/>
<span class="stateColor">
<xsl:value-of select="floor(($stateD mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($stateD mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($stateD mod 1000)"/> ms
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="log:timeEnlapsed"/>
</xsl:call-template>
</span>
</td>
</tr>
......@@ -225,34 +229,36 @@ td.simple {
</table>
</td>
<td>
<xsl:variable name="transD" select="../log:timeEnlapsed"/>
<span class="actionColor">
<xsl:value-of select="floor(($transD mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($transD mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($transD mod 1000)"/> ms
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="../log:timeEnlapsed"/>
</xsl:call-template>
</span>
</td>
</tr>
</xsl:template>
<xsl:template match="log:closing">
<xsl:template match="log:closing">
<tr>
<td colspan="2">
<span class="actionColor"><span class="enhanced">Closing:</span></span>
<span class="actionColor"><span class="enhanced">Closing:</span></span>
</td>
</tr>
<tr>
<td>
<table class="simple">
<xsl:apply-templates select="log:component"/>
</table>
</td>
<td>
<xsl:variable name="transD" select="../log:timeEnlapsed"/>
<tr>
<td>
<table class="simple">
<xsl:apply-templates select="log:component"/>
</table>
</td>
<td>
<span class="actionColor">
<xsl:value-of select="floor(($transD mod 3600000) div 3600000)"/> min <xsl:value-of select="floor((($transD mod (3600000)) mod (60000)) div 1000)"/> s <xsl:value-of select="floor($transD mod 1000)"/> ms
<xsl:call-template name="formatTime">
<xsl:with-param name="timeElapsed" select="../log:timeEnlapsed"/>
</xsl:call-template>
</span>
</td>
</tr>
</xsl:template>
</td>
</tr>
</xsl:template>
<xsl:template match="log:parameters">
<table class="simple">
......@@ -316,4 +322,22 @@ td.simple {
</td>
</tr>
</xsl:template>
<xsl:template name="formatTime">
<xsl:param name="timeElapsed" select="/log:application/log:timeEnlapsed"/>
<!--
int milisec = (startTime->elapsed());
int mili = milisec % 1000;
int seconds = ((milisec % (3600000)) % (60000)) / 1000;
int minutes = (milisec % (3600000)) / (60000);
int hours = milisec / (3600000);
-->
<xsl:variable name="hours" select="floor($timeElapsed div 3600000)"/>
<xsl:variable name="minutes" select="floor(($timeElapsed - $hours * 3600000) div 60000)"/>
<xsl:variable name="secondes" select="floor(($timeElapsed - $hours * 3600000 - $minutes * 60000) div 1000)"/>
<xsl:variable name="msec" select="floor($timeElapsed - $hours * 3600000 - $minutes * 60000 -$secondes * 1000)"/> <xsl:if test="$hours > 0"><xsl:value-of select="$hours"/> h </xsl:if>
<xsl:if test="$minutes > 0"><xsl:value-of select="$minutes"/> min </xsl:if>
<xsl:if test="$secondes > 0"><xsl:value-of select="$secondes"/> s </xsl:if>
<xsl:if test="$msec > 0"><xsl:value-of select="$msec"/> ms</xsl:if>
</xsl:template>
</xsl:stylesheet>
......@@ -28,7 +28,7 @@ include(camitk/manifest/CamiTKWriteManifestData)
# -- CamiTK test macros (see also http://www.org/cmake/help/v2.8.8/cmake.html#section_PropertiesonTests)
include(camitk/test/CamiTKInitTest)
include(camitk/test/CamiTKAddTest)
include(camitk/test/CamiTKAddTestActionStateMachine)
include(camitk/test/CamiTKAddIntegrationTest)
include(camitk/test/CamiTKAdditionalActionTest)
# -- packaging macros
......
......@@ -29,7 +29,7 @@
#! [TARGET_NAME non-default-targetname]
#! [DESCRIPTION description]
#! [EXTRA_TRANSLATE_LANGUAGE]
#! [AUTO_TEST]
#! [ENABLE_AUTO_TEST]
#! [TEST_FILES file1 file2 ...]
#! [AUTO_TEST_LEVEL 1]
#! [AUTO_TEST_LEVEL 2]
......@@ -71,7 +71,7 @@
#! No CEP_NAME provided will result in default categorization (generic extension).
#! \param DESCRIPTION = Simple description of the extension. Used for packaging presentation for instance.
#! \param EXTRA_TRANSLATE_LANGUAGE = Additionnal extra language to translate the application
#! \param AUTO_TEST = Create automatic test with either testactions or testcomponents.
#! \param ENABLE_AUTO_TEST = Create automatic test with either testactions or testcomponents.
#! By default, auto test are run at the highlest level (level 3) unless AUTO_TEST_LEVEL is specified
#! See also TEST_FILES and AUTO_TEST_LEVEL options
#! \param TEST_FILES = List of files to use for testing.
......@@ -106,7 +106,7 @@ macro(camitk_extension)
get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} EXTENSION_NAME)
set(options ACTION_EXTENSION COMPONENT_EXTENSION DISABLED NEEDS_XERCESC NEEDS_ITK NEEDS_LIBXML2 NEEDS_XSD NEEDS_OPENCV NEEDS_IGSTK INSTALL_ALL_HEADERS NEEDS_GDCM AUTO_TEST)
set(options ACTION_EXTENSION COMPONENT_EXTENSION DISABLED NEEDS_XERCESC NEEDS_ITK NEEDS_LIBXML2 NEEDS_XSD NEEDS_OPENCV NEEDS_IGSTK INSTALL_ALL_HEADERS NEEDS_GDCM ENABLE_AUTO_TEST ENABLE_INTEGRATION_TEST)
set(oneValueArgs TARGET_NAME CEP_NAME DESCRIPTION AUTO_TEST_LEVEL)
set(multiValueArgs NEEDS_TOOL NEEDS_CEP_LIBRARIES NEEDS_COMPONENT_EXTENSION NEEDS_ACTION_EXTENSION INCLUDE_DIRECTORIES EXTERNAL_LIBRARIES HEADERS_TO_INSTALL DEFINES CXX_FLAGS EXTERNAL_SOURCES EXTRA_TRANSLATE_LANGUAGE TEST_FILES)
cmake_parse_arguments(${EXTENSION_NAME_CMAKE} "${options}" "${oneValueArgs}"
......@@ -822,7 +822,7 @@ macro(camitk_extension)
#########################################################################
# if auto test possible and required
if (NOT PACKAGING_NSIS AND BUILD_TESTING AND ${EXTENSION_NAME_CMAKE}_AUTO_TEST)
if (NOT PACKAGING_NSIS AND BUILD_TESTING AND ${EXTENSION_NAME_CMAKE}_ENABLE_AUTO_TEST)
if(${EXTENSION_NAME_CMAKE}_COMPONENT_EXTENSION)
camitk_init_test( camitk-testcomponents )
......@@ -935,8 +935,19 @@ macro(camitk_extension)
camitk_parse_test_add(NAME ${CAMITK_TEST_NAME} LEVEL 1 DESCRIPTION "Open a file, load the action and apply it on the component.")
endforeach()
endif()
endif() # NOT PACKAGING_NSIS AND BUILD_TESTING AND ${EXTENSION_NAME_CMAKE}_AUTO_TEST)
endif() # NOT PACKAGING_NSIS AND BUILD_TESTING AND ${EXTENSION_NAME_CMAKE}_ENABLE_AUTO_TEST)
#########################################################################
# #
# CTEST - Integration test #
# #
#########################################################################
if (NOT PACKAGING_NSIS AND BUILD_TESTING AND ${EXTENSION_NAME_CMAKE}_ENABLE_INTEGRATION_TEST)
# add a specific test to run the action, save the output and compare it to expected
camitk_add_integration_test()
endif()
endif() # endif(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE})
endmacro()
......
#!
#! @ingroup group_sdk_cmake_camitk_test
#!
#! camitk_add_test_actionstatemachine is a macro to add a new test to the CTest infrastructure
#! camitk_add_integration_test is a macro to add a new test to the CTest infrastructure
#! It encapsulates CMake add_test and use the action state machine to run a set of actions.
#! The set of actions are described in a CamiTK SCXML document. This macro is used to
#! add integration tests.
#!
#! Details on the runned test can be found in ${CMAKE_BINARY_DIR}/Testing/Temporary/target#
#! where target is the executable name (see camitk_init_test() macro), and # is the test order number.
#! Details on the runned test can be found in directory
#! ${CMAKE_BINARY_DIR}/Testing/Temporary/${TYPE_EXTENSION}-${EXTENSION_NAME}-integration-test
#!
#! It is typically usued inside the camitk_extension(..) macro and expects the following variable
#! to be set beforehand:
#! - TYPE_EXTENSION action or component)
#! - EXTENSION_NAME name of the current action or component
#!
#! It does add a test if and only if:
#! - ${CMAKE_CURRENT_SOURCE_DIR}/integration-testdata exists
#! - ${CMAKE_CURRENT_SOURCE_DIR}/integration-testdata contains an file called "asm-input.scxml"
#! - ${CMAKE_CURRENT_SOURCE_DIR}/integration-testdata contains at least one file name "output-*.*"
#!
#! Usage:
#! \code
#! camitk_add_test_actionstatemachine(NAME "testName"
#! CAMITK_SCXML "file.xml"
#! EXPECTED_OUTPUT_FILES file1 file2 file3...
#! )
#! camitk_add_integration_test()
#! \endcode
#!
#! It creates a target name
#!
#! \param NAME Name of the test, use "ctest -V -R testName" to run the test individually
#! \param CAMITK_SCXML The input xml file
#! \param EXPECTED_OUTPUT_FILES List of files that have to be compared with the asm output
#!
macro(camitk_add_test_actionstatemachine)
set(options "")
set(oneValueArgs NAME CAMITK_SCXML)
set(multiValueArgs EXPECTED_OUTPUT_FILES)
cmake_parse_arguments(CAMITK_ADD_TEST_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
macro(camitk_add_integration_test)
# determine cmake macro path
if (NOT EXISTS ${SDK_TOP_LEVEL_SOURCE_DIR})
# this macro is called outside the sdk
set(CAMITK_CMAKE_MACRO_PATH ${CAMITK_CMAKE_DIR}/modules/macros/camitk/test)
if(NOT IS_DIRECTORY ${CAMITK_CMAKE_MACRO_PATH})
# inside communityedition but not in sdk (modeling or imaging)
set(CAMITK_CMAKE_MACRO_PATH ${CMAKE_SOURCE_DIR}/sdk/cmake/modules/macros/camitk/test)
endif()
else()
# directly use the macro source dir
set(CAMITK_CMAKE_MACRO_PATH ${SDK_TOP_LEVEL_SOURCE_DIR}/cmake/modules/macros/camitk/test)
endif()
#-- set the name of the current test and other parameters
set(CAMITK_INTEGRATION_TEST_NAME ${TYPE_EXTENSION}-${EXTENSION_NAME}-integration-test)
#-- check integration data availability
set(CAMITK_INTEGRATION_TESTDATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/integration-testdata)
if (NOT EXISTS ${CAMITK_INTEGRATION_TESTDATA_DIR})
message(FATAL_ERROR "Can not add test ${CAMITK_INTEGRATION_TEST_NAME}: \"integration-testdata\" subdirectory not found." )
endif()
set(CAMITK_INTEGRATION_SCXML asm-input.scxml)
if (NOT EXISTS ${CAMITK_INTEGRATION_TESTDATA_DIR})
message(FATAL_ERROR "Can not add test ${CAMITK_INTEGRATION_TEST_NAME}: CamiTK SCXML document not found." )
endif()
# look for all the files that called "output-*"
file(GLOB CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES RELATIVE ${CAMITK_INTEGRATION_TESTDATA_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/integration-testdata/output-*.*)
list(LENGTH CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES NUMBER_OF_EXPECTED_OUTPUT_FILES)
if (NUMBER_OF_EXPECTED_OUTPUT_FILES EQUAL 0)
message(FATAL_ERROR "Can not add test ${CAMITK_INTEGRATION_TEST_NAME}: no expected output file found." )
endif()
#-- clean/create test output directory
set(CAMITK_TEST_OUTPUT_DIR "${CMAKE_BINARY_DIR}/Testing/Temporary/${CAMITK_ADD_TEST_ASM_NAME}")
set(CAMITK_TEST_OUTPUT_DIR "${CMAKE_BINARY_DIR}/Testing/Temporary/${CAMITK_INTEGRATION_TEST_NAME}")
file(REMOVE_RECURSE ${CAMITK_TEST_OUTPUT_DIR})
file(MAKE_DIRECTORY ${CAMITK_TEST_OUTPUT_DIR})
#-- replace the input file names
# Read the file in a variable
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/testdata/${CAMITK_ADD_TEST_ASM_CAMITK_SCXML} ASM_INPUT_FILE_AS_STRING)
file(READ ${CAMITK_INTEGRATION_TESTDATA_DIR}/${CAMITK_INTEGRATION_SCXML} ASM_INPUT_FILE_AS_STRING)
# get all the lines that have a non-empty "File Name" parameter
string(REGEX MATCHALL "<camitk:parameter name=\"File Name\" value=\".*\" type=\"QString\"/>" FILENAME_LINES "${ASM_INPUT_FILE_AS_STRING}")
# intialize ASM_INPUT_FILE_AS_STRING_OK
......@@ -55,14 +62,14 @@ macro(camitk_add_test_actionstatemachine)
# for each lines that have a non-empty "File Name" parameter
foreach(CURRENT_LINE ${FILENAME_LINES})
# first replace the file name so that the file can be copied to the temp directory
string(REGEX REPLACE "value=\"(.*)\"" "value=\"${CAMITK_TEST_OUTPUT_DIR}/\\1\"" CURRENT_LINE_OK "${CURRENT_LINE}")
string(REGEX REPLACE "value=\"(.*)\"" "value=\"${CAMITK_TEST_OUTPUT_DIR}/\\1\"" CURRENT_LINE_OK ${CURRENT_LINE})
# second replace the line in ASM_INPUT_FILE_AS_STRING_OK
string(REPLACE "${CURRENT_LINE}" "${CURRENT_LINE_OK}" ASM_INPUT_FILE_AS_STRING_OK "${ASM_INPUT_FILE_AS_STRING_OK}")
# extract the File Name
string(REGEX REPLACE ".*value=\"(.*)\" .*" "\\1" INPUT_FILE_NAME "${CURRENT_LINE}")
string(REGEX REPLACE ".*value=\"(.*)\" .*" "\\1" INPUT_FILE_NAME ${CURRENT_LINE})
# copy the corresponding file to the temp directory
# message("===== Input File = ${INPUT_FILE_NAME}")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/testdata/${INPUT_FILE_NAME}
file(COPY ${CAMITK_INTEGRATION_TESTDATA_DIR}/${INPUT_FILE_NAME}
DESTINATION ${CAMITK_TEST_OUTPUT_DIR})
endforeach()
......@@ -70,65 +77,101 @@ macro(camitk_add_test_actionstatemachine)
# Beware/Note: you need to add the quote around the ASM_INPUT_FILE_AS_STRING_OK value otherwise ";" will be
# interprated as list/argument separator and will be transformed to " " (for XML files that means that each
# substitution will get damaged: &lt; -> &lt ... not good...)
file(WRITE ${CAMITK_TEST_OUTPUT_DIR}/${CAMITK_ADD_TEST_ASM_CAMITK_SCXML} "${ASM_INPUT_FILE_AS_STRING_OK}")
file(WRITE ${CAMITK_TEST_OUTPUT_DIR}/${CAMITK_INTEGRATION_SCXML} "${ASM_INPUT_FILE_AS_STRING_OK}")
# And copy the expected output files
foreach(EXPECTED_OUTPUT_FILE ${CAMITK_ADD_TEST_ASM_EXPECTED_OUTPUT_FILES})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/testdata/${EXPECTED_OUTPUT_FILE}
foreach(EXPECTED_OUTPUT_FILE ${CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES})
file(COPY ${CAMITK_INTEGRATION_TESTDATA_DIR}/${EXPECTED_OUTPUT_FILE}
DESTINATION ${CAMITK_TEST_OUTPUT_DIR})
endforeach()
#-- run actionstatemachine
set(CAMITK_TEST_EXECUTABLE_ARG "-f ${CAMITK_TEST_OUTPUT_DIR}/${CAMITK_ADD_TEST_ASM_CAMITK_SCXML} -o ${CAMITK_TEST_OUTPUT_DIR} -a")
set(CAMITK_TEST_EXECUTABLE_ARG "-f ${CAMITK_TEST_OUTPUT_DIR}/${CAMITK_INTEGRATION_SCXML} -o ${CAMITK_TEST_OUTPUT_DIR} -a")
# determine path to camitk-actionstatemachine executable
if(NOT CAMITK_COMMUNITY_EDITION_BUILD)
# this macro is called outside the CE build
set(CAMITK_ASM_EXE ${CAMITK_BIN_DIR}/camitk-actionstatemachine)
if (WIN32 AND NOT EXISTS ${CAMITK_ASM_EXE})
set(CAMITK_ASM_EXE ${CAMITK_BIN_DIR}/camitk-actionstatemachine${CAMITK_DEBUG_POSTFIX})
#-- determine cmake macro path
if (NOT EXISTS SDK_TOP_LEVEL_SOURCE_DIR)
# this macro is called outside the sdk
set(CAMITK_CMAKE_MACRO_PATH ${CAMITK_CMAKE_DIR}/modules/macros/camitk/test)
if(NOT IS_DIRECTORY ${CAMITK_CMAKE_MACRO_PATH})
# inside opensource but not in sdk (modeling or imaging)
set(CAMITK_CMAKE_MACRO_PATH ${CMAKE_SOURCE_DIR}/sdk/cmake/modules/macros/camitk/test)
endif()
else()
# in CE build, use the binary dir version
set(CAMITK_ASM_EXE ${CMAKE_BINARY_DIR}/bin/camitk-actionstatemachine)
# directly use the macro source dir
set(CAMITK_CMAKE_MACRO_PATH ${SDK_TOP_LEVEL_SOURCE_DIR}/cmake/modules/macros/camitk/test)
endif()
#-- check if debug postfix is needed
set(APP_NAME camitk-actionstatemachine)
if(NOT CAMITK_COMMUNITY_EDITION_BUILD)
# this macro is called outside CamiTK CE
# find the complete path to the test programs (removing any previous attempt to find a test application
# as this could be another application)
unset(CAMITK_INTEGRATION_TEST_EXECUTABLE CACHE)
find_program(CAMITK_INTEGRATION_TEST_EXECUTABLE
NAMES ${APP_NAME}${CAMITK_DEBUG_POSTFIX} ${APP_NAME}
PATH_SUFFIXES "bin"
PATHS ${CAMITK_BIN_DIR}
)
if (NOT CAMITK_INTEGRATION_TEST_EXECUTABLE)
# Test programs should be installed
message(FATAL_ERROR "${APP_NAME} not found.\n This means that action state machine was not installed during CamiTK SDK installation.")
endif()
else()
# in CamiTK CE build
# add debug postfix if needed by MSVC
set(APP_SUFFIX "")
# determine which version of the executable to use (debug-suffixed or not)
if(MSVC)
if(NOT CMAKE_BUILD_TYPE)
# Assume the developer that is running the communityedition test suite compiled everything in Debug
set(CAMITK_ASM_EXE ${CAMITK_ASM_EXE}${CAMITK_DEBUG_POSTFIX})
# Assume the developer that is running the test suite compiled everything in Debug
set(APP_SUFFIX ${CAMITK_DEBUG_POSTFIX})
else()
# support multiplaform (sometimes the "Debug" type is all uppercase, as on Win32, sometimes it is Camelcase)
# support multiplaform (sometimes the "Debug" type is all uppercase, as on Win32, sometimes it is CamelCase)
string(TOUPPER ${CMAKE_BUILD_TYPE} CAMITK_BUILD_TYPE_UPPER)
if (CAMITK_BUILD_TYPE_UPPER STREQUAL "DEBUG")
# manage debug build only
set(CAMITK_ASM_EXE ${CAMITK_ASM_EXE}${CAMITK_DEBUG_POSTFIX})
set(APP_SUFFIX ${CAMITK_DEBUG_POSTFIX})
endif()
# if build type is not debug, everything is ok as CAMITK_ASM_EXE is already set to the non-suffixed version
# if build type is not debug, everything is ok as
endif()
endif()
# In CamiTK CE build directly use the binary dir version
set(CAMITK_INTEGRATION_TEST_EXECUTABLE ${CMAKE_BINARY_DIR}/bin/${APP_NAME}${APP_SUFFIX})
endif()
# if CE is not being build and actionstationmachine executable cannot be found, this test can be added
if(NOT CAMITK_COMMUNITY_EDITION_BUILD AND NOT EXISTS ${CAMITK_ASM_EXE})
message(WARNING "Cannot add test \"${CAMITK_ADD_TEST_ASM_NAME}\": camitk-actionstatemachine executable not found.")
else()
# all ok, add the test (either outside sdk build and asm is found or inside sdk build)
add_test(NAME ${CAMITK_ADD_TEST_ASM_NAME}
COMMAND ${CMAKE_COMMAND}
-DCAMITK_TEST_COMMAND=${CAMITK_ASM_EXE}
-DCAMITK_TEST_COMMAND_ARG=${CAMITK_TEST_EXECUTABLE_ARG}
-DCAMITK_TEST_EXPECTED_FILES=${CAMITK_ADD_TEST_ASM_EXPECTED_OUTPUT_FILES}
-DCAMITK_TEST_OUTPUT_DIR=${CAMITK_TEST_OUTPUT_DIR}
-DCAMITK_TEST_NAME=${CAMITK_ADD_TEST_ASM_NAME}
-P ${CAMITK_CMAKE_MACRO_PATH}/CamiTKTestActionStateMachine.cmake
)
# set the label for tests / associate tests to a project name in CDash
if( CAMITK_ADD_TEST_PROJECT_NAME )
set_tests_properties( ${CAMITK_ADD_TEST_ASM_NAME} PROPERTIES LABELS ${CAMITK_ADD_TEST_PROJECT_NAME} )#
#-- and add the test
# Construct a specific string for outputfiles to pass them properly to the test command
unset(CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES_ARG)
foreach(TEST_EXPECTED_OUTPUT_FILE ${CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES})
# add specific "::" separator
if(CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES_ARG)
string(CONCAT CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES_ARG "${CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES_ARG}::${TEST_EXPECTED_OUTPUT_FILE}")
else()
set_tests_properties( ${CAMITK_ADD_TEST_ASM_NAME} PROPERTIES LABELS ${CAMITK_ADD_TEST_ASM_NAME} )
set(CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES_ARG ${TEST_EXPECTED_OUTPUT_FILE})
endif()
endif()
endforeach()
add_test(NAME ${CAMITK_INTEGRATION_TEST_NAME}
COMMAND ${CMAKE_COMMAND}
-DCAMITK_TEST_COMMAND=${CAMITK_INTEGRATION_TEST_EXECUTABLE}
-DCAMITK_TEST_COMMAND_ARG=${CAMITK_TEST_EXECUTABLE_ARG}
-DCAMITK_TEST_EXPECTED_FILES=${CAMITK_INTEGRATION_TEST_EXPECTED_OUTPUT_FILES_ARG}
-DCAMITK_TEST_OUTPUT_DIR=${CAMITK_TEST_OUTPUT_DIR}
-DCAMITK_TEST_NAME=${CAMITK_INTEGRATION_TEST_NAME}
-P ${CAMITK_CMAKE_MACRO_PATH}/CamiTKTestActionStateMachine.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} # needs to be at the top of the CamiTK module repository
)
# set the label for tests / associate tests to a project name in CDash
if( CAMITK_ADD_TEST_PROJECT_NAME )
set_tests_properties( ${CAMITK_INTEGRATION_TEST_NAME} PROPERTIES LABELS ${CAMITK_ADD_TEST_PROJECT_NAME} )#
else()
set_tests_properties( ${CAMITK_INTEGRATION_TEST_NAME} PROPERTIES LABELS ${CAMITK_INTEGRATION_TEST_NAME} )
endif()
endmacro()
......@@ -75,7 +75,7 @@ macro(camitk_init_test)
if (NOT CAMITK_INIT_TEST_EXECUTABLE)
# Test programs should be installed
message(FATAL_ERROR "${TEST_APPLICATION_ARG} not found.\n This means that automatic test applications were not installed during CamiTK SDK installation.")
message(FATAL_ERROR "${APP_NAME} not found.\n This means that automatic test applications were not installed during CamiTK SDK installation.")
endif()
else()
# in CamiTK CE build
......@@ -88,7 +88,7 @@ macro(camitk_init_test)
# Assume the developer that is running the test suite compiled everything in Debug
set(APP_SUFFIX ${CAMITK_DEBUG_POSTFIX})
else()
# support multiplaform (sometimes the "Debug" type is all uppercase, as on Win32, sometimes it is Camelcase)
# support multiplaform (sometimes the "Debug" type is all uppercase, as on Win32, sometimes it is CamelCase)
string(TOUPPER ${CMAKE_BUILD_TYPE} CAMITK_BUILD_TYPE_UPPER)
if (CAMITK_BUILD_TYPE_UPPER STREQUAL "DEBUG")
# manage debug build only
......
#!
#! @ingroup group_sdk_cmake_camitk_test
#!
#! This CMake file run the action state machine and compare the output files to the expected files
#! The intended use is to execute this script from the camitk_add_test_actionstatemachine
#! This CMake script run the action state machine and compare the output files to the expected files
#! The intended use is to run this script from the camitk_add_test_actionstatemachine
#!
#! Usage:
#! \code
......@@ -62,17 +62,21 @@ execute_process(
COMMAND ${CAMITK_TEST_COMMAND} ${CAMITK_TEST_COMMAND_ARG_LIST}
RESULT_VARIABLE CAMITK_TEST_COMMAND_RESULT
OUTPUT_VARIABLE CAMITK_TEST_COMMAND_OUTPUT
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
file(WRITE ${CAMITK_TEST_COMMAND_RESULT_FILE} ${CAMITK_TEST_COMMAND_RESULT})
file(WRITE ${CAMITK_TEST_COMMAND_OUTPUT_FILE} ${CAMITK_TEST_COMMAND_OUTPUT})
set(CAMITK_TEST_EXPECTED_FILE_OUTPUT "Action state machine regression test called with:\n - CAMITK_TEST_NAME=${CAMITK_TEST_NAME}\n - CAMITK_TEST_COMMAND=${CMAKE_BINARY_DIR}/bin/camitk-actionstatemachine\n - CAMITK_TEST_COMMAND_ARG=${CAMITK_TEST_COMMAND_ARG}\n - CAMITK_TEST_EXPECTED_FILES=${CAMITK_TEST_EXPECTED_FILES}\n - CAMITK_TEST_OUTPUT_DIR=${CAMITK_TEST_OUTPUT_DIR}\n")
# Transform back the "::" separated list of expected output to a classic ";" separated string
string(REPLACE "::" ";" CAMITK_TEST_EXPECTED_FILES_LIST ${CAMITK_TEST_EXPECTED_FILES})
set(CAMITK_TEST_EXPECTED_FILE_OUTPUT "Action state machine regression test called with:\n - CAMITK_TEST_NAME=${CAMITK_TEST_NAME}\n - CAMITK_TEST_COMMAND=${CMAKE_BINARY_DIR}/bin/camitk-actionstatemachine\n - CAMITK_TEST_COMMAND_ARG=${CAMITK_TEST_COMMAND_ARG}\n - CAMITK_TEST_EXPECTED_FILES=${CAMITK_TEST_EXPECTED_FILES_LIST}\n - CAMITK_TEST_OUTPUT_DIR=${CAMITK_TEST_OUTPUT_DIR}\n")
set(CAMITK_TEST_EXPECTED_FILE_RESULT 0)
set(CAMITK_TEST_EXPECTED_FILE_COMMAND)
set(CAMITK_TEST_FAILED_FILE)
#-- Then compare each expected output
foreach(EXPECTED_OUTPUT_FILE ${CAMITK_TEST_EXPECTED_FILES})
foreach(EXPECTED_OUTPUT_FILE ${CAMITK_TEST_EXPECTED_FILES_LIST})
# find the same file in the asm output directory (*T*)
file(GLOB_RECURSE OUTPUT_FILE "${CAMITK_TEST_OUTPUT_DIR}/*T*/${EXPECTED_OUTPUT_FILE}")
......@@ -108,7 +112,7 @@ file(WRITE ${CAMITK_TEST_EXPECTED_FILE_RESULT_FILE} ${CAMITK_TEST_EXPECTED_FILE_
#-- check result
if( CAMITK_TEST_EXPECTED_FILE_RESULT )
message("[FAIL]")
message(FATAL_ERROR "${CAMITK_TEST_NAME}: (one or more) output file do(es) not match the corresponding expected file\nSee ${CAMITK_TEST_EXPECTED_FILE_OUTPUT_FILE} for more information" )
message(FATAL_ERROR "${CAMITK_TEST_NAME}: (one or more) output file do(es) not match the corresponding expected file.\n${CAMITK_TEST_EXPECTED_FILE_OUTPUT}" )
else()
message("[OK]")
endif()
......@@ -4,7 +4,7 @@ camitk_extension(COMPONENT_EXTENSION
DESCRIPTION "Support for .msh files"
DEFINES COMPILE_MSH_COMPONENT_API
HEADERS_TO_INSTALL MshComponent.h MshExtension.h MshComponentAPI.h
AUTO_TEST
ENABLE_AUTO_TEST
)
# Recursively update the shiboken path variable containing the CamiTK SDK tree structure
......
......@@ -2,7 +2,7 @@
camitk_extension(COMPONENT_EXTENSION
CEP_NAME SDK
DESCRIPTION "Support for .obj files"
AUTO_TEST
ENABLE_AUTO_TEST
TEST_FILES liver-smooth.obj scissors.obj
)
......
......@@ -2,7 +2,7 @@
camitk_extension(COMPONENT_EXTENSION
CEP_NAME SDK
DESCRIPTION "Support for .off files"
AUTO_TEST
ENABLE_AUTO_TEST
)
# Recursively update the shiboken path variable containing the CamiTK SDK tree structure
......
......@@ -2,6 +2,6 @@
camitk_extension(COMPONENT_EXTENSION
CEP_NAME SDK
DESCRIPTION "Support for STL 3D mesh format"
AUTO_TEST
ENABLE_AUTO_TEST
TEST_FILES head1.STL skull1.stl
)
......@@ -2,7 +2,7 @@ camitk_extension(COMPONENT_EXTENSION
NEEDS_QT_MODULES
CEP_NAME SDK
DESCRIPTION "Support for .vrml files"
AUTO_TEST
ENABLE_AUTO_TEST
# vrml save cannot save VRML -> level 1 is the best we can do
AUTO_TEST_LEVEL 1
)
......
......@@ -3,7 +3,7 @@ camitk_extension(COMPONENT_EXTENSION
HEADERS_TO_INSTALL VtkImageComponent.h VtkImageComponentAPI.h
CEP_NAME SDK
DESCRIPTION "Support for most native vtk image file formats"
AUTO_TEST
ENABLE_AUTO_TEST
# mha binary data are never saved exactly the same way -> level 2 is the best we can do
AUTO_TEST_LEVEL 2
TEST_FILES brain.mha sinus.mhd
......
......@@ -9,7 +9,7 @@ camitk_extension(COMPONENT_EXTENSION
VtkMeshUtil.h
CEP_NAME SDK
DESCRIPTION "Support for native (legacy) vtkmesh files"
AUTO_TEST
ENABLE_AUTO_TEST
# Exclude binary files
TEST_FILES cube-with-point-and-cell-data.vtk imageBoundingBox.vtk polydata-with-data.vtk sinus_skull.vtk cube-with-tensors.vtk male.vtk structuredgrid-with-data.vtk brainImageSmooth.vtk female.vtk plate-with-data.vtk simple.vtk structured.vtk check-with-color-pointdata.vtk fieldfile.vtk pointcloud-with-data.vtk sinus_skin.vtk
)
......