Commit 23cdfb9a authored by Jean-Loup Haberbusch's avatar Jean-Loup Haberbusch
Browse files

Merge branch 'feature/extra-testaction' into 'develop'

Feature/extra testaction

See merge request !6
parents d6f48e8f b9dc4ac2
......@@ -26,3 +26,8 @@ set_tests_properties("component-itkimage-level3-3" PROPERTIES WILL_FAIL true)
set_tests_properties("component-itkimage-level3-19" PROPERTIES WILL_FAIL true)
# TODO check why ITK cannot save LittleEndianZ.img.gz properly
set_tests_properties("component-itkimage-level3-20" PROPERTIES WILL_FAIL true)
# Additional test for SDK actions: this will add auto test for the given actions using the itkimage component
camitk_additional_action_test(ACTION_EXTENSIONS cropvolume imagelut imageresampling multipicking pixelcolorchanger reconstruction reorientimage showin3d volumerendering
TEST_FILES BigEndian.hdr BigEndian.img BigEndianCompressed1.hdr BigEndianCompressed1.img biorad.pic cthead1.lsm LittleEndian1.hdr LittleEndian1.img LittleEndianCompressed1.hdr LittleEndianCompressed1.img LittleEndianZ1.hdr mini-complex-slow1.nrrd mini-ten-nomask-slow1.nrrd mini-vector-slow1.nrrd ramp1.gipl
)
......@@ -9,3 +9,7 @@ camitk_extension(COMPONENT_EXTENSION
TEST_FILES diaphragm.pml truthcube.pml
)
# Additional test for SDK actions: this will add auto test for the given actions using the pmlcomponent
camitk_additional_action_test(ACTION_EXTENSIONS basicmesh basictopology meshprocessing
TEST_FILES diaphragm.pml truthcube.pml
)
......@@ -97,7 +97,7 @@ Action::ApplyStatus BoxVOI::apply() {
// this call works only with a GUI (i.e. if theWidget exists)
if ( ( input == NULL ) || ( rgWidget == NULL ) ) {
CAMITK_INFO("BoxVOI", "apply()", "This action cannot be called without a GUI (input data are required to be set manually.")
CAMITK_INFO("BoxVOI", "apply()", "This action cannot be called without a GUI (input data are required to be set manually).")
return ABORTED;
}
......
......@@ -28,6 +28,7 @@ include(camitk/cdash/projects/CamiTKSubProjectValidate)
# -- 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/CamiTKAdditionalActionTest)
# -- packaging macros
include(camitk/packaging/CamiTKOpenSourcePackaging)
......
......@@ -945,10 +945,10 @@ macro(camitk_extension)
foreach( ACTION_TESTDATA_FILE ${TESTFILES})
# Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
camitk_add_test( EXECUTABLE_ARGS "-i ${ACTION_TESTDATA_FILE} -a ${EXTENSION_PLUGIN_FILE}"
TEST_SUFFIX "-level1-"
PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
)
camitk_add_test(EXECUTABLE_ARGS "-i ${ACTION_TESTDATA_FILE} -a ${EXTENSION_PLUGIN_FILE}"
TEST_SUFFIX "-level1-"
PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
)
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()
......
......@@ -11,6 +11,7 @@
#! [NAME packageName]
#! [VENDOR vendorName]
#! [CONTACT contactName]
#! [LICENSE "This is the license text..."]
#! )
#! \endcode
#!
......@@ -18,7 +19,7 @@
#! \param NAME (optional) Specify the package name (default is project name)
#! \param VENDOR (optional) Specify the vendor name (default is TIMC-IMAG)
#! \param CONTACT (optional) Specify the contact name (default is link to CamiTK website)
#! \param APPLICATIONS (optional) If you want to package some applications
#! \param LICENSE (optional) Specify the license test
#!
#! When configuring CMake, do not forget to set the CMAKE_INSTALL_PREFIX correctly (e.g., /usr on Linux)
#! It will always use the CamiTK install directory as install prefix (install where the core is already)
......@@ -30,11 +31,11 @@ macro(camitk_cep_packaging)
# CEP Packaging only works for stand-alone CEP
if (NOT CAMITK_EXTENSION_PROJECT_SET)
parse_arguments(CAMITK_CEP_PACKAGING
"NAME;VENDOR;CONTACT;APPLICATIONS;DESCRIPTION;LICENSE" # possible lists
"" # possible option
${ARGN}
)
set(options "")
set(oneValueArgs NAME VENDOR CONTACT DESCRIPTION LICENSE)
set(multiValueArgs "")
cmake_parse_arguments(CAMITK_CEP_PACKAGING "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
# Clean list of targets by removing duplicates
# Those may appear if configuring more than once (i.e. by manually clicking more than once on the CMake configure
......@@ -490,4 +491,4 @@ message(STATUS "Generated CEP manifest in CEPPackageManifest.xml")
endif() # Standalone CEP
endmacro()
\ No newline at end of file
endmacro()
......@@ -49,10 +49,10 @@
#
#! @sa camitk_init_test
macro(camitk_add_test)
#set(options "")
set(options "")
set(oneValueArgs EXECUTABLE_ARGS PASS_FILE PASS_REGULAR_EXPRESSION FAIL_REGULAR_EXPRESSION PASS_FILE_OUTPUT TEST_SUFFIX PROJECT_NAME)
#set(multiValueArgs "")
cmake_parse_arguments(CAMITK_ADD_TEST "" "${oneValueArgs}" "" ${ARGN} )
set(multiValueArgs "")
cmake_parse_arguments(CAMITK_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
math(EXPR CAMITK_TEST_ID "${CAMITK_TEST_ID} + 1")
set(CAMITK_TEST_NAME "${CAMITK_ADD_TEST_PROJECT_NAME}${CAMITK_ADD_TEST_TEST_SUFFIX}${CAMITK_TEST_ID}")
......
#!
#! @ingroup group_sdk_cmake_camitk_test
#!
#! camitk_additional_action_test is a macro to create additional level1 test of CamiTK action
#! to the CTest infrastructure.
#!
#! It should be used when a CEP introduces a new component (with new test files)
#! and an existing action should be run using this new component and test files.
#!
#! Usage:
#! \code
#! camitk_additional_action_test(ACTION_EXTENSIONS action1 action2 ...
#! [TEST_FILES file1 file2 ...]
#! [TEST_SUFFIX name]
#! )
#! \endcode
#!
#! \param ACTION_EXTENSIONS List of the action extension that will be additionnaly tested with the given
#! test files. Only the action extension name (note the full library/dll name nor
#! the path should be given. This macro checks the existence of the extension
#! library/dll in the following directories (in this order) : build dir;
#! user install dir and global install dir. The first one found is used for the tests.
#! \param TEST_FILES Optional. List of files to use for testing. If not set, then all the files in the
#! testdata dir are used.
#! If provided, only the filenames are required (not the absolute paths) and
#! all the given files should be in the testdata subdir.
#! \param TEST_SUFFIX Optional. suffix name for the additional test. default value is the name of the
#! current component extension.
#!
#! @sa camitk_extension
macro(camitk_additional_action_test)
if (NOT PACKAGING_NSIS AND BUILD_TESTING)
set(options "")
set(oneValueArgs TEST_SUFFIX)
set(multiValueArgs ACTION_EXTENSIONS TEST_FILES)
cmake_parse_arguments(CAMITK_ADDITIONAL_ACTION_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
if (CAMITK_ADDITIONAL_ACTION_TEST_TEST_SUFFIX)
set(CAMITK_ADDITIONAL_ACTION_TEST_SUFFIX ${CAMITK_ADDITIONAL_ACTION_TEST_TEST_SUFFIX})
else()
set(CAMITK_ADDITIONAL_ACTION_TEST_SUFFIX ${EXTENSION_NAME})
endif()
# COMPONENT_EXTENSION_PLUGIN_FILE
# determine the extension full file name depending on the plateform
if (MSVC)
set(COMPONENT_EXTENSION_PLUGIN_FILE "components/${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}${CAMITK_DEBUG_POSTFIX}.dll")
elseif(APPLE)
set(COMPONENT_EXTENSION_PLUGIN_FILE "components/lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.dylib")
else()
# Must be Linux
set(COMPONENT_EXTENSION_PLUGIN_FILE "components/lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.so")
endif()
# if this is not SDK, then it is required
if(NOT CAMITK_SDK_BUILD)
set(ADDITIONAL_COMPONENT_EXTENSION_ARG "-c ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${COMPONENT_EXTENSION_PLUGIN_FILE}")
endif()
# loop over actions
# if (action extension exists in repository) CAMITK_USER_PRIVATE_LIB_DIR CAMITK_PRIVATE_LIB_DIR CAMITK_BUILD_PRIVATE_LIB_DIR
# loop over test files
# add test
# math(EXPR CAMITK_ADDITIONNAL_TEST_ID "${CAMITK_ADDITIONNAL_TEST_ID} + 1")
foreach(ACTION_EXTENSION ${CAMITK_ADDITIONAL_ACTION_TEST_ACTION_EXTENSIONS})
# determine the extension full file name depending on the plateform
if (MSVC)
set(EXTENSION_FILE "actions/${ACTION_EXTENSION}${CAMITK_DEBUG_POSTFIX}.dll")
elseif(APPLE)
set(EXTENSION_FILE "$actions/lib${ACTION_EXTENSION}.dylib")
else()
# Must be Linux
set(EXTENSION_FILE "actions/lib${ACTION_EXTENSION}.so")
endif()
# check if action can be found in (this order) : build dir (CAMITK_BUILD_PRIVATE_LIB_DIR),
# user install (CAMITK_USER_PRIVATE_LIB_DIR, and global install (CAMITK_PRIVATE_LIB_DIR)
set(ACTION_EXTENSION_PLUGIN_FILE ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
if (NOT EXISTS ${ACTION_EXTENSION_PLUGIN_FILE})
set(ACTION_EXTENSION_PLUGIN_FILE ${CAMITK_USER_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
if (NOT EXISTS ${ACTION_EXTENSION_PLUGIN_FILE})
set(ACTION_EXTENSION_PLUGIN_FILE ${CAMITK_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
if (NOT EXISTS ${ACTION_EXTENSION_PLUGIN_FILE})
message(SEND_ERROR "Action extension \"${ACTION_EXTENSION}\" not found: no additional test added")
return()
endif()
endif()
endif()
message(STATUS "Adding additional autotest for action-${ACTION_EXTENSION}")
if (CAMITK_SDK_BUILD)
camitk_init_test(application-testactions)
else()
camitk_init_test(camitk-testactions)
endif()
camitk_parse_test_add_separator(EXTENSION_TYPE actions EXTENSION_NAME ${ACTION_EXTENSION})
# Retrieve the files in testdata directory - a test will be applied for each of these files
# or use only the given files
if (CAMITK_ADDITIONAL_ACTION_TEST_TEST_FILES)
# add testdata dir to filename
set(TESTFILES)
foreach(COMPONENT_TESTDATA_FILE ${CAMITK_ADDITIONAL_ACTION_TEST_TEST_FILES})
list(APPEND TESTFILES ${CMAKE_CURRENT_SOURCE_DIR}/testdata/${COMPONENT_TESTDATA_FILE})
endforeach()
else()
get_subdirectoryfiles( ${CMAKE_CURRENT_SOURCE_DIR}/testdata TESTFILES )
endif()
foreach( ACTION_TESTDATA_FILE ${TESTFILES})
# Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
camitk_add_test(EXECUTABLE_ARGS "-i ${ACTION_TESTDATA_FILE} -a ${ACTION_EXTENSION_PLUGIN_FILE} ${ADDITIONAL_COMPONENT_EXTENSION_ARG}"
TEST_SUFFIX "-additional-${CAMITK_ADDITIONAL_ACTION_TEST_SUFFIX}-level1-"
PROJECT_NAME "action-${ACTION_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()
endforeach()
endif()
endmacro()
......@@ -13,3 +13,13 @@ camitk_extension(@EXTTYPEHIGH@_EXTENSION
#TEST_FILES file1 file2 ...
# for component extension, test can be relaxed to lower levels using the AUTO_TEST_LEVEL option
)
# For component extension, additional action autotest can be added.
# If this extension provides a new component extension, it is possible to check its integration
# with previously defined actions (in CamiTK SDK or other CEPs) by using the
# camitk_additional_action_test macro.
# Example:
# camitk_additional_action_test(ACTION_EXTENSIONS action1 action2
# TEST_FILES file1 file2
# )
# will add automatic test for action1 and action2 using file1 and file2 (provided by this extension in testdata subdir)
......@@ -20,7 +20,7 @@ class options {
std::string --action | -a
{
"<action>",
"<path>",
"The action extension to be tested (please provide the full path of the dynamic library)."
};
......@@ -29,4 +29,14 @@ class options {
"<file>",
"input component file to test the actions on (please provide the full path to the file). Note that this file is not modified."
};
std::string --component | -c
{
"<path>",
"[Optional] Additional component extension to be loaded before opening the input file (please provide the full
path to the dynamic library).
This is generally needed when an automatic test is added. The component extension that manages will not be
automatically loaded in this case. Use this option to provide it."
};
};
......@@ -311,7 +311,8 @@ options (int& argc,
::cli::unknown_mode arg)
: help_ (),
action_ (),
input_ ()
input_ (),
component_ ()
{
::cli::argv_scanner s (argc, argv, erase);
_parse (s, opt, arg);
......@@ -326,7 +327,8 @@ options (int start,
::cli::unknown_mode arg)
: help_ (),
action_ (),
input_ ()
input_ (),
component_ ()
{
::cli::argv_scanner s (start, argc, argv, erase);
_parse (s, opt, arg);
......@@ -341,7 +343,8 @@ options (int& argc,
::cli::unknown_mode arg)
: help_ (),
action_ (),
input_ ()
input_ (),
component_ ()
{
::cli::argv_scanner s (argc, argv, erase);
_parse (s, opt, arg);
......@@ -358,7 +361,8 @@ options (int start,
::cli::unknown_mode arg)
: help_ (),
action_ (),
input_ ()
input_ (),
component_ ()
{
::cli::argv_scanner s (start, argc, argv, erase);
_parse (s, opt, arg);
......@@ -371,7 +375,8 @@ options (::cli::scanner& s,
::cli::unknown_mode arg)
: help_ (),
action_ (),
input_ ()
input_ (),
component_ ()
{
_parse (s, opt, arg);
}
......@@ -379,13 +384,18 @@ options (::cli::scanner& s,
void options::
print_usage (::std::ostream& os)
{
os << "--help|-h Print usage information and exit." << ::std::endl;
os << "--help|-h Print usage information and exit." << ::std::endl;
os << "--action|-a <action> The action extension to be tested (please provide the full" << ::std::endl
<< " path of the dynamic library)." << ::std::endl;
os << "--action|-a <path> The action extension to be tested (please provide the full" << ::std::endl
<< " path of the dynamic library)." << ::std::endl;
os << "--input|-i <file> input component file to test the actions on (please provide" << ::std::endl
<< " the full path to the file)." << ::std::endl;
os << "--input|-i <file> input component file to test the actions on (please" << ::std::endl
<< " provide the full path to the file)." << ::std::endl;
os << "--component|-c <path> [Optional] Additional component extension to be loaded" << ::std::endl
<< " before opening the input file (please provide the full" << ::std::endl
<< ::std::endl
<< " path to the dynamic library)." << ::std::endl;
}
typedef
......@@ -410,6 +420,10 @@ struct _cli_options_map_init
&::cli::thunk< options, std::string, &options::input_ >;
_cli_options_map_["-i"] =
&::cli::thunk< options, std::string, &options::input_ >;
_cli_options_map_["--component"] =
&::cli::thunk< options, std::string, &options::component_ >;
_cli_options_map_["-c"] =
&::cli::thunk< options, std::string, &options::component_ >;
}
} _cli_options_map_init_;
......
......@@ -242,6 +242,9 @@ class options
const std::string&
input () const;
const std::string&
component () const;
// Print usage information.
//
static void
......@@ -257,6 +260,7 @@ class options
bool help_;
std::string action_;
std::string input_;
std::string component_;
};
#include "CommandLineOptions.ixx"
......
......@@ -126,3 +126,9 @@ input () const
return this->input_;
}
inline const std::string& options::
component () const
{
return this->component_;
}
......@@ -36,7 +36,7 @@ using namespace camitk;
#include "CommandLineOptions.hxx"
// description of the application. Please update the manpage-prologue.1.in also if you modify this string.
const char* description = "camitk-testactions aims at testing a action extension individually.\n"
const char* description = "camitk-testactions aims at testing an action extension individually.\n"
"It loads the given action extension library (dll or so), opens the\n"
"given component, and apply all the action that work on the given\n" "component.\n\n"
"Please visit http://camitk.imag.fr for more information.\n"
......@@ -80,6 +80,7 @@ int main(int argc, char* argv[]) {
try {
int end; // End of options.
options o(argc, argv, end);
bool loadAdditionnalComponentExtension = false;
// if specific help or no options provided
if (o.help() || (o.action().empty() && o.input().empty())) {
......@@ -98,8 +99,9 @@ int main(int argc, char* argv[]) {
}
// check input files
QFileInfo inputComponent(o.input().c_str());
QFileInfo inputActionExtension(o.action().c_str());
QFileInfo inputComponent {o.input().c_str()};
QFileInfo inputActionExtension {o.action().c_str()};
QFileInfo additionaleComponentExtension {o.component().c_str()};
if (!inputComponent.exists()) {
usage("Argument error: component test file \"" + o.input() + "\" does not exist.");
......@@ -111,10 +113,23 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}
if (!o.component().empty()) {
if (!additionaleComponentExtension.exists()) {
usage("Argument error: action dll/so file \"" + o.component() + "\" does not exist.");
return EXIT_FAILURE;
}
else {
loadAdditionnalComponentExtension = true;
}
}
std::cout << "camitk-testactions run with arguments:" << std::endl;
std::cout << "- action library file: \"" << o.action() << "\"" << std::endl;
std::cout << "- input test file: \"" << o.input() << "\"" << std::endl;
if (loadAdditionnalComponentExtension) {
std::cout << "- additional component extension: \"" << o.component() << "\"" << std::endl;
}
testInit("Starting the camitk default application...");
//-- init the camitk application context
......@@ -129,6 +144,15 @@ int main(int argc, char* argv[]) {
testPassed();
if (loadAdditionnalComponentExtension) {
testInit("Loading additional component extension...");
if (!ExtensionManager::loadExtension(ExtensionManager::COMPONENT, additionaleComponentExtension.absoluteFilePath())) {
testFailed();
return EXIT_FAILURE;
}
testPassed();
}
testInit("Opening component: " + o.input() + "...");
Component* comp = Application::open(o.input().data());
......@@ -202,7 +226,7 @@ int main(int argc, char* argv[]) {
}
std::cout << "Return status is: " << statusString << std::endl;
}
}
}
std::cout << std::endl;
......
......@@ -24,7 +24,7 @@ The targeted users are in R&D departments or laboratories.
.IP "\fB--help\fP|\fB-h\fP"
Print usage information and exit\.
.IP "\fB--action\fP|\fB-a\fP \fIaction\fP"
.IP "\fB--action\fP|\fB-a\fP \fIpath\fP"
The action extension to be tested (please provide the full path of the
dynamic library)\.
......@@ -32,6 +32,16 @@ dynamic library)\.
input component file to test the actions on (please provide the full path to
the file)\. Note that this file is not modified\.
.IP "\fB--component\fP|\fB-c\fP \fIpath\fP"
[Optional] Additional component extension to be loaded before opening the
input file (please provide the full
path to the dynamic library)\.
This is generally needed when an automatic test is added\. The component
extension that manages will not be automatically loaded in this case\. Use
this option to provide it\.
.SH "AUTHORS"
CamiTK and camitk\-@APPLICATION_NAME@ is currently developed by the Univ. Grenoble Alpes,
CNRS in the TIMC\-IMAG UMR 5525 laboratory (GMCAO).
......
......@@ -5,7 +5,7 @@ camitk_extension(COMPONENT_EXTENSION
AUTO_TEST
# only .mixed is managed by this component, but as mha and vtk data file are needed as well
# there is only brain.mixed to test.
TEST_FILES brain.mixed
TEST_FILES brain.mixed
# save is not implemented, just do level 1 test
AUTO_TEST_LEVEL 1
)
......@@ -8,3 +8,6 @@ camitk_extension( COMPONENT_EXTENSION
AUTO_TEST_LEVEL 1
)
# Additional test for SDK actions: this will add auto test for the given actions using the pmlcomponent
camitk_additional_action_test(ACTION_EXTENSIONS basicmesh basictopology meshprocessing
)
Supports Markdown
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