Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated last test cases to automated registration #1861

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,29 @@ AC_DEFUN([QL_CHECK_BOOST_VERSION_1_59_OR_HIGHER],
AC_DEFUN([QL_CHECK_BOOST_UNIT_TEST],
[AC_MSG_CHECKING([for Boost.Test])
AC_REQUIRE([AC_PROG_CC])
ql_original_CXXFLAGS=$CXXFLAGS
for test_flags in "" \
"-DBOOST_TEST_MAIN -DBOOST_TEST_DYN_LINK" ; do
# static version
CXXFLAGS="$ql_original_CXXFLAGS $test_flags"
boost_unit_found=no
AC_LINK_IFELSE([AC_LANG_SOURCE(
[@%:@include <boost/test/included/unit_test.hpp>
using namespace boost::unit_test_framework;
test_suite*
init_unit_test_suite(int argc, char** argv)
{
return (test_suite*) 0;
}
])],
[boost_unit_found=yes
boost_defines=$test_flags
break],
[])
done
CXXFLAGS="$ql_original_CXXFLAGS"
# static version
boost_unit_found=no
AC_LINK_IFELSE([AC_LANG_SOURCE(
[@%:@include <boost/test/included/unit_test.hpp>
using namespace boost::unit_test_framework;
test_suite*
init_unit_test_suite(int argc, char** argv)
{
return (test_suite*) 0;
}
])],
[boost_unit_found=yes
boost_defines=$test_flags
break],
[])
if test "$boost_unit_found" = no ; then
AC_MSG_RESULT([no])
AC_SUBST([HAVE_BOOST_TEST],[""])
AC_SUBST([BOOST_UNIT_TEST_MAIN_CXXFLAGS],[""])
AC_MSG_WARN([Boost unit-test framework not found.])
AC_MSG_WARN([The test suite will be disabled.])
else
AC_MSG_RESULT([yes])
AC_SUBST([HAVE_BOOST_TEST],["yes"])
AC_SUBST([BOOST_UNIT_TEST_MAIN_CXXFLAGS],[$boost_defines])
fi
])

Expand Down
20 changes: 3 additions & 17 deletions test-suite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ set(QL_TEST_SOURCES
)

set(QL_TEST_HEADERS
marketmodel.hpp
paralleltestrunner.hpp
preconditions.hpp
quantlibglobalfixture.hpp
Expand Down Expand Up @@ -212,27 +211,15 @@ set(QL_BENCHMARK_SOURCES
swaptionvolstructuresutilities.hpp
)

if (QL_BUILD_TEST_SUITE OR QL_BUILD_BENCHMARK)
add_library(ql_unit_test_main STATIC main.cpp)
target_include_directories(ql_unit_test_main PRIVATE
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR})
target_include_directories(ql_unit_test_main SYSTEM PRIVATE
${Boost_INCLUDE_DIRS})
if (NOT Boost_USE_STATIC_LIBS)
target_compile_definitions(ql_unit_test_main PRIVATE BOOST_TEST_DYN_LINK)
endif()
endif()

if (QL_BUILD_TEST_SUITE)
add_executable(ql_test_suite ${QL_TEST_SOURCES} ${QL_TEST_HEADERS})
set_target_properties(ql_test_suite PROPERTIES OUTPUT_NAME "quantlib-test-suite")
set_source_files_properties(quantlibtestsuite.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION true)
if (NOT Boost_USE_STATIC_LIBS)
target_compile_definitions(ql_test_suite PRIVATE BOOST_ALL_DYN_LINK BOOST_TEST_DYN_LINK)
target_compile_definitions(ql_test_suite PRIVATE BOOST_ALL_DYN_LINK)
endif()
target_link_libraries(ql_test_suite PRIVATE
ql_library
ql_unit_test_main
${QL_THREAD_LIBRARIES})
if(MSVC AND CMAKE_UNITY_BUILD)
# for Unity builds, we need to add /bigobj
Expand All @@ -249,11 +236,10 @@ IF (QL_BUILD_BENCHMARK)
set_target_properties(ql_benchmark PROPERTIES OUTPUT_NAME "quantlib-benchmark")
set_source_files_properties(quantlibbenchmark.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION true)
if (NOT Boost_USE_STATIC_LIBS)
target_compile_definitions(ql_benchmark PRIVATE BOOST_ALL_DYN_LINK BOOST_TEST_DYN_LINK)
target_compile_definitions(ql_benchmark PRIVATE BOOST_ALL_DYN_LINK)
endif()
target_link_libraries(ql_benchmark PRIVATE
ql_library
ql_unit_test_main
${QL_THREAD_LIBRARIES})
if(MSVC AND CMAKE_UNITY_BUILD)
# for Unity builds, we need to add /bigobj
Expand Down
9 changes: 2 additions & 7 deletions test-suite/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ QL_TEST_SRCS = \
zerocouponswap.cpp

QL_TEST_HDRS = \
marketmodel.hpp \
preconditions.hpp \
quantlibglobalfixture.hpp \
swaptionvolstructuresutilities.hpp \
Expand Down Expand Up @@ -226,10 +225,6 @@ if BUILD_TEST_SUITE

AM_CPPFLAGS = -I${top_builddir} -I${top_srcdir}

noinst_LTLIBRARIES = libUnitMain.la
libUnitMain_la_SOURCES = main.cpp
libUnitMain_la_CXXFLAGS = ${BOOST_UNIT_TEST_MAIN_CXXFLAGS}

if AUTO_BENCHMARK
bin_PROGRAMS = quantlib-test-suite quantlib-benchmark
else
Expand Down Expand Up @@ -272,10 +267,10 @@ EXTRA_DIST =

endif

quantlib_test_suite_LDADD = libUnitMain.la ${top_builddir}/ql/libQuantLib.la \
quantlib_test_suite_LDADD = ${top_builddir}/ql/libQuantLib.la \
${PTHREAD_LIB} ${BOOST_INTERPROCESS_LIB}

quantlib_benchmark_LDADD = libUnitMain.la ${top_builddir}/ql/libQuantLib.la \
quantlib_benchmark_LDADD = ${top_builddir}/ql/libQuantLib.la \
${PTHREAD_LIB}

TESTS = quantlib-test-suite$(EXEEXT)
Expand Down
20 changes: 0 additions & 20 deletions test-suite/main.cpp

This file was deleted.

Loading