Skip to content

Commit

Permalink
Merge pull request #164 from pbauman/cpp-unit
Browse files Browse the repository at this point in the history
Add CPPUnit Testing Framework
  • Loading branch information
pbauman committed Sep 9, 2015
2 parents 8cdbb04 + f5b0d21 commit e330197
Show file tree
Hide file tree
Showing 27 changed files with 2,323 additions and 720 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ compiler:
- clang
before_script:
- sudo apt-get update -qq
- sudo apt-get install -qq libeigen3-dev libgsl0-dev
- sudo apt-get install -qq libeigen3-dev libgsl0-dev libcppunit-1.12-1 libcppunit-dev
script:
- echo apt-get install -qq libeigen3-dev libgsl0-dev fglrx=2:8.960-0ubuntu1 opencl-headers libboost-chrono1.48-dev libboost-date-time1.48-dev libboost-filesystem1.48-dev libboost-system1.48-dev libboost-thread1.48-dev libboost-program-options1.48-dev libboost-test1.48-dev
- echo apt-get install -qq libeigen3-dev libgsl0-dev libcppunit-1.12-1 libcppunit-dev fglrx=2:8.960-0ubuntu1 opencl-headers libboost-chrono1.48-dev libboost-date-time1.48-dev libboost-filesystem1.48-dev libboost-system1.48-dev libboost-thread1.48-dev libboost-program-options1.48-dev libboost-test1.48-dev
- echo git clone https://github.com/ddemidov/vexcl
- ./bootstrap
- echo ./configure --with-vexcl=${PWD}/vexcl "takes too much RAM to compile"
Expand Down
15 changes: 15 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ if (test x$HAVE_GSL = x1); then
fi
AM_CONDITIONAL(ANTIOCH_ENABLE_GSL, test x$HAVE_GSL = x1)

# -------------------------------------------------------------
# cppunit C++ unit testing -- enabled by default
# -------------------------------------------------------------
AC_ARG_ENABLE(cppunit,
AS_HELP_STRING([--disable-cppunit],
[Build without cppunit C++ unit testing support]))
AS_IF([test "x$enable_cppunit" != "xno"], [
AM_PATH_CPPUNIT([1.10.0],[enablecppunit=yes],[enablecppunit=no])
])

if (test x$HAVE_CPPUNIT = x1); then
antioch_optional_test_INCLUDES="$CPPUNIT_CPPFLAGS $antioch_optional_test_INCLUDES"
antioch_optional_test_LDFLAGS="$CPPUNIT_LIBS $antioch_optional_test_LDFLAGS"
fi
AM_CONDITIONAL(ANTIOCH_ENABLE_CPPUNIT, test x$enablecppunit = xyes)

AC_SUBST(antioch_optional_INCLUDES)
AC_SUBST(antioch_optional_test_INCLUDES)
Expand Down
6 changes: 5 additions & 1 deletion doxygen/antioch.dox.in
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,11 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.

PREDEFINED =
PREDEFINED = ANTIOCH_HAVE_CPPUNIT \
ANTIOCH_HAVE_EIGEN \
ANTIOCH_HAVE_METAPHYSICL \
ANTIOCH_HAVE_VEXCL \
ATNIOCH_HAVE_GSL

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
Expand Down
98 changes: 98 additions & 0 deletions m4/common/cppunit.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
dnl
dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl
AC_DEFUN([AM_PATH_CPPUNIT],
[
AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)],
cppunit_config_prefix="$withval", cppunit_config_prefix="")
AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)],
cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
if test x$cppunit_config_exec_prefix != x ; then
cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
if test x${CPPUNIT_CONFIG+set} != xset ; then
CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
fi
fi
if test x$cppunit_config_prefix != x ; then
cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
if test x${CPPUNIT_CONFIG+set} != xset ; then
CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
fi
fi
AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
cppunit_version_min=$1
AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
no_cppunit=""
if test "$CPPUNIT_CONFIG" = "no" ; then
AC_MSG_RESULT(no)
no_cppunit=yes
else
CPPUNIT_CPPFLAGS=`$CPPUNIT_CONFIG --cflags`
CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
CPPUNIT_VERSION=`$CPPUNIT_CONFIG --version`
CPPUNIT_PREFIX=`$CPPUNIT_CONFIG --prefix`
cppunit_version=`$CPPUNIT_CONFIG --version`
cppunit_major_version=`echo $cppunit_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
cppunit_minor_version=`echo $cppunit_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
cppunit_micro_version=`echo $cppunit_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
cppunit_major_min=`echo $cppunit_version_min | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
if test "x${cppunit_major_min}" = "x" ; then
cppunit_major_min=0
fi
cppunit_minor_min=`echo $cppunit_version_min | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
if test "x${cppunit_minor_min}" = "x" ; then
cppunit_minor_min=0
fi
cppunit_micro_min=`echo $cppunit_version_min | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x${cppunit_micro_min}" = "x" ; then
cppunit_micro_min=0
fi
cppunit_version_proper=`expr \
$cppunit_major_version \> $cppunit_major_min \| \
$cppunit_major_version \= $cppunit_major_min \& \
$cppunit_minor_version \> $cppunit_minor_min \| \
$cppunit_major_version \= $cppunit_major_min \& \
$cppunit_minor_version \= $cppunit_minor_min \& \
$cppunit_micro_version \>= $cppunit_micro_min `
if test "$cppunit_version_proper" = "1" ; then
AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
else
AC_MSG_RESULT(no)
no_cppunit=yes
fi
fi
if test "x$no_cppunit" = x ; then
ifelse([$2], , :, [$2])
AC_SUBST(HAVE_CPPUNIT,[1])
AC_DEFINE([HAVE_CPPUNIT], [1], [Enable CPPUnit Tests])
else
CPPUNIT_CPPFLAGS=""
CPPUNIT_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(CPPUNIT_VERSION)
AC_SUBST(CPPUNIT_PREFIX)
AC_SUBST(CPPUNIT_CPPFLAGS)
AC_SUBST(CPPUNIT_LIBS)
])



10 changes: 10 additions & 0 deletions m4/config_summary.m4
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ echo Revision id................... : $BUILD_VERSION
echo
echo Testing Options:
echo ' 'Number of tuples............ : $n_tuples
if test "x$HAVE_CPPUNIT" = "x1"; then
echo ' 'CPPUnit..................... : yes
echo ' 'CPPUNIT_VERSION........... : $CPPUNIT_VERSION
echo ' 'CPPUNIT_CPPFLAGS.......... : $CPPUNIT_CPPFLAGS
echo ' 'CPPUNIT_LIBS.............. : $CPPUNIT_LIBS
else
echo ' 'CPPUnit..................... : no
fi
echo
echo Optional Libraries:
if test "x$HAVE_EIGEN" = "x1"; then
echo ' 'Eigen....................... : yes
else
Expand Down
45 changes: 33 additions & 12 deletions test/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
EXTRA_DIST = input_files

check_PROGRAMS =
check_PROGRAMS += standard_unit_tests
check_PROGRAMS += eigen_unit_tests
check_PROGRAMS += vexcl_unit_tests
check_PROGRAMS += metaphysicl_unit_tests
check_PROGRAMS += gsl_unit_tests
check_PROGRAMS += chem_mixture_unit
check_PROGRAMS += chem_mixture_vec_unit
check_PROGRAMS += nasa_evaluator_unit
Expand All @@ -14,8 +19,6 @@ check_PROGRAMS += hercourtessen_rate_vec_unit
check_PROGRAMS += berthelot_rate_unit
check_PROGRAMS += berthelot_rate_vec_unit
check_PROGRAMS += arrhenius_rate_deriv
check_PROGRAMS += arrhenius_rate_unit
check_PROGRAMS += arrhenius_rate_vec_unit
check_PROGRAMS += kooij_rate_unit
check_PROGRAMS += kooij_rate_vec_unit
check_PROGRAMS += berthelothercourtessen_rate_unit
Expand Down Expand Up @@ -66,8 +69,6 @@ check_PROGRAMS += molecular_binary_diffusion_unit
check_PROGRAMS += molecular_binary_diffusion_vec_unit
check_PROGRAMS += kinetics_theory_viscosity_unit
check_PROGRAMS += kinetics_theory_viscosity_vec_unit
check_PROGRAMS += gsl_spline_unit
check_PROGRAMS += gsl_spline_vec_unit
check_PROGRAMS += Stockmayer_unit

# Eigen Tests
Expand All @@ -86,13 +87,36 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/thermal_conduction/include
AM_CPPFLAGS += -I$(top_srcdir)/src/transport/include
AM_CPPFLAGS += -I$(top_srcdir)/src/utilities/include
AM_CPPFLAGS += -I$(top_builddir)/src/utilities/include #antioch_version.h
AM_CPPFLAGS += -I$(top_srcdir)/test/standard_unit
AM_CPPFLAGS += $(antioch_optional_test_INCLUDES)

AM_LDFLAGS = $(antioch_optional_test_LDFLAGS)
LIBS = $(antioch_optional_test_LIBS)

LDADD = $(top_builddir)/src/libantioch.la

pkginclude_HEADERS =

standard_unit_tests_SOURCES = standard_unit/arrhenius_rate_test.C \
standard_unit/arrhenius_rate_valarray_test.C \
standard_unit/standard_unit_tests.C

eigen_unit_tests_SOURCES = eigen_unit/arrhenius_rate_eigen_test.C \
eigen_unit/eigen_unit_tests.C

vexcl_unit_tests_SOURCES = vexcl_unit/arrhenius_rate_vexcl_test.C \
vexcl_unit/vexcl_unit_tests.C

metaphysicl_unit_tests_SOURCES = metaphysicl_unit/arrhenius_rate_metaphysicl_test.C \
metaphysicl_unit/metaphysicl_unit_tests.C

gsl_unit_tests_SOURCES = gsl_unit/gsl_spliner_test.C \
gsl_unit/gsl_spliner_vec_test.C \
gsl_unit/gsl_unit_tests.C

pkginclude_HEADERS += standard_unit/reaction_rate_test_base.h
pkginclude_HEADERS += standard_unit/arrhenius_rate_test_helper.h

# Sources for these tests
chem_mixture_unit_SOURCES = chem_mixture_unit.C
chem_mixture_vec_unit_SOURCES = chem_mixture_vec_unit.C
Expand All @@ -107,8 +131,6 @@ hercourtessen_rate_vec_unit_SOURCES = hercourtessen_rate_vec_unit.C
berthelot_rate_unit_SOURCES = berthelot_rate_unit.C
berthelot_rate_vec_unit_SOURCES = berthelot_rate_vec_unit.C
arrhenius_rate_deriv_SOURCES = arrhenius_rate_deriv.C
arrhenius_rate_unit_SOURCES = arrhenius_rate_unit.C
arrhenius_rate_vec_unit_SOURCES = arrhenius_rate_vec_unit.C
berthelothercourtessen_rate_unit_SOURCES = berthelothercourtessen_rate_unit.C
berthelothercourtessen_rate_vec_unit_SOURCES = berthelothercourtessen_rate_vec_unit.C
kooij_rate_unit_SOURCES = kooij_rate_unit.C
Expand Down Expand Up @@ -158,8 +180,6 @@ molecular_binary_diffusion_unit_SOURCES = molecular_binary_diffusion_unit.C
molecular_binary_diffusion_vec_unit_SOURCES = molecular_binary_diffusion_vec_unit.C
kinetics_theory_viscosity_unit_SOURCES = kinetics_theory_viscosity_unit.C
kinetics_theory_viscosity_vec_unit_SOURCES = kinetics_theory_viscosity_vec_unit.C
gsl_spline_unit_SOURCES = gsl_spline_unit.C
gsl_spline_vec_unit_SOURCES = gsl_spline_vec_unit.C
ideal_gas_micro_thermo_unit_SOURCES = ideal_gas_micro_thermo_unit.C
Stockmayer_unit_SOURCES = Stockmayer_unit.C

Expand All @@ -170,6 +190,11 @@ stat_mech_thermo_unit_eigen_SOURCES = stat_mech_thermo_unit_eigen.C

#Define tests to actually be run
TESTS =
TESTS += standard_unit_tests
TESTS += eigen_unit_tests
TESTS += vexcl_unit_tests
TESTS += metaphysicl_unit_tests
TESTS += gsl_unit_tests
TESTS += chem_mixture_unit
TESTS += chem_mixture_vec_unit
TESTS += nasa_evaluator_unit.sh
Expand All @@ -183,8 +208,6 @@ TESTS += hercourtessen_rate_unit
TESTS += berthelot_rate_vec_unit
TESTS += berthelot_rate_vec_unit
TESTS += arrhenius_rate_deriv
TESTS += arrhenius_rate_unit
TESTS += arrhenius_rate_vec_unit
TESTS += berthelothercourtessen_rate_unit
TESTS += berthelothercourtessen_rate_vec_unit
TESTS += kooij_rate_unit
Expand Down Expand Up @@ -235,8 +258,6 @@ TESTS += molecular_binary_diffusion_unit
TESTS += molecular_binary_diffusion_vec_unit
TESTS += kinetics_theory_viscosity_unit
TESTS += kinetics_theory_viscosity_vec_unit
TESTS += gsl_spline_unit
TESTS += gsl_spline_vec_unit
TESTS += Stockmayer_unit


Expand Down
Loading

0 comments on commit e330197

Please sign in to comment.