Commit 5e744775 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED better test using Test lib code

parent 4033c6b0
......@@ -10,5 +10,6 @@ camitk_application(DEFAULT
# Add config test
find_program (BASH_PROGRAM bash)
if (BASH_PROGRAM)
# use "ctest -VV -R cepgenerator-test" to run just this test
add_test(cepgenerator-test ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/resources/cepgenerator-test.sh -inbuild ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR})
endif (BASH_PROGRAM)
......@@ -47,11 +47,11 @@ cleanup() {
echo "===== ABORTED ====="
echo
# Test exist status of every file and directory otherwise the script abort and the temp directory is not removed
if [ -f "./wizard-$testDirName" ]; then
echo "===== ABORTED wizard-$testDirName ====="
cat ./wizard-$testDirName
if [ -f "./generated-$testDirName" ]; then
echo "===== ABORTED generated-$testDirName ====="
cat ./generated-$testDirName
else
echo "===== File $workingDir/wizard-$testDirName not found ====="
echo "===== File $workingDir/generated-$testDirName not found ====="
fi
if [ -d "$testDirName/build" ]; then
cd $testDirName/build
......@@ -85,7 +85,7 @@ cleanup() {
cd
fi
# finally cleanup working dir
rm -rf $workingDir
# TODO rm -rf $workingDir
# use the backup value (otherwise the result of the "rm -rf" command above will
# be used, and that's probably always 0 !)
exit $currentExitValue
......@@ -138,7 +138,7 @@ cd $workingDir
# ---------------------- exampleComponents.xml ----------------------
# Example taken from distributed source ./sdk/applications/cepgenerator/testdata/exampleComponents.xml
# Example taken from distributed source ./sdk/libraries/cepcoreschema/testdata/exampleComponents.xml
cat <<EOF > exampleComponents.xml
<?xml version="1.0" encoding="UTF-8"?>
<cep
......@@ -246,7 +246,7 @@ EOF
# ---------------------- actionsExamplesLicence.xml ----------------------
# Example taken from distributed source ./sdk/applications/cepgenerator/testdata/actionsExamplesLicence.xml
# Example taken from distributed source ./sdk/libraries/cepcoreschema/testdata/actionsExamplesLicence.xml
cat <<EOF > actionsExamplesLicence.xml
<?xml version="1.0" encoding="UTF-8"?>
<cep xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
......@@ -336,7 +336,7 @@ EOF
# ---------------------- actionsExamplesNoLicence.xml ----------------------
# Example taken from distributed source ./sdk/applications/cepgenerator/testdata/actionsExamplesNoLicence.xml
# Example taken from distributed source ./sdk/libraries/cepcoreschema/testdata/actionsExamplesNoLicence.xml
cat <<EOF > actionsExamplesNoLicence.xml
<?xml version="1.0" encoding="UTF-8"?>
<cep xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
......@@ -412,7 +412,7 @@ EOF
# ---------------------- actionAndComponent.xml ----------------------
# Example taken from distributed source ./sdk/applications/cepgenerator/testdata/actionAndComponent.xml
# Example taken from distributed source ./sdk/libraries/cepcoreschema/testdata/actionAndComponent.xml
cat <<EOF > actionAndComponent.xml
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<cep xmlns="http://camitk.imag.fr/cepcoreschema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://camitk.imag.fr/cepcoreschema Cep.xsd">
......@@ -478,7 +478,7 @@ This test the link between an action and a component defined in the same CEP.</d
EOF
# ---------------------- empty.xml ----------------------
# Example taken from distributed source ./sdk/applications/cepgenerator/testdata/empty.xml
# Example taken from distributed source ./sdk/libraries/cepcoreschema/testdata/empty.xml
cat <<EOF > empty.xml
<?xml version="1.0" encoding="UTF-8"?>
<cep xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
......@@ -493,6 +493,211 @@ cat <<EOF > empty.xml
</cep>
EOF
# ---------------------- complete-test-1.xml ----------------------
# Example taken from distributed source ./sdk/libraries/cepcoreschema/testdata/complete-test-1.xml
cat <<EOF > complete-test-1.xml
<?xml version="1.0" encoding="utf-8"?>
<cep xmlns="http://camitk.imag.fr/cepcoreschema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://camitk.imag.fr/cepcoreschema Cep.xsd">
<name>Complete test CEP 1</name>
<contact>
<email>timc-camitk@univ-grenoble-alpes.fr</email>
</contact>
<description>This CEP is trying to achieve a complete test of all possible cepcoreschema element</description>
<readme>This CEP is trying to achieve a complete test of all possible cepcoreschema element. Probably some specific cases are not included, but it is our best shot</readme>
<copyright><![CDATA[/*****************************************************************************
$USERDEF_LICENCE_BEGIN$
CamiTK - Computer Assisted Medical Intervention ToolKit
(c) 2001-2017 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
Visit http://camitk.imag.fr for more information
This file is part of CamiTK.
$CEP_NAME$ is under the following licence:
This is the complete licence, it covers everything, everywhere, for everyone at everytime.
Please consider thatthis is just an example...
$USERDEF_LICENCE_END$
****************************************************************************/
]]></copyright>
<actionExtensions>
<actionExtension>
<name>Test Action Extension 1</name>
<description>Test the first action extension</description>
<actions>
<action>
<name>Test Action 1</name>
<description>Test a first action, for image component, with a lot of parameters</description>
<component>ImageComponent</component>
<classification>
<family>Complete Test Actions #1</family>
<tag>Test</tag>
<tag>Action #1</tag>
<tag>ImageComponent</tag>
<itkFilter outputType="Same as Input" />
</classification>
<parameters>
<parameter name="p1" type="int" description="This is p1" unit="unit 1" defaultValue="42" editable="true" />
<parameter name="p2" type="bool" description="This is p2" unit="unit 2" defaultValue="true" editable="true" />
<parameter name="p3" type="double" description="This is p3" unit="unit 3" defaultValue="42.42" editable="true" />
<parameter name="p4" type="QString" description="This is p4" unit="unit 4" defaultValue="Default value" editable="true" />
<parameter name="p5" type="QDate" description="This is p5" unit="unit 5" defaultValue="QDate(28,12,1969)" editable="true" />
<parameter name="p6" type="QColor" description="This is p6" unit="unit 6" defaultValue="QVariant().value&lt;QColor>()" editable="true" />
<parameter name="p7" type="QPoint" description="This is p7" unit="unit 7" defaultValue="QPoint(42,84)" editable="true" />
<parameter name="p8" type="QPointF" description="This is p8" unit="unit 8" defaultValue="QPointF(42.42,84.84)" editable="true" />
<parameter name="p9" type="QVector3D" description="This is p9" unit="unit 9" defaultValue="QVariant().value&lt;QVector3D>()" editable="true" />
<parameter name="p10" type="QVector4D" description="This is p10" unit="unit 10" defaultValue="QVariant().value&lt;QVector4D>()" editable="true" />
<parameter name="p11" type="QTime" description="This is p11" unit="unit 11" defaultValue="QTime(23,58)" editable="true" />
</parameters>
<properties modal="false" embedded="true" delayed="false" />
</action>
<action>
<name>Test Action 2</name>
<description>Test a second action, with no tag, no component, and with just one non editable parameters</description>
<component></component>
<classification>
<family>Complete Test Actions #1</family>
<!-- no tag... -->
</classification>
<parameters>
<parameter name="No Tag Action" type="bool" description="A &lt;b>small&lt;/b> description with &lt;i>hyper text&lt;i>" unit="€" defaultValue="false" editable="false"/>
</parameters>
<properties modal="true" embedded="false" delayed="false" />
</action>
<action>
<name>Test Action 3</name>
<description>Test a third action, with non existing \"Mesh Component\", and with lots of parameters and defautl editable</description>
<component></component>
<classification>
<family>Complete Test Actions #1</family>
<tag>Mesh Component</tag>
</classification>
<parameters>
<parameter name="p1" type="int" description="This is p1" unit="unit 1" defaultValue="42"/>
<parameter name="p2" type="bool" description="This is p2" unit="unit 2" defaultValue="true"/>
<parameter name="p3" type="double" description="This is p3" unit="unit 3" defaultValue="42.42"/>
<parameter name="p4" type="QString" description="This is p4" unit="unit 4" defaultValue="Default value"/>
<parameter name="p5" type="QDate" description="This is p5" unit="unit 5" defaultValue="QDate(28,12,1969)"/>
<parameter name="p6" type="QColor" description="This is p6" unit="unit 6" defaultValue="QVariant().value&lt;QColor>()"/>
<parameter name="p7" type="QPoint" description="This is p7" unit="unit 7" defaultValue="QPoint(42,84)"/>
<parameter name="p8" type="QPointF" description="This is p8" unit="unit 8" defaultValue="QPointF(42.42,84.84)"/>
<parameter name="p9" type="QVector3D" description="This is p9" unit="unit 9" defaultValue="QVariant().value&lt;QVector3D>()"/>
<parameter name="p10" type="QVector4D" description="This is p10" unit="unit 10" defaultValue="QVariant().value&lt;QVector4D>()"/>
<parameter name="p11" type="QTime" description="This is p11" unit="unit 11" defaultValue="QTime(23,58)" editable="true" />
</parameters>
<properties modal="true" embedded="false" delayed="false" />
</action>
</actions>
<dependencies>
<dependency type="library" name="itk"/>
<dependency type="cepLibrary" name="testlib"/>
</dependencies>
</actionExtension>
<actionExtension>
<name>Test Action Extension 2</name>
<description>Test the second action extension</description>
<actions>
<action>
<name>Test Action 4</name>
<description>This action use the Test Component 1</description>
<component>TestComponent1</component>
<classification>
<family>Complete Test Actions #2</family>
<tag>Test</tag>
<tag>Action #2</tag>
<tag>Test Component 1</tag>
</classification>
<parameters>
<parameter name="message" type="QString" description="This is a message parameter" unit="none" defaultValue="hello!" editable="true" />
</parameters>
<properties modal="false" embedded="true" delayed="false" />
</action>
</actions>
<dependencies>
<dependency type="component" name="testcomponentextension1"/>
</dependencies>
</actionExtension>
</actionExtensions>
<applications>
<application>
<name>testapp</name>
<description>Test application</description>
<directoryName>testappdir</directoryName>
</application>
</applications>
<componentExtensions>
<componentExtension>
<name>Test Component Extension 1</name>
<description>Test the first component extension</description>
<components>
<component>
<name>Test Component 1</name>
<description>Test a first action with an image representation</description>
<representation>Image</representation>
<properties>
<parameter name="p1" type="int" description="This is p1" unit="unit 1" defaultValue="42" editable="true" />
<parameter name="p2" type="bool" description="This is p2" unit="unit 2" defaultValue="true" editable="true" />
<parameter name="p3" type="double" description="This is p3" unit="unit 3" defaultValue="42.42" editable="true" />
<parameter name="p4" type="QString" description="This is p4" unit="unit 4" defaultValue="Default value" editable="true" />
<parameter name="p5" type="QDate" description="This is p5" unit="unit 5" defaultValue="QDate(28,12,1969)" editable="true" />
<parameter name="p6" type="QColor" description="This is p6" unit="unit 6" defaultValue="QVariant().value&lt;QColor>()" editable="true" />
<parameter name="p7" type="QPoint" description="This is p7" unit="unit 7" defaultValue="QPoint(42,84)" editable="true" />
<parameter name="p8" type="QPointF" description="This is p8" unit="unit 8" defaultValue="QPointF(42.42,84.84)" editable="true" />
<parameter name="p9" type="QVector3D" description="This is p9" unit="unit 9" defaultValue="QVariant().value&lt;QVector3D>()" editable="true" />
<parameter name="p10" type="QVector4D" description="This is p10" unit="unit 10" defaultValue="QVariant().value&lt;QVector4D>()" editable="true" />
<parameter name="p11" type="QTime" description="This is p11" unit="unit 11" defaultValue="QTime(23,58)" editable="true" />
</properties>
<fileSuffix>test</fileSuffix>
</component>
</components>
<dependencies>
<dependency type="library" name="testlib" />
</dependencies>
</componentExtension>
</componentExtensions>
<libraries>
<library static="true">
<name>testlib</name>
<description>A simple test lib. This lib will not compile unless some minimal C++ code is present in the generated source. Copy TestLib.h and TestLib.cpp to the library directory before configuration time.</description>
<dependencies>
<dependency type="library" name="XSD"/>
<dependency type="library" name="ITK"/>
<dependency type="cepLibrary" name="qtpropertybrowser"/>
</dependencies>
</library>
</libraries>
</cep>
EOF
# ---------------------- TestLib.h ----------------------
# Example taken from distributed source ./sdk/libraries/cepcoreschema/testdata/TestLib.h
cat <<EOF > TestLib.h
#ifndef TESTLIB_H
#define TESTLIB_H
// A simple test library
class TestLib {
public:
static void test();
};
#endif // TESTLIB_H
EOF
# ---------------------- TestLib.cpp ----------------------
# Example taken from distributed source ./sdk/libraries/cepcoreschema/testdata/TestLib.cpp
cat <<EOF > TestLib.cpp
#include "TestLib.h"
#include <iostream>
// --------------- test -------------------
void TestLib::test() {
std::cout << "Test output" << std::endl;
}
EOF
# ---------------------- generateConfigureAndMake ----------------------
generateConfigureAndMake() {
# generate
......@@ -501,12 +706,16 @@ generateConfigureAndMake() {
cd $workingDir
rm -rf $testDirName
mkdir $testDirName
$camitkGenerator -f $1 -d $testDirName > ./wizard-$testDirName
echo "===== wizard-$testDirName ====="
cat ./wizard-$testDirName
$camitkGenerator -f $1 -d $testDirName > ./generated-$testDirName
echo "===== generated-$testDirName ====="
cat ./generated-$testDirName
cd $testDirName
# get the created dir name
srcDirName=$(ls)
# check if there is a library (in this case copy dummy test lib to the given library name source dir
if [ "$#" == 2 ]; then
cp ../TestLib.* $srcDirName/libraries/$2
fi
# configure
mkdir build
cd build
......@@ -527,7 +736,7 @@ generateConfigureAndMake() {
# @param xmlfile
# @param expected number of created extensions
testcepfile() {
generateConfigureAndMake $1
generateConfigureAndMake $1 $3
expectedValue="$2"
echo "========== check $1 =========="
......@@ -542,6 +751,7 @@ testcepfile() {
else
echo "OK"
fi
echo
# increase id
checkValueId=$((checkValueId+1))
}
......@@ -555,10 +765,12 @@ testcepfile() {
# --------------------------------------------------------------------------
# testcepfile cep.xml nrOfExcpectedNewExtensions
testcepfile exampleComponents.xml 2
testcepfile actionsExamplesLicence.xml 2
testcepfile actionsExamplesNoLicence.xml 2
testcepfile actionAndComponent.xml 2
testcepfile empty.xml 0
testcepfile complete-test-1.xml 3 testlib
# TODO
# testcepfile exampleComponents.xml 2
# testcepfile actionsExamplesLicence.xml 2
# testcepfile actionsExamplesNoLicence.xml 2
# testcepfile actionAndComponent.xml 2
# testcepfile empty.xml 0
exit $exitStatus
#include "TestLib.h"
#include <iostream>
// --------------- test -------------------
void TestLib::test() {
std::cout << "Test output" << std::endl;
}
#ifndef TESTLIB_H
#define TESTLIB_H
// A simple test library
class TestLib {
public:
static void test();
};
#endif // TESTLIB_H
......@@ -11,6 +11,7 @@ mkdir build
cd build
CAMITK_DIR=$CAMITK_BUILD_DIR cmake -DCMAKE_MODULE_PATH:PATH="$CAMITK_SOURCE_DIR/sdk/cmake/modules;$CAMITK_SOURCE_DIR/sdk/cmake/modules/macros" ../completetestcep1
make
$CAMITK_BUILD_DIR/bin/camitk-config \-\-config | grep "\[W\]"
cd
rm -rf $workingDir
-->
......@@ -114,7 +115,7 @@ $USERDEF_LICENCE_END$
<description>Test the second action extension</description>
<actions>
<action>
<name>Test Action 1</name>
<name>Test Action 4</name>
<description>This action use the Test Component 1</description>
<component>TestComponent1</component>
<classification>
......@@ -167,12 +168,12 @@ $USERDEF_LICENCE_END$
</component>
</components>
<dependencies>
<dependency type="library" name="testlib" />
<dependency type="cepLibrary" name="testlib"/>
</dependencies>
</componentExtension>
</componentExtensions>
<libraries>
<library static="true">
<library static="false">
<name>testlib</name>
<description>A simple test lib. This lib will not compile unless some minimal C++ code is present in the generated source. Copy TestLib.h and TestLib.cpp to the library directory before configuration time.</description>
<dependencies>
......
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