Commit c86d41a6 authored by lealv's avatar lealv
Browse files

FEATURE 165 - CTEST (MAJOR COMMIT) : test application for automatic ACTIONS testing

DO for all actions in opensource repository:
- load extension dll
- for each files in Ctestdata , process actions on 
- Report if apply processing failed or not (in case files are not compatible with action, i.e mesh files with image actions, test reports pass)

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1163 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 0a23f72a
...@@ -13,5 +13,6 @@ camitk_extension( ACTION_EXTENSION ...@@ -13,5 +13,6 @@ camitk_extension( ACTION_EXTENSION
NEEDS_ITK NEEDS_ITK
CEP_NAME CEP_IMAGING CEP_NAME CEP_IMAGING
DESCRIPTION "This action features basic ITK image processing filters" DESCRIPTION "This action features basic ITK image processing filters"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
...@@ -3,4 +3,5 @@ camitk_extension( ACTION_EXTENSION ...@@ -3,4 +3,5 @@ camitk_extension( ACTION_EXTENSION
NEEDS_ACTION_EXTENSION multipicking NEEDS_ACTION_EXTENSION multipicking
CEP_NAME CEP_IMAGING CEP_NAME CEP_IMAGING
DESCRIPTION "This action features basic ITK image processing segmentation algorithms" DESCRIPTION "This action features basic ITK image processing segmentation algorithms"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
...@@ -5,4 +5,5 @@ camitk_extension(ACTION_EXTENSION ...@@ -5,4 +5,5 @@ camitk_extension(ACTION_EXTENSION
NEEDS_COMPONENT_EXTENSION physicalmodel mml vtkmesh physicalmodel NEEDS_COMPONENT_EXTENSION physicalmodel mml vtkmesh physicalmodel
CEP_NAME CEP_MODELING CEP_NAME CEP_MODELING
DESCRIPTION "Action MML features algorithms applicable on MML components." DESCRIPTION "Action MML features algorithms applicable on MML components."
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
\ No newline at end of file
...@@ -2,6 +2,7 @@ camitk_extension( ACTION_EXTENSION ...@@ -2,6 +2,7 @@ camitk_extension( ACTION_EXTENSION
DEFINES COMPILE_APPLICATION_ACTION_API DEFINES COMPILE_APPLICATION_ACTION_API
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Features actions used at aplication level (these actions are mandatory for any CamiTK appliction to work)" DESCRIPTION "Features actions used at aplication level (these actions are mandatory for any CamiTK appliction to work)"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
if(NOT ACTION_APPLICATION) if(NOT ACTION_APPLICATION)
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
camitk_extension( ACTION_EXTENSION camitk_extension( ACTION_EXTENSION
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Control of the arbitrary slice on image component" DESCRIPTION "Control of the arbitrary slice on image component"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
...@@ -4,4 +4,5 @@ camitk_extension( ACTION_EXTENSION ...@@ -4,4 +4,5 @@ camitk_extension( ACTION_EXTENSION
NEEDS_ACTION_EXTENSION multipicking NEEDS_ACTION_EXTENSION multipicking
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Helps you to crop a volume to keep only an interesting subsample" DESCRIPTION "Helps you to crop a volume to keep only an interesting subsample"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
\ No newline at end of file
...@@ -2,4 +2,5 @@ camitk_extension( ACTION_EXTENSION ...@@ -2,4 +2,5 @@ camitk_extension( ACTION_EXTENSION
DEFINES COMPILE_LUT_ACTION_API DEFINES COMPILE_LUT_ACTION_API
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Displays the image look-up-table (lut)" DESCRIPTION "Displays the image look-up-table (lut)"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
\ No newline at end of file
...@@ -3,4 +3,5 @@ camitk_extension( ACTION_EXTENSION ...@@ -3,4 +3,5 @@ camitk_extension( ACTION_EXTENSION
INSTALL_ALL_HEADERS INSTALL_ALL_HEADERS
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Action-multipicking allows to make several pixel picking on an image component (volumic image)" DESCRIPTION "Action-multipicking allows to make several pixel picking on an image component (volumic image)"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
\ No newline at end of file
...@@ -2,4 +2,5 @@ camitk_extension( ACTION_EXTENSION ...@@ -2,4 +2,5 @@ camitk_extension( ACTION_EXTENSION
DEFINES COMPILE_RECONSTRUCTION_ACTION_API DEFINES COMPILE_RECONSTRUCTION_ACTION_API
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Use marching cube algorithm to create a surfacic mesh from a volumic image" DESCRIPTION "Use marching cube algorithm to create a surfacic mesh from a volumic image"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
\ No newline at end of file
camitk_extension( ACTION_EXTENSION camitk_extension( ACTION_EXTENSION
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Display in 3D the component" DESCRIPTION "Display in 3D the component"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
...@@ -3,5 +3,6 @@ camitk_extension( ACTION_EXTENSION ...@@ -3,5 +3,6 @@ camitk_extension( ACTION_EXTENSION
DEFINES COMPILE_VOLUME_RENDERING_ACTION_API DEFINES COMPILE_VOLUME_RENDERING_ACTION_API
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Use ray tracing to produce a 3D reprensation of the image" DESCRIPTION "Use ray tracing to produce a 3D reprensation of the image"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
...@@ -2,4 +2,5 @@ camitk_extension( ACTION_EXTENSION ...@@ -2,4 +2,5 @@ camitk_extension( ACTION_EXTENSION
DEFINES COMPILE_BASIC_MESH_ACTION_API DEFINES COMPILE_BASIC_MESH_ACTION_API
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Provides basic actions on meshes" DESCRIPTION "Provides basic actions on meshes"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
...@@ -2,4 +2,5 @@ camitk_extension( ACTION_EXTENSION ...@@ -2,4 +2,5 @@ camitk_extension( ACTION_EXTENSION
DEFINES COMPILE_BASIC_TOPOLOGY_ACTION_API DEFINES COMPILE_BASIC_TOPOLOGY_ACTION_API
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Helps building simple 3D objects" DESCRIPTION "Helps building simple 3D objects"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
\ No newline at end of file
...@@ -3,6 +3,7 @@ camitk_extension( ACTION_EXTENSION ...@@ -3,6 +3,7 @@ camitk_extension( ACTION_EXTENSION
DEFINES COMPILE_MESHPROCESSING_ACTION_API DEFINES COMPILE_MESHPROCESSING_ACTION_API
CEP_NAME SDK CEP_NAME SDK
DESCRIPTION "Features some nice algorithms for mesh processing" DESCRIPTION "Features some nice algorithms for mesh processing"
TEST_APPLICATION ${APPLICATION_TEST_ACTION}
) )
#--------------------------------------------
#
# CamiTK Open Source CEP Set
#
#--------------------------------------------
cmake_minimum_required(VERSION 2.6)
camitk_application( CEP_NAME SDK
DESCRIPTION "Test application to test actions"
)
#---------
# Testing
#----------
# Define the application test component name
set( APPLICATION_TEST_ACTION ${APPLICATION_TARGET_NAME} CACHE INTERNAL "")#CACHE INTERNAL extends the scope of the variable outside the directory
\ No newline at end of file
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
// -- Core stuff
#include <Application.h>
#include <MainWindow.h>
#include <InteractiveViewer.h>
#include <Core.h>
#include <ExtensionManager.h>
#include <Action.h>
using namespace camitk;
// Complete description
// If you modify this description, PLEASE do not forget to
// also update the associated "camitk-imp-prologue.1.in" man page
// (both texts should only be marginally different)
static const char* description = "This is a test application, it is "
"not intended to be used as a CamiTK application."
"\n -a <file> action to load (.dll file)"
"\n -i <file> is the file to open - will not be modified";
// usage for this application
static void usage(char *appName) {
std::cout << appName << std::endl;
std::cout << std::endl;
std::cout << "Usage: " << appName << " -i <fileIn> -a <OutDirectory>" << std::endl;
std::cout << "Built using " << Core::version << std::endl;
std::cout << std::endl;
std::cout << description << std::endl;
std::cout << std::endl;
std::cout << "Options:" << endl;
std::cout << "Arguments:" << std::endl;
std::cout << "-a <file> action name -i <file> input file on which the tested action will process" << std::endl;
}
int main(int argc, char *argv[]) {
try {
int ret = EXIT_SUCCESS;
bool inputTest = false;
bool actionTest = false;
QFileInfo iaction;
QFileInfo ifile;
std::cout << "Start " << argv[0] << std::endl;
for (int i=1; i<argc; i++)
{
if (!strcmp( argv[i],"-a" )) {
iaction.setFile( argv[i+1] );
actionTest = true;
}
if (!strcmp( argv[i],"-i" )) {
ifile.setFile( argv[i+1] );
inputTest = true;
}
}
// if no or not correct options provided
if ( !inputTest || !actionTest )
{
if (argc>1)
{
std::cout << "Argument errors: ";
for(int i=1; i<argc; i++)
{
std::cout << "[" << argv[i] << "] ";
}
}
usage(argv[0]);
ret = EXIT_SUCCESS;
return ret;
}
else
{
std::cout << "Arguments OK: ";
bool extOpen = false;
// init the camitk application context
Application a( "action-test", argc, argv, false, false );// No autoload + No association of types extensions to CamiTK
a.getMainWindow()->setCentralViewer( InteractiveViewer::getAxialViewer() );
ExtensionManager::autoload( ExtensionManager::COMPONENT );
Component* comp = Application::open( ifile.absoluteFilePath() );
if( comp )
{
QString ActionDir;
Action::ApplyStatus status;
QStringList extensionDir;
std::cout << "Open file OK : ";
comp->setSelected( true, true );
extensionDir = Core::getActionDirectories();
foreach( ActionDir, extensionDir )
{
if ( ExtensionManager::loadExtension( ExtensionManager::ACTION, ActionDir + '/' + iaction.fileName() ))
{
std::cout << "load action OK : ";
extOpen = true;
}
}
if( extOpen )
{
QStringList componentHierarchy = comp->getHierarchy();
ActionList actl = Application::getActions( comp );
foreach( Action *action , actl )
{
QString q = action->getName();
std::cout << "action->getName() " << action->getName().data();
if( componentHierarchy.contains( action->getComponent() ) )
{
std::cout << "componentHierarchy OK : ";
action->setInputComponent( comp );
status = action->apply();
if( status != Action::SUCCESS )
{
std::cout << "action->getname() " << action->getName().data() << "FAILED";
ret = EXIT_FAILURE;
break;
}
}
}
}
else
{
std::cout << "Loading action extension :" << iaction.fileName().data() << "FAILED";
}
}
else
{
std::cout << "Loading file :" << ifile.absoluteFilePath().data() << "FAILED";
}
return ret;
}
}
catch (camitk::AbortException& e) {
//QMessageBox::warning(NULL, QString(argv[0]) + " aborted...", "AbortException:" + QString(e.what()));
std::cout << argv[0] << " aborted..." << std::endl << "camitk AbortException:" << std::endl << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (std::exception& e) {
//QMessageBox::warning(NULL, QString(argv[0]) + " aborted...", "AbortException:" + QString(e.what()));
std::cout << argv[0] << " aborted..." << std::endl << "std AbortException:" << std::endl << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (...) {
//QMessageBox::warning(NULL, QString(argv[0]) + " aborted...", "Unknown Exception");
std::cout << argv[0] << " aborted..." << std::endl << "Unknown Exception" << std::endl;
return EXIT_FAILURE;
}
}
...@@ -1071,11 +1071,11 @@ macro(camitk_extension) ...@@ -1071,11 +1071,11 @@ macro(camitk_extension)
######################################################################### #########################################################################
# # # #
# CTEST - TESTS DESCRIPTION # # CTEST - COMPONENT TESTS DESCRIPTION #
# # # #
######################################################################### #########################################################################
if( ${EXTENSION_NAME_CMAKE}_COMPONENT_EXTENSION AND ${EXTENSION_NAME_CMAKE}_TEST_APPLICATION ) if( ${EXTENSION_NAME_CMAKE}_COMPONENT_EXTENSION AND ${EXTENSION_NAME_CMAKE}_TEST_APPLICATION )
message( STATUS "GENERATE CTEST TESTS - TEST APPLICATION IS " ${${EXTENSION_NAME_CMAKE}_TEST_APPLICATION} ) message( "GENERATE CTEST TESTS - TARGETNAME IS " ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} " TEST APPLICATION IS " ${${EXTENSION_NAME_CMAKE}_TEST_APPLICATION} )
camitk_init_test( ${${EXTENSION_NAME_CMAKE}_TEST_APPLICATION} ) camitk_init_test( ${${EXTENSION_NAME_CMAKE}_TEST_APPLICATION} )
# Retrieve the current directory name to properly name the test # Retrieve the current directory name to properly name the test
...@@ -1097,8 +1097,45 @@ macro(camitk_extension) ...@@ -1097,8 +1097,45 @@ macro(camitk_extension)
# Test should pass because invoking application-test with a faulty arguments results in printing # Test should pass because invoking application-test with a faulty arguments results in printing
# an "Usage error" message (and exit failure) # an "Usage error" message (and exit failure)
camitk_add_test( EXECUTABLE_ARGS "-error" PASS_REGULAR_EXPRESSION "Usage" TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ) camitk_add_test( EXECUTABLE_ARGS "-error" PASS_REGULAR_EXPRESSION "Usage" TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
endif()
#########################################################################
# #
# CTEST - ACTION TESTS DESCRIPTION #
# #
#########################################################################
elseif( ${EXTENSION_NAME_CMAKE}_ACTION_EXTENSION AND ${EXTENSION_NAME_CMAKE}_TEST_APPLICATION )
message( "GENERATE CTEST TESTS - TARGETNAME IS " ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} " TEST APPLICATION IS " ${${EXTENSION_NAME_CMAKE}_TEST_APPLICATION} )
camitk_init_test( ${${EXTENSION_NAME_CMAKE}_TEST_APPLICATION} )
# Retrieve the current directory name to properly name the test
get_directory_name( ${CMAKE_CURRENT_SOURCE_DIR} COMP_DIR_NAME )
# Test should pass because application test runs with no arguments - shows usage and exit success
camitk_add_test( PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
# Test should pass because invoking application-test with a faulty arguments results in printing
# an "Usage error" message (and exit failure)
camitk_add_test( EXECUTABLE_ARGS "-error" PASS_REGULAR_EXPRESSION "Usage" PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
# Retrieve the files in ctestdata directory - tests will be applied for each of these files
get_subdirectoryfiles( ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata TESTFILES )
#get the names of actions .dlls in lib directory
get_subdirectoryfiles( ${CAMITK_BUILD_PRIVATE_LIB_DIR}/actions/ ACTIONSDLLS )
foreach( ACTION_TESTDATA_FILE ${TESTFILES} )
# Give the file name (full path cut)
get_directory_name( ${ACTION_TESTDATA_FILE} DATA_FILE )
if( NOT ( ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME} MATCHES "application" ) )#We do not apply tests on actions like (close, save, save as)
# Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
if(MSVC)
camitk_add_test( EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata/${DATA_FILE} -a ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}${CAMITK_DEBUG_POSTFIX}.dll" PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
else()
camitk_add_test( EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata/${DATA_FILE} -a ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.dll" PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
endif()
endif()
endforeach()
endif()
endif() # endif(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE}) endif() # endif(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE})
endmacro() endmacro()
......
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