mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
update of the testing framework:
replaced the QTestLib framework my custom macros and a (optional) custom script to run the tests from ctest.
This commit is contained in:
@@ -2,43 +2,78 @@ IF(BUILD_TESTS)
|
||||
|
||||
OPTION(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions" OFF)
|
||||
|
||||
# similar to SET_TARGET_PROPERTIES but append the property instead of overwritting it
|
||||
MACRO(EI_ADD_TARGET_PROPERTY target prop value)
|
||||
|
||||
GET_TARGET_PROPERTY(previous ${target} ${prop})
|
||||
SET_TARGET_PROPERTIES(${target} PROPERTIES ${prop} "${previous} ${value}")
|
||||
|
||||
ENDMACRO(EI_ADD_TARGET_PROPERTY)
|
||||
|
||||
# Macro to add a test
|
||||
#
|
||||
# the unique parameter testname must correspond to a file
|
||||
# <testname>.cpp which follows this pattern:
|
||||
#
|
||||
# #include "main.h"
|
||||
# void test_<testname>() { ... }
|
||||
#
|
||||
# this macro add an executable test_<testname> as well as a ctest test
|
||||
# named <testname>
|
||||
#
|
||||
# On platforms with bash simply run:
|
||||
# "ctest -V" or "ctest -V -R <testname>"
|
||||
# On other platform use ctest as usual
|
||||
#
|
||||
MACRO(EI_ADD_TEST testname)
|
||||
|
||||
SET(targetname test_${testname})
|
||||
|
||||
ADD_EXECUTABLE(${targetname} ${testname}.cpp)
|
||||
|
||||
IF(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
SET_TARGET_PROPERTIES(${targetname} PROPERTIES COMPILE_FLAGS "-fexceptions")
|
||||
OPTION(EIGEN_DEBUG_ASSERTS "Enable debuging of assertions" OFF)
|
||||
IF(EIGEN_DEBUG_ASSERTS)
|
||||
SET_TARGET_PROPERTIES(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_DEBUG_ASSERTS=1")
|
||||
ENDIF(EIGEN_DEBUG_ASSERTS)
|
||||
|
||||
ELSE(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
SET_TARGET_PROPERTIES(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_NO_ASSERTION_CHECKING=1")
|
||||
|
||||
ENDIF(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
EI_ADD_TARGET_PROPERTY(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
|
||||
|
||||
IF(WIN32)
|
||||
ADD_TEST(${testname} "${targetname}")
|
||||
ELSE(WIN32)
|
||||
ADD_TEST(${testname} "${CMAKE_CURRENT_SOURCE_DIR}/runtest.sh" "${testname}")
|
||||
ENDIF(WIN32)
|
||||
|
||||
TARGET_LINK_LIBRARIES(${targetname} ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} )
|
||||
|
||||
ENDMACRO(EI_ADD_TEST)
|
||||
|
||||
|
||||
ENABLE_TESTING()
|
||||
|
||||
FIND_PACKAGE(Qt4 REQUIRED)
|
||||
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
|
||||
|
||||
SET(test_SRCS
|
||||
cholesky.cpp
|
||||
main.cpp
|
||||
basicstuff.cpp
|
||||
linearstructure.cpp
|
||||
product.cpp
|
||||
adjoint.cpp
|
||||
submatrices.cpp
|
||||
miscmatrices.cpp
|
||||
smallvectors.cpp
|
||||
map.cpp
|
||||
cwiseop.cpp
|
||||
# determinant.cpp
|
||||
triangular.cpp
|
||||
)
|
||||
QT4_AUTOMOC(${test_SRCS})
|
||||
|
||||
ADD_EXECUTABLE(test ${test_SRCS})
|
||||
TARGET_LINK_LIBRARIES(test ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY})
|
||||
IF(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
SET_TARGET_PROPERTIES(test PROPERTIES COMPILE_FLAGS "-fexceptions")
|
||||
OPTION(EIGEN_DEBUG_ASSERTS "Enable debuging of assertions" OFF)
|
||||
IF(EIGEN_DEBUG_ASSERTS)
|
||||
ADD_DEFINITIONS(-DEIGEN_DEBUG_ASSERTS=1)
|
||||
ENDIF(EIGEN_DEBUG_ASSERTS)
|
||||
|
||||
ELSE(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
ADD_DEFINITIONS(-DEIGEN_NO_ASSERTION_CHECKING=1)
|
||||
|
||||
ENDIF(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
ADD_TEST(Eigen test)
|
||||
EI_ADD_TEST(basicstuff)
|
||||
EI_ADD_TEST(miscmatrices)
|
||||
EI_ADD_TEST(adjoint)
|
||||
EI_ADD_TEST(submatrices)
|
||||
EI_ADD_TEST(smallvectors)
|
||||
EI_ADD_TEST(cwiseop)
|
||||
EI_ADD_TEST(map)
|
||||
EI_ADD_TEST(linearstructure)
|
||||
EI_ADD_TEST(product)
|
||||
EI_ADD_TEST(triangular)
|
||||
EI_ADD_TEST(cholesky)
|
||||
# EI_ADD_TEST(determinant)
|
||||
|
||||
ENDIF(BUILD_TESTS)
|
||||
|
||||
Reference in New Issue
Block a user