#=========================================================
# CLITK = Command Line ITK
-cmake_minimum_required(VERSION 2.4)
-cmake_policy(VERSION 2.4)
+cmake_minimum_required(VERSION 2.8)
+cmake_policy(VERSION 2.8)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
IF (BUILD_TESTING)
OPTION(CLITK_BUILD_TESTING "Test ITK" ON)
INCLUDE(CTest)
- ADD_SUBDIRECTORY(tests)
ENDIF(BUILD_TESTING)
#=========================================================
# Select what is compiled
ADD_SUBDIRECTORY(common)
-add_subdirectory(tools)
-add_subdirectory(segmentation)
-add_subdirectory(registration)
+ADD_SUBDIRECTORY(tools)
+ADD_SUBDIRECTORY(segmentation)
+ADD_SUBDIRECTORY(registration)
# Compilation options
#=========================================================
-
+# Build test when vv has been compiled
+IF(BUILD_TESTING)
+ ADD_SUBDIRECTORY(tests)
+ENDIF(BUILD_TESTING)
--- /dev/null
+# This file is configured by CMake automatically as DartConfiguration.tcl
+# If you choose not to use CMake, this file may be hand configured, by
+# filling in the required variables.
+
+
+# Configuration directories and files
+SourceDirectory: /home/mpech/workspace/vvSource
+BuildDirectory: /home/mpech/workspace/vvSource
+
+# Where to place the cost data store
+CostDataFile:
+
+# Site is something like machine.domain, i.e. pragmatic.crd
+Site: russule
+
+# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
+BuildName: Linux-c++
+
+# Submission information
+IsCDash: TRUE
+CDashVersion:
+QueryCDashVersion:
+DropSite: localhost
+DropLocation: /cdash/submit.php?project=vv
+DropSiteUser:
+DropSitePassword:
+DropSiteMode:
+DropMethod: http
+TriggerSite:
+ScpCommand: /usr/bin/scp
+
+# Dashboard start time
+NightlyStartTime: 00:00:00 EST
+
+# Commands for the build/test/submit cycle
+ConfigureCommand: "/usr/bin/cmake" "/home/mpech/workspace/vvSource"
+MakeCommand: /usr/bin/gmake -i
+DefaultCTestConfigurationType: Release
+
+# CVS options
+# Default is "-d -P -A"
+CVSCommand: /usr/bin/cvs
+CVSUpdateOptions: -d -A -P
+
+# Subversion options
+SVNCommand: /usr/bin/svn
+SVNUpdateOptions:
+
+# Git options
+GITCommand: /usr/bin/git
+GITUpdateOptions:
+GITUpdateCustom:
+
+# Generic update command
+UpdateCommand: /usr/bin/git
+UpdateOptions:
+UpdateType: git
+
+# Compiler info
+Compiler: /usr/bin/c++
+
+# Dynamic analysis and coverage
+PurifyCommand:
+ValgrindCommand:
+ValgrindCommandOptions:
+MemoryCheckCommand: MEMORYCHECK_COMMAND-NOTFOUND
+MemoryCheckCommandOptions:
+MemoryCheckSuppressionFile:
+CoverageCommand: /usr/bin/gcov
+
+# Cluster commands
+SlurmBatchCommand: SLURM_SBATCH_COMMAND-NOTFOUND
+SlurmRunCommand: SLURM_SRUN_COMMAND-NOTFOUND
+
+# Testing options
+# TimeOut is the amount of time in seconds to wait for processes
+# to complete during testing. After TimeOut seconds, the
+# process will be summarily terminated.
+# Currently set to 25 minutes
+TimeOut: 1500
+
+UseLaunchers:
+CurlOptions:
+# warning, if you add new options here that have to do with submit,
+# you have to update cmCTestSubmitCommand.cxx
+
+# For CTest submissions that timeout, these options
+# specify behavior for retrying the submission
+CTestSubmitRetryDelay: 5
+CTestSubmitRetryCount: 3
-# Tests are organized to mirror the clitk directory tree.
-# Eacho subdirectory has its own CMakeLists.txt with the compiling directives
+macro(ADD_GOOGLE_TESTS executable)
+ foreach ( source ${ARGN} )
+ file(READ "${source}" contents)
+ string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
+ foreach(hit ${found_tests})
+ string(REGEX REPLACE ".*\\(([A-Za-z_0-9]+)[, ]*([A-Za-z_0-9]+)\\).*" "\\1.\\2" test_name ${hit})
+ add_test(${test_name} ${executable} --gtest_filter=${test_name})
+ endforeach(hit)
+ endforeach()
+endmacro()
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests/bin)
+SET(BUILDNAME ${CMAKE_SYSTEM_NAME}${CMAKE_OSX_ARCHITECTURES} CACHE INTERNAL DOCSTRING)
+SET(CLITK_DATA_PATH ${PROJECT_BINARY_DIR}/tests/data/ CACHE STRING "dataTest path")
+#todo test if data test path exists
-IF (CLITK_BUILD_TESTING)
+ADD_DEFINITIONS(-DCLITK_DATA_PATH=\"${CLITK_DATA_PATH}\")
- set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests/bin)
-
- # default data path is searched in the project source tree
- FIND_PATH(CLITK_DATA_PATH data PATHS ${PROJECT_SOURCE_DIR})
- IF (CLITK_DATA_PATH STREQUAL "CLITK_DATA_PATH-NOTFOUND" OR CLITK_DATA_PATH STREQUAL "")
- MESSAGE("Data path must be given when tests are enabled.")
- ENDIF (CLITK_DATA_PATH STREQUAL "CLITK_DATA_PATH-NOTFOUND" OR CLITK_DATA_PATH STREQUAL "")
-
- set(CLITK_DATA_PATH ${CLITK_DATA_PATH}/data)
- ADD_DEFINITIONS(-DCLITK_DATA_PATH='"${CLITK_DATA_PATH}"')
+add_library(gtest UNKNOWN IMPORTED)
+set(GTEST_DIR ${ITK_DIR}/../gtest/ CACHE STRING "gtestDir")
+#if windows gtestLibName=gtest.dll else libgtest.a
+set(gtestLibName libgtest.a)
+set(GTEST_LIB ${GTEST_DIR}/build/${gtestLibName})
+message(gtestlib name = ${GTEST_LIB})
+set_property(TARGET gtest PROPERTY IMPORTED_LOCATION "${GTEST_LIB}")
+include_directories(${GTEST_DIR}/include/)
+IF(CLITK_BUILD_TOOLS)
ADD_SUBDIRECTORY(tools)
- #ADD_SUBDIRECTORY(segmentation)
- #ADD_SUBDIRECTORY(registration)
- #ADD_SUBDIRECTORY(common)
+ENDIF()
+IF(CLITK_BUILD_VV)
+ ADD_SUBDIRECTORY(vv)
+ENDIF()
+# ADD_SUBDIRECTORY(segmentation)
+# ADD_SUBDIRECTORY(registration)
+# ADD_SUBDIRECTORY(common)
+
-ENDIF(CLITK_BUILD_TESTING)
-# Add test apps and test executions to this part
-# Test apps are compiled as any other app in the
-# project. Test executions are run using "make test"
-#
-IF(CLITK_BUILD_TESTING)
+include_directories(
+ ${PROJECT_SOURCE_DIR}/common
+ ${PROJECT_SOURCE_DIR}/tools
+ ${GTEST_DIR}/include
+)
- # clitkImageInfo
- ADD_EXECUTABLE(clitkImageInfoTest clitkImageInfoTest.cxx)
- TARGET_LINK_LIBRARIES(clitkImageInfoTest ITKIO)
- ADD_TEST(NAME clitkImageInfoTest COMMAND clitkImageInfoTest)
+FILE(GLOB srcs *.cxx)
+ADD_EXECUTABLE(toolsTest ${srcs})
+ADD_DEFINITIONS(-DTOOLS_PATH=\"${PROJECT_BINARY_DIR}/bin/\")
+target_link_libraries(toolsTest vvLib ${vvExternalLibs} gtest)
- # clitkWriteDicomSeries
- ADD_EXECUTABLE(clitkWriteDicomSeriesTest clitkWriteDicomSeriesTest.cxx)
- TARGET_LINK_LIBRARIES(clitkWriteDicomSeriesTest ITKIO)
- ADD_TEST(NAME clitkWriteDicomSeriesTest COMMAND clitkWriteDicomSeriesTest)
-
-ENDIF(CLITK_BUILD_TESTING)
+# Add all tests found in the source code, calling the executable to run them
+add_google_tests ( ${EXECUTABLE_OUTPUT_PATH}/toolsTest ${srcs})
+SET(BUILDNAME ${BUILDNAME}_tools CACHE INTERNAL DOCSTRING)
\ No newline at end of file
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
===========================================================================*/
-#include <cstdlib>
-#include <cstdio>
-
#include <iostream>
#include <sstream>
#include <string>
-
+#include <fstream>
+#include "gtest/gtest.h"
+#include "stdio.h"
#include <itksys/SystemTools.hxx>
-
-
-const size_t NUMTESTS=2;
-
-// test files
-const char mhd_files[NUMTESTS][128] = {
- CLITK_DATA_PATH"/4d/mhd/00.mhd",
- CLITK_DATA_PATH"/4d/mhd/bh.mhd"
-};
-
-// pre-written validation files. the idea
-// is that the output generated from the test
-// files match the verification files
-const char validation_files[NUMTESTS][128] = {
- CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate3D.out",
- CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate4D.out"
-};
-
-int main(int argc, char** argv)
-{
- system("pwd");
+static inline void compare(std::string mhd, std::string ref){
+ std::ostringstream cmd_line;
+ ASSERT_TRUE(itksys::SystemTools::FileExists(mhd.c_str(), true));
+ cmd_line << TOOLS_PATH<<"clitkImageInfo " << mhd << " > clitkImageInfoTest.out";
+ std::cout << "Executing " << cmd_line.str() << std::endl;
+ system(cmd_line.str().c_str());
- bool failed = false;
- for (size_t i = 0; i < NUMTESTS; i++) {
- std::ostringstream cmd_line;
- cmd_line << "clitkImageInfo " << mhd_files[i] << " > clitkImageInfoTest.out";
-
- std::cout << "Executing " << cmd_line.str() << std::endl;
- system(cmd_line.str().c_str());
-
- // compare output with validation file
- std::cout << "Validating output against " << validation_files[i] << std::endl;
- bool differ = itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", validation_files[i]);
- if (differ)
- {
- failed = true;
- std::cout << "FAILED: Program output and reference do not match." << std::endl;
- }
- else
- {
- itksys::SystemTools::RemoveFile("clitkImageInfoTest.out");
- std::cout << "PASSED" << std::endl;
- }
- }
- return failed ? -1 : 0;
+ bool differ = itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", ref.c_str());
+ remove("clitkImageInfoTest.out");
+ EXPECT_FALSE(differ);
+}
+TEST(clitkImageInfoTest, main){
+ std::string mhd1=std::string(CLITK_DATA_PATH)+"4d/mhd/00.mhd";
+ std::string ref1=std::string(CLITK_DATA_PATH)+"tools/clitkImageInfoTestValidate3D.out";
+ compare(mhd1, ref1);
+
+ std::string mhd2=std::string(CLITK_DATA_PATH)+"4d/mhd/bh.mhd";
+ std::string ref2=std::string(CLITK_DATA_PATH)+"tools/clitkImageInfoTestValidate4D.out";
+ compare(mhd2, ref2);
}
\ No newline at end of file
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
===========================================================================*/
-#include <cstdlib>
-#include <cstdio>
-
#include <iostream>
#include <sstream>
-#include <cassert>
-
+#include "gtest/gtest.h"
#include <itksys/SystemTools.hxx>
-
-const size_t NUMTESTS=1;
-
-const char mhd_files[NUMTESTS][128] = {
- CLITK_DATA_PATH"/3d/mhd/00.mhd"
-};
-
-const char dcm_dirs[NUMTESTS][128] = {
- CLITK_DATA_PATH"/3d/dcm/1.2.840.113704.1.111.536.1248695032.26"
-};
-
-int main(int argc, char** argv)
-{
- bool failed = false;
- for (size_t i = 0; i < NUMTESTS; i++) {
- std::ostringstream cmd_line;
- cmd_line << "clitkWriteDicomSeries -i " << mhd_files[i] << " -d " << dcm_dirs[i] << " -o dcm --verbose";
-
- std::cout << "Executing " << cmd_line.str() << std::endl;
- int err = system(cmd_line.str().c_str());
- if (err != 0)
- {
- failed = true;
- std::cout << "FAILED (errno = " << err << ")" << std::endl;
- }
- else
- {
- itksys::SystemTools::RemoveADirectory("dcm");
- std::cout << "PASSED" << std::endl;
- }
- }
- return failed ? -1 : 0;
+TEST(clitkWriteDicomSeriesTest, main){
+
+ std::string fIn=std::string(CLITK_DATA_PATH)+"/3d/mhd/00.mhd";
+ std::string fOut=std::string(CLITK_DATA_PATH)+"/3d/dcm/1.2.840.113704.1.111.536.1248695032.26";
+ ASSERT_TRUE(itksys::SystemTools::FileExists(fIn.c_str(), true));
+ std::ostringstream cmd_line;
+ cmd_line << TOOLS_PATH <<"clitkWriteDicomSeries -i " << fIn << " -d " << fOut << " -o dcm --verbose";
+ EXPECT_TRUE(itksys::SystemTools::FileExists(fOut.c_str(), false));
+ EXPECT_TRUE(itksys::SystemTools::FileExists("dcm", false));
+ EXPECT_EQ(0, system(cmd_line.str().c_str()));
+ //does directory exists
+ itksys::SystemTools::RemoveADirectory("dcm");
}
\ No newline at end of file
--- /dev/null
+#include "gtest/gtest.h"
+int main(int argc, char** argv){
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+include_directories(
+ ${PROJECT_SOURCE_DIR}/vv
+ ${PROJECT_BINARY_DIR}/vv
+ ${QT_INCLUDES}
+ ${QT_INCLUDE_DIR}
+ ${QT_QTGUI_INCLUDE_DIR}
+ ${QT_QTCORE_INCLUDE_DIR}
+ ${QT_QTNETWORK_INCLUDE_DIR}
+ ${PROJECT_SOURCE_DIR}/common
+ ${PROJECT_SOURCE_DIR}/tools
+ ${PROJECT_SOURCE_DIR}/segmentation
+ ${QT_LIBRARY_DIR}
+ ${GTEST_DIR}/include
+)
+
+FILE(GLOB srcs *.cxx)
+ADD_EXECUTABLE(vvTest ${srcs})
+target_link_libraries(vvTest vvLib ${vvExternalLibs} gtest)
+
+# Add all tests found in the source code, calling the executable to run them
+add_google_tests ( ${EXECUTABLE_OUTPUT_PATH}/vvTest ${srcs})
+SET(BUILDNAME ${BUILDNAME}_vv CACHE INTERNAL DOCSTRING)
--- /dev/null
+#include "gtest/gtest.h"
+#include <iostream>
+#include <QApplication>
+int main(int argc, char** argv){
+ QApplication* q=new QApplication ( argc, argv );
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================*/
+#include "vvRegisterForm.h"
+#include <QUrl>
+#include <QSettings>
+#include "gtest/gtest.h"
+#include "vvCommon.h"
+#include <stdio.h>
+#include <fstream>
+const std::string data_path = "/home/mpech/workspace/vvSource/tests/data/";
+TEST(vvRegisterForm, canPush){
+ QUrl url;
+ //the file exists with some old lines
+ vvRegisterForm* v=new vvRegisterForm(url, QString::fromStdString(data_path+".settingsCanPush.txt"), QSettings::NativeFormat);
+ std::ifstream inFile((data_path+".settingsCanPush.txt").c_str(), std::ifstream::in);
+ ASSERT_FALSE(inFile.fail());
+ EXPECT_TRUE(v->canPush());
+
+ //the file doesn't exist
+ vvRegisterForm* v2=new vvRegisterForm(url, QString::fromStdString(data_path+".settings_notFound.txt"), QSettings::NativeFormat);
+ EXPECT_TRUE(v2->canPush());
+
+ //the current version is the same
+ QString strSettings=QString::fromStdString(data_path+".settings2.txt");
+ QSettings settings(strSettings, QSettings::NativeFormat);
+ settings.setValue("vvVersion", VV_VERSION);
+ vvRegisterForm* v3=new vvRegisterForm(url, strSettings, QSettings::NativeFormat);
+ EXPECT_FALSE(v3->canPush());
+}
+TEST(vvRegisterForm, acquitPushed){
+ QUrl url;
+ vvRegisterForm* v=new vvRegisterForm(url, QString::fromStdString(data_path+".settingsAcquit.txt"), QSettings::NativeFormat);
+ ASSERT_TRUE(v->canPush());
+ v->acquitPushed();
+ EXPECT_FALSE(v->canPush());
+ remove((data_path+".settingsAcquit.txt").c_str());
+}
QT4_WRAP_CPP(vv_SRCS ${tool}.h)
QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
endforeach(tool)
-
#Add the common source files
foreach(tool ${vv_COMMON})
SET(vv_SRCS ${vv_SRCS} ${tool}.cxx)
QT4_WRAP_CPP(vv_SRCS ${tool}.h)
endforeach(tool)
-
# if Windows and Qt was built as a static lib then don't set QT_DLL flag
SET(QT_STATIC 0)
IF (WIN32)
ENDIF(WIN32)
LINK_DIRECTORIES(${QT_LIBRARY_DIR})
-ADD_EXECUTABLE(vv ${vv_SRCS} vv.cxx ${vv_UI_CXX} ${EXE_ICON})
-ADD_DEPENDENCIES(vv clitkSegmentationGgoLib)
-TARGET_LINK_LIBRARIES(vv clitkDicomRTStruct)
-
#=========================================================
#Add each tool's dependencies
foreach(tool ${vv_TOOLS})
- target_link_libraries(vv ${${tool}_LIBS})
+ SET(toolLibs ${toolLibs} ${${tool}_LIBS})
endforeach(tool)
-
#=========================================================
#Add Foundation Libraries (this should be after our libraries, since we depend
#on them)
-TARGET_LINK_LIBRARIES(vv
-clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid)
+SET(foundationLibraries clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid)
+#=========================================================
+#Create binary and libs for tests
+SET(vvExternalLibs clitkSegmentationGgoLib clitkDicomRTStruct ${toolLibs} ${foundationLibraries} CACHE INTERNAL DOCSTRING)
+ADD_EXECUTABLE(vv ${vv_SRCS} vv.cxx ${vv_UI_CXX} ${EXE_ICON})
+ADD_DEPENDENCIES(vv clitkSegmentationGgoLib)
+IF(BUILD_TESTING)
+ target_link_libraries(vv ${vvExternalLibs})
+ add_library(vvLib ${vv_SRCS} vv.cxx ${vv_UI_CXX} ${EXE_ICON})
+ENDIF(BUILD_TESTING)
#=========================================================
# Install options (also used by CPack)
IF(UNIX AND NOT APPLE)
INCLUDE(CPack)
#=========================================================
#=========================================================
-configure_file (
- vvCommon.h.in
- vvCommon.h
-)
+configure_file(vvCommon.h.in vvCommon.h)
#=========================================================
\ No newline at end of file