diff --git a/ChangeLog b/ChangeLog index d1db9df..863df2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2016-06-24 Juergen Knoedlseder +2016-07-04 Juergen Knoedlseder * Version 1.1.0 released ========================= @@ -61,6 +61,7 @@ Use GFilename in GFits to store filename (#1649) Load CTA GTI extension from the HDU name provided by the DSS keyword (#1598) Support Fermi LAT Pass 8 response functions (#1517) + Support out of source builds (#1484) Finalize implementation of CTA On/Off fitting (#1044, #1781) diff --git a/Makefile.am b/Makefile.am index ad1ffcd..217009d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for GammaLib package # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Include M4 macros ACLOCAL_AMFLAGS = -I m4 @@ -25,7 +44,7 @@ doc_DATA = \ AUTHORS \ ChangeLog \ COPYING \ - INSTALL \ + INSTALL \ NEWS \ README.md docdir = ${datadir}/doc/${PACKAGE} diff --git a/NEWS b/NEWS index e165c87..063c025 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ New Features and Important Changes in GammaLib 1.1.0 Author(s) : Juergen Knoedlseder -24 June 2016 +4 July 2016 1. Introduction @@ -143,7 +143,7 @@ The interface for the following methods has been changed: 3. Configuration ----------------- -None +The GammaLib package now supports out of source builds (#1484). 4. Application module diff --git a/configure.ac b/configure.ac index abede89..b45451e 100644 --- a/configure.ac +++ b/configure.ac @@ -76,14 +76,6 @@ AC_DEFINE_UNQUOTED([PACKAGE_PREFIX], "${gammalib_prefix}", [Location where libra ############################################################################# -# Determine source directory for unit testing # -############################################################################# -PACKAGE_SOURCE=`pwd` -AC_DEFINE_UNQUOTED([PACKAGE_SOURCE], "${PACKAGE_SOURCE}", [Location where source is installed]) -AC_SUBST(PACKAGE_SOURCE) - - -############################################################################# # Check for programs that are required by automake # ############################################################################# AC_PROG_MAKE_SET @@ -563,7 +555,7 @@ esac # Checks for optional instrument specific interfaces # ############################################################################# # Checks for the existence of instrument specific interfaces -AC_CHECK_FILE([inst/README.md], +AC_CHECK_FILE([$srcdir/inst/README.md], [with_inst=yes], [with_inst=no]) AM_CONDITIONAL([WITH_INST], [test "x$with_inst" = "xyes"]) @@ -575,7 +567,7 @@ AC_ARG_WITH([mwl], [], [with_mwl=yes]) if test "x$with_mwl" = "xyes"; then - AC_CHECK_FILE([inst/mwl/README.md], + AC_CHECK_FILE([$srcdir/inst/mwl/README.md], [with_mwl=yes], [with_mwl=no]) fi @@ -588,7 +580,7 @@ AC_ARG_WITH([cta], [], [with_cta=yes]) if test "x$with_cta" = "xyes"; then - AC_CHECK_FILE([inst/cta/README.md], + AC_CHECK_FILE([$srcdir/inst/cta/README.md], [with_cta=yes], [with_cta=no]) fi @@ -601,7 +593,7 @@ AC_ARG_WITH([lat], [], [with_lat=yes]) if test "x$with_lat" = "xyes"; then - AC_CHECK_FILE([inst/lat/README.md], + AC_CHECK_FILE([$srcdir/inst/lat/README.md], [with_lat=yes], [with_lat=no]) fi @@ -614,7 +606,7 @@ AC_ARG_WITH([com], [], [with_com=yes]) if test "x$with_com" = "xyes"; then - AC_CHECK_FILE([inst/com/README.md], + AC_CHECK_FILE([$srcdir/inst/com/README.md], [with_com=yes], [with_com=no]) fi @@ -1393,12 +1385,13 @@ AC_CONFIG_FILES([Makefile include/Makefile test/Makefile test/test_python.sh + test/test_examples.sh + test/reports/Makefile pyext/Makefile pyext/setup.py pyext/gammalib/__init__.py examples/Makefile examples/cpp/Makefile - test/test_examples.sh gammalib.pc testconf.sh], [if test -f test/test_python.sh; then chmod +x test/test_python.sh; fi; diff --git a/examples/Makefile.am b/examples/Makefile.am index a97573f..309bbea 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for examples module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set sub directories SUBDIRS = cpp diff --git a/examples/cpp/Makefile.am b/examples/cpp/Makefile.am index 2de59d3..2fe94ca 100644 --- a/examples/cpp/Makefile.am +++ b/examples/cpp/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for example/cpp module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Darwin support MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ @@ -29,40 +48,40 @@ check_PROGRAMS = createfits \ createfits_SOURCES = createfits.cpp createfits_LDFLAGS = @LDFLAGS@ createfits_CPPFLAGS = @CPPFLAGS@ -createfits_LDADD = $(top_srcdir)/src/libgamma.la +createfits_LDADD = $(top_builddir)/src/libgamma.la # Program definition createskymap_SOURCES = createskymap.cpp createskymap_LDFLAGS = @LDFLAGS@ createskymap_CPPFLAGS = @CPPFLAGS@ -createskymap_LDADD = $(top_srcdir)/src/libgamma.la +createskymap_LDADD = $(top_builddir)/src/libgamma.la # Program definition createxml_SOURCES = createxml.cpp createxml_LDFLAGS = @LDFLAGS@ createxml_CPPFLAGS = @CPPFLAGS@ -createxml_LDADD = $(top_srcdir)/src/libgamma.la +createxml_LDADD = $(top_builddir)/src/libgamma.la # Program definition interpolate_SOURCES = interpolate.cpp interpolate_LDFLAGS = @LDFLAGS@ interpolate_CPPFLAGS = @CPPFLAGS@ -interpolate_LDADD = $(top_srcdir)/src/libgamma.la +interpolate_LDADD = $(top_builddir)/src/libgamma.la # Program definition numerics_SOURCES = numerics.cpp numerics_LDFLAGS = @LDFLAGS@ numerics_CPPFLAGS = @CPPFLAGS@ -numerics_LDADD = $(top_srcdir)/src/libgamma.la +numerics_LDADD = $(top_builddir)/src/libgamma.la # Program definition optimize_SOURCES = optimize.cpp optimize_LDFLAGS = @LDFLAGS@ optimize_CPPFLAGS = @CPPFLAGS@ -optimize_LDADD = $(top_srcdir)/src/libgamma.la +optimize_LDADD = $(top_builddir)/src/libgamma.la # Program definition readmodel_SOURCES = readmodel.cpp readmodel_LDFLAGS = @LDFLAGS@ readmodel_CPPFLAGS = @CPPFLAGS@ -readmodel_LDADD = $(top_srcdir)/src/libgamma.la +readmodel_LDADD = $(top_builddir)/src/libgamma.la diff --git a/include/Makefile.am b/include/Makefile.am index a711aa9..f34f05d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,3 +1,24 @@ +############################################################################# +# Makefile.am for include module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# + # Define package included headers (to be installed) pkginclude_HEADERS = GammaLib.hpp \ GTypemaps.hpp \ diff --git a/inst/Makefile.am b/inst/Makefile.am index 8dca2c4..23ddb88 100644 --- a/inst/Makefile.am +++ b/inst/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for inst module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Detect configuration if WITH_INST_CTA diff --git a/inst/com/Makefile.am b/inst/com/Makefile.am index 447cf85..6117a40 100644 --- a/inst/com/Makefile.am +++ b/inst/com/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for com module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Darwin support MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ diff --git a/inst/com/test/test_COM.cpp b/inst/com/test/test_COM.cpp index 1bb0378..3a9b441 100644 --- a/inst/com/test/test_COM.cpp +++ b/inst/com/test/test_COM.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_COM.cpp - test COM classes * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Juergen Knoedlseder * + * copyright (C) 2012-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -30,6 +30,7 @@ #endif #include #include +#include // getenv #include "GTools.hpp" #include "test_COM.hpp" @@ -38,8 +39,9 @@ /* __ Globals ____________________________________________________________ */ /* __ Constants __________________________________________________________ */ -const std::string datadir = PACKAGE_SOURCE"/inst/com/test/data"; -const std::string com_caldb = PACKAGE_SOURCE"/inst/com/caldb"; +const std::string srcdir = std::getenv("TESTS_SRCDIR"); +const std::string datadir = srcdir + "/inst/com/test/data"; +const std::string com_caldb = srcdir + "/inst/com/caldb"; const std::string com_iaq = "ENERG(1.0-3.0)MeV"; // 1-3 MeV const std::string com_dre = datadir+"/m50439_dre.fits"; // 1-3 MeV const std::string com_drb = datadir+"/m34997_drg.fits"; diff --git a/inst/cta/Makefile.am b/inst/cta/Makefile.am index bae5962..83c19bb 100644 --- a/inst/cta/Makefile.am +++ b/inst/cta/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for cta module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Darwin support MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ diff --git a/inst/cta/test/data/irf_1dc.xml b/inst/cta/test/data/irf_1dc.xml index 74769ec..a6b4836 100644 --- a/inst/cta/test/data/irf_1dc.xml +++ b/inst/cta/test/data/irf_1dc.xml @@ -1,9 +1,9 @@ - - - + + + diff --git a/inst/cta/test/data/irf_binned.xml b/inst/cta/test/data/irf_binned.xml index 1cb9ef4..bf65240 100644 --- a/inst/cta/test/data/irf_binned.xml +++ b/inst/cta/test/data/irf_binned.xml @@ -1,9 +1,9 @@ - - - - + + + + diff --git a/inst/cta/test/data/irf_unbinned.xml b/inst/cta/test/data/irf_unbinned.xml index 179c4cc..0d79dfc 100644 --- a/inst/cta/test/data/irf_unbinned.xml +++ b/inst/cta/test/data/irf_unbinned.xml @@ -1,9 +1,9 @@ - - - - + + + + diff --git a/inst/cta/test/test_CTA.cpp b/inst/cta/test/test_CTA.cpp index 4106daa..73495a7 100644 --- a/inst/cta/test/test_CTA.cpp +++ b/inst/cta/test/test_CTA.cpp @@ -29,9 +29,10 @@ #include #endif #include +#include #include #include -#include +#include // getenv #include "GCTALib.hpp" #include "GTools.hpp" #include "GNodeArray.hpp" @@ -46,8 +47,10 @@ /* __ Globals ____________________________________________________________ */ /* __ Constants __________________________________________________________ */ -const std::string datadir = PACKAGE_SOURCE"/inst/cta/test/data"; -const std::string cta_caldb = PACKAGE_SOURCE"/inst/cta/caldb"; +const std::string srcdir = std::getenv("TESTS_SRCDIR"); +const std::string datadir = srcdir+"/inst/cta/test/data"; +const std::string caldbdir = srcdir+"/inst/cta/test/caldb"; +const std::string cta_caldb = srcdir+"/inst/cta/caldb"; const std::string cta_irf = "cta_dummy_irf"; const std::string cta_events = datadir+"/crab_events.fits"; const std::string cta_events_gti = datadir+"/crab_events_gti.fits[EVENTS2]"; @@ -59,12 +62,12 @@ const std::string cta_rsp_xml = datadir+"/rsp_models.xml"; const std::string cta_cube_bgd_xml = datadir+"/cta_model_cube_bgd.xml"; const std::string cta_irf_bgd_xml = datadir+"/cta_model_irf_bgd.xml"; const std::string cta_aeff_bgd_xml = datadir+"/cta_model_aeff_bgd.xml"; -const std::string cta_caldb_king = PACKAGE_SOURCE"/inst/cta/caldb/data/cta/e/bcf/IFAE20120510_50h_King"; +const std::string cta_caldb_king = cta_caldb+"/data/cta/e/bcf/IFAE20120510_50h_King"; const std::string cta_irf_king = "irf_file.fits"; -const std::string cta_psf_table = PACKAGE_SOURCE"/inst/cta/test/caldb/psf_table.fits[PSF_2D_TABLE]"; -const std::string cta_edisp_perf = PACKAGE_SOURCE"/inst/cta/test/caldb/cta_dummy_irf.dat"; -const std::string cta_edisp_rmf = PACKAGE_SOURCE"/inst/cta/test/caldb/dc1/rmf.fits"; -const std::string cta_edisp_2D = PACKAGE_SOURCE"/inst/cta/test/caldb/edisp_matrix.fits"; +const std::string cta_psf_table = caldbdir+"/psf_table.fits[PSF_2D_TABLE]"; +const std::string cta_edisp_perf = caldbdir+"/cta_dummy_irf.dat"; +const std::string cta_edisp_rmf = caldbdir+"/dc1/rmf.fits"; +const std::string cta_edisp_2D = caldbdir+"/edisp_matrix.fits"; const std::string cta_modbck_fit = datadir+"/bg_test.fits"; const std::string cta_point_table = datadir+"/crab_pointing.fits"; diff --git a/inst/cta/test/test_CTA.py b/inst/cta/test/test_CTA.py index 45a8891..b8c00aa 100755 --- a/inst/cta/test/test_CTA.py +++ b/inst/cta/test/test_CTA.py @@ -17,8 +17,8 @@ # along with this program. If not, see . # # ========================================================================== -import gammalib import os +import gammalib import math @@ -37,19 +37,25 @@ class Test(gammalib.GPythonTestSuite): # Call base class constructor gammalib.GPythonTestSuite.__init__(self) - # Initialise CALDB - self.caldb = '../inst/cta/test/caldb' + # Set directory base path + self.testdir(os.path.dirname(os.path.abspath(__file__))) # Return return - # Define CALDB - def caldb_path(self, path): + # Set test directory base path + def testdir(self, path): """ - Set path to calibration database for test. + Set test directory base path + + Parameters + ---------- + path : str + Test directory base path """ - # Set path - self.caldb = path + # Set test data paths + self._caldb = path + '/caldb' + self._data = path + '/data' # Return return @@ -78,7 +84,7 @@ class Test(gammalib.GPythonTestSuite): Test GCTAAeff classes. """ # Test GCTAAeff2D file constructor - filename = self.caldb + '/prod1_gauss.fits' + filename = self._caldb + '/prod1_gauss.fits' aeff = gammalib.GCTAAeff2D(filename) # Test Aeff values @@ -106,7 +112,7 @@ class Test(gammalib.GPythonTestSuite): ' above maximum offset angle') # Test GCTAAeffPerfTable file constructor - filename = self.caldb + '/cta_dummy_irf.dat' + filename = self._caldb + '/cta_dummy_irf.dat' aeff = gammalib.GCTAAeffPerfTable(filename) # Test Aeff values @@ -116,7 +122,7 @@ class Test(gammalib.GPythonTestSuite): self.test_value(aeff(1.0, 0.01745), 15838314971.2, 0.1) # Test GCTAAeffArf file constructor - filename = self.caldb + '/dc1/arf.fits' + filename = self._caldb + '/dc1/arf.fits' aeff = gammalib.GCTAAeffArf(filename) # Test Aeff values @@ -134,7 +140,7 @@ class Test(gammalib.GPythonTestSuite): Test GCTAPsf classes. """ # Test GCTAPsf2D file constructor - filename = self.caldb + '/prod1_gauss.fits' + filename = self._caldb + '/prod1_gauss.fits' psf = gammalib.GCTAPsf2D(filename) # Test PSF values @@ -146,7 +152,7 @@ class Test(gammalib.GPythonTestSuite): self.test_value(psf(0.001, 1.0, 0.01745), 111075.0692681, 1.0e-6) # Test GCTAPsfKing file constructor - filename = self.caldb + '/prod1_king.fits' + filename = self._caldb + '/prod1_king.fits' psf = gammalib.GCTAPsfKing(filename) # Test PSF values @@ -158,7 +164,7 @@ class Test(gammalib.GPythonTestSuite): self.test_value(psf(0.001, 1.0, 0.01745), 80272.5530008, 1.0e-6) # Test GCTAPsfPerfTable file constructor - filename = self.caldb + '/cta_dummy_irf.dat' + filename = self._caldb + '/cta_dummy_irf.dat' psf = gammalib.GCTAPsfPerfTable(filename) # Test PSF values @@ -170,7 +176,7 @@ class Test(gammalib.GPythonTestSuite): self.test_value(psf(0.001, 1.0, 0.01745), 22272.4258111, 1.0e-6) # Test GCTAPsfVector file constructor - filename = self.caldb + '/dc1/psf_magic.fits' + filename = self._caldb + '/dc1/psf_magic.fits' psf = gammalib.GCTAPsfVector(filename) # Print @@ -190,7 +196,7 @@ class Test(gammalib.GPythonTestSuite): Test GCTAEdisp classes. """ # Test GCTAEdispRmf file constructor - filename = self.caldb + '/dc1/rmf.fits' + filename = self._caldb + '/dc1/rmf.fits' edisp = gammalib.GCTAEdispRmf(filename) # Test energy dispersion values @@ -198,7 +204,7 @@ class Test(gammalib.GPythonTestSuite): self.test_value(edisp(math.log10(1),math.log10(30)), 0.0, 1.0e-9) # Test GCTAEdispPerfTable file constructor - filename = self.caldb + '/cta_dummy_irf.dat' + filename = self._caldb + '/cta_dummy_irf.dat' edisp = gammalib.GCTAEdispPerfTable(filename) # Test energy dispersion values @@ -210,7 +216,7 @@ class Test(gammalib.GPythonTestSuite): self.test_value(edisp(1.001, 1.0, 0.0), 18.0463571212, 1.0e-6) # Test GCTAResponseIrf file constructor - db = gammalib.GCaldb(self.caldb) + db = gammalib.GCaldb(self._caldb) irf = 'cta_dummy_irf' rsp = gammalib.GCTAResponseIrf(irf, db) @@ -237,7 +243,7 @@ class Test(gammalib.GPythonTestSuite): Test response classes """ # Load 1DC CTA observation (ARF, PSF, RMF) - filename = self.caldb + '/../data/irf_1dc.xml' + filename = self._data + '/irf_1dc.xml' obs = gammalib.GObservations(filename) # Return @@ -266,7 +272,7 @@ class Test(gammalib.GPythonTestSuite): gammalib.GEnergy(10.0, 'TeV')) # Create On/Off observations from CTA observations - filename = self.caldb + '/../data/irf_unbinned.xml' + filename = self._data + '/irf_unbinned.xml' inobs = gammalib.GObservations(filename) outobs = gammalib.GObservations() for run in inobs: @@ -274,7 +280,7 @@ class Test(gammalib.GPythonTestSuite): outobs.append(onoff) # Load model container and attach it to the observations - models = gammalib.GModels(self.caldb + '/../data/onoff_model.xml') + models = gammalib.GModels(self._data + '/onoff_model.xml') outobs.models(models) # Perform maximum likelihood fit diff --git a/inst/lat/Makefile.am b/inst/lat/Makefile.am index 0656664..abb021d 100644 --- a/inst/lat/Makefile.am +++ b/inst/lat/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for lat module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Darwin support MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ diff --git a/inst/lat/test/test_LAT.cpp b/inst/lat/test/test_LAT.cpp index 3140a07..e910913 100644 --- a/inst/lat/test/test_LAT.cpp +++ b/inst/lat/test/test_LAT.cpp @@ -29,8 +29,9 @@ #include #endif #include -#include #include +#include +#include // getenv #include "GLATLib.hpp" #include "GTools.hpp" #include "test_LAT.hpp" @@ -40,11 +41,12 @@ /* __ Globals ____________________________________________________________ */ /* __ Constants __________________________________________________________ */ -const std::string datadir = PACKAGE_SOURCE"/inst/lat/test/data"; -const std::string lat_caldb = PACKAGE_SOURCE"/inst/lat/caldb"; -const std::string dirPass6 = PACKAGE_SOURCE"/inst/lat/test/data/p6v3"; -const std::string dirPass7 = PACKAGE_SOURCE"/inst/lat/test/data/p7v6"; -const std::string dirPass8 = PACKAGE_SOURCE"/inst/lat/test/data/p8v2"; +const std::string srcdir = std::getenv("TESTS_SRCDIR"); +const std::string datadir = srcdir + "/inst/lat/test/data"; +const std::string lat_caldb = srcdir + "/inst/lat/caldb"; +const std::string dirPass6 = srcdir + "/inst/lat/test/data/p6v3"; +const std::string dirPass7 = srcdir + "/inst/lat/test/data/p7v6"; +const std::string dirPass8 = srcdir + "/inst/lat/test/data/p8v2"; /***********************************************************************//** diff --git a/inst/mwl/Makefile.am b/inst/mwl/Makefile.am index 3ed220d..0c4886e 100644 --- a/inst/mwl/Makefile.am +++ b/inst/mwl/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for com module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Darwin support MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ diff --git a/inst/mwl/test/test_MWL.cpp b/inst/mwl/test/test_MWL.cpp index 437f1b2..6ce93f4 100644 --- a/inst/mwl/test/test_MWL.cpp +++ b/inst/mwl/test/test_MWL.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_MWL.cpp - Test multi-wavelength classes * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2015 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -30,6 +30,7 @@ #endif #include #include +#include // getenv #include "GMWLLib.hpp" #include "test_MWL.hpp" @@ -38,12 +39,13 @@ /* __ Globals ____________________________________________________________ */ /* __ Constants __________________________________________________________ */ -const std::string datadir = PACKAGE_SOURCE"/inst/mwl/test/data"; -const std::string lat_crab_model = datadir+"/crab.xml"; -const std::string lat_crab_fits = datadir+"/crab.fits"; -const std::string crab_model = datadir+"/crab_mwl.xml"; -const std::string crab_fits = datadir+"/crab_mwl.fits"; -const std::string mwl_xml = datadir+"/obs_mwl.xml"; +const std::string srcdir = std::getenv("TESTS_SRCDIR"); +const std::string datadir = srcdir + "/inst/mwl/test/data"; +const std::string lat_crab_model = datadir + "/crab.xml"; +const std::string lat_crab_fits = datadir + "/crab.fits"; +const std::string crab_model = datadir + "/crab_mwl.xml"; +const std::string crab_fits = datadir + "/crab_mwl.fits"; +const std::string mwl_xml = datadir + "/obs_mwl.xml"; /***********************************************************************//** @@ -55,8 +57,10 @@ void TestGMWL::set(void) name("GMWL"); // Append tests to test suite - append(static_cast(&TestGMWL::test_obs), "Test observation handling"); - append(static_cast(&TestGMWL::test_optimizer), "Test optimizer"); + append(static_cast(&TestGMWL::test_obs), + "Test observation handling"); + append(static_cast(&TestGMWL::test_optimizer), + "Test optimizer"); // Return return; diff --git a/pyext/Makefile.am b/pyext/Makefile.am index f98b1c4..67a959d 100755 --- a/pyext/Makefile.am +++ b/pyext/Makefile.am @@ -150,7 +150,7 @@ if IS_ELCAPITAN echo "Post process module "$$f; \ install_name_tool -change $(libdir)/libgamma.2.dylib @rpath/libgamma.2.dylib $$f; \ install_name_tool -add_rpath $(libdir) $$f; \ - install_name_tool -add_rpath $(abs_top_srcdir)/src/.libs $$f; \ + install_name_tool -add_rpath $(abs_top_builddir)/src/.libs $$f; \ done endif @@ -176,14 +176,14 @@ swig: $(BUILT_SOURCES) # General rule for core modules %_wrap.cpp %.py: %.i - if $(SWIGCOMPILE) -MMD -MF "$*.Tpi" -o $@ -outdir gammalib $<; \ + if $(SWIGCOMPILE) -MMD -MF "$*.Tpi" -I$(top_srcdir)/pyext -o $@ -outdir gammalib $<; \ then mv -f "$*.Tpi" "$*.Pi"; else rm -f "$*.Tpi"; exit 1; fi # Rule for MWL module if WITH_INST_MWL gammalib/mwl.py: gammalib/mwl_wrap.cpp gammalib/mwl_wrap.cpp: $(top_srcdir)/inst/mwl/pyext/mwl.i - if $(SWIGCOMPILE) -MMD -MF "gammalib/mwl.Tpi" -o gammalib/mwl_wrap.cpp -outdir gammalib $<; \ + if $(SWIGCOMPILE) -MMD -MF "gammalib/mwl.Tpi" -I$(top_srcdir)/pyext -o gammalib/mwl_wrap.cpp -outdir gammalib $<; \ then mv -f "gammalib/mwl.Tpi" "gammalib/mwl.Pi"; else rm -f "gammalib/mwl.Tpi"; exit 1; fi endif @@ -191,7 +191,7 @@ endif if WITH_INST_CTA gammalib/cta.py: gammalib/cta_wrap.cpp gammalib/cta_wrap.cpp: $(top_srcdir)/inst/cta/pyext/cta.i - if $(SWIGCOMPILE) -MMD -MF "gammalib/cta.Tpi" -o gammalib/cta_wrap.cpp -outdir gammalib $<; \ + if $(SWIGCOMPILE) -MMD -MF "gammalib/cta.Tpi" -I$(top_srcdir)/pyext -o gammalib/cta_wrap.cpp -outdir gammalib $<; \ then mv -f "gammalib/cta.Tpi" "gammalib/cta.Pi"; else rm -f "gammalib/cta.Tpi"; exit 1; fi endif @@ -199,7 +199,7 @@ endif if WITH_INST_LAT gammalib/lat.py: gammalib/lat_wrap.cpp gammalib/lat_wrap.cpp: $(top_srcdir)/inst/lat/pyext/lat.i - if $(SWIGCOMPILE) -MMD -MF "gammalib/lat.Tpi" -o gammalib/lat_wrap.cpp -outdir gammalib $<; \ + if $(SWIGCOMPILE) -MMD -MF "gammalib/lat.Tpi" -I$(top_srcdir)/pyext -o gammalib/lat_wrap.cpp -outdir gammalib $<; \ then mv -f "gammalib/lat.Tpi" "gammalib/lat.Pi"; else rm -f "gammalib/lat.Tpi"; exit 1; fi endif @@ -207,7 +207,7 @@ endif if WITH_INST_COM gammalib/com.py: gammalib/com_wrap.cpp gammalib/com_wrap.cpp: $(top_srcdir)/inst/com/pyext/com.i - if $(SWIGCOMPILE) -MMD -MF "gammalib/com.Tpi" -o gammalib/com_wrap.cpp -outdir gammalib $<; \ + if $(SWIGCOMPILE) -MMD -MF "gammalib/com.Tpi" -I$(top_srcdir)/pyext -o gammalib/com_wrap.cpp -outdir gammalib $<; \ then mv -f "gammalib/com.Tpi" "gammalib/com.Pi"; else rm -f "gammalib/com.Tpi"; exit 1; fi endif diff --git a/src/Makefile.am b/src/Makefile.am index 8dd9157..bf3bcd5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,8 +1,23 @@ -## Process this file with automake to produce Makefile.in - -# we use srcdir/src for "private" includes -# we use srcdir/include for the static global include files -# we use builddir/src for the generated include files to get found +############################################################################# +# Makefile.am for source module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# INCLUDES = -I$(top_srcdir)/include \ -I$(top_builddir)/src \ diff --git a/src/app/Makefile.am b/src/app/Makefile.am index 908c64e..2fa175f 100644 --- a/src/app/Makefile.am +++ b/src/app/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for app module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/base/Makefile.am b/src/base/Makefile.am index 2e1793a..e2d0788 100644 --- a/src/base/Makefile.am +++ b/src/base/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for base module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/fits/Makefile.am b/src/fits/Makefile.am index a51e965..5dd59eb 100644 --- a/src/fits/Makefile.am +++ b/src/fits/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for fits module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/linalg/Makefile.am b/src/linalg/Makefile.am index b7ebfd7..d65d254 100644 --- a/src/linalg/Makefile.am +++ b/src/linalg/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for linalg module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/model/Makefile.am b/src/model/Makefile.am index 8e9a622..211fc2b 100644 --- a/src/model/Makefile.am +++ b/src/model/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for model module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/numerics/Makefile.am b/src/numerics/Makefile.am index e69f83d..4ee18f2 100644 --- a/src/numerics/Makefile.am +++ b/src/numerics/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for numerics module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/obs/Makefile.am b/src/obs/Makefile.am index 7ff1686..dde7c05 100644 --- a/src/obs/Makefile.am +++ b/src/obs/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for obs module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/opt/Makefile.am b/src/opt/Makefile.am index 89854dd..507f058 100644 --- a/src/opt/Makefile.am +++ b/src/opt/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for opt module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/sky/Makefile.am b/src/sky/Makefile.am index 2a87e40..c5eec97 100644 --- a/src/sky/Makefile.am +++ b/src/sky/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for sky module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/support/Makefile.am b/src/support/Makefile.am index d7706a2..00ce932 100644 --- a/src/support/Makefile.am +++ b/src/support/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for support module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/test/Makefile.am b/src/test/Makefile.am index daf9414..671a58b 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for test module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/vo/Makefile.am b/src/vo/Makefile.am index 7fc1261..1665867 100644 --- a/src/vo/Makefile.am +++ b/src/vo/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for vo module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/xml/Makefile.am b/src/xml/Makefile.am index ebc08aa..f99d26e 100644 --- a/src/xml/Makefile.am +++ b/src/xml/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for xml module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/src/xspec/Makefile.am b/src/xspec/Makefile.am index af8b836..5d7f9b4 100644 --- a/src/xspec/Makefile.am +++ b/src/xspec/Makefile.am @@ -1,4 +1,23 @@ -## Process this file with automake to produce Makefile.in +############################################################################# +# Makefile.am for xspec module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Set include directories INCLUDES = -I$(top_srcdir)/include \ diff --git a/test/Makefile.am b/test/Makefile.am index 0407a1f..507c16b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,8 +1,23 @@ -## Process this file with automake to produce Makefile.in - -# we use srcdir/src for "private" includes -# we use srcdir/include for the static global include files -# we use builddir/src for the generated include files to get found +############################################################################# +# Makefile.am for unit test module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# # Optional instrument specific tests if WITH_INST_MWL @@ -12,7 +27,7 @@ if WITH_INST_MWL test_MWL_SOURCES = $(top_srcdir)/inst/mwl/test/test_MWL.cpp test_MWL_LDFLAGS = @LDFLAGS@ test_MWL_CPPFLAGS = @CPPFLAGS@ - test_MWL_LDADD = $(top_srcdir)/src/libgamma.la + test_MWL_LDADD = $(top_builddir)/src/libgamma.la endif if WITH_INST_CTA INST_CTA = test_CTA @@ -21,7 +36,7 @@ if WITH_INST_CTA test_CTA_SOURCES = $(top_srcdir)/inst/cta/test/test_CTA.cpp test_CTA_LDFLAGS = @LDFLAGS@ test_CTA_CPPFLAGS = @CPPFLAGS@ - test_CTA_LDADD = $(top_srcdir)/src/libgamma.la + test_CTA_LDADD = $(top_builddir)/src/libgamma.la endif if WITH_INST_LAT INST_LAT = test_LAT @@ -30,7 +45,7 @@ if WITH_INST_LAT test_LAT_SOURCES = $(top_srcdir)/inst/lat/test/test_LAT.cpp test_LAT_LDFLAGS = @LDFLAGS@ test_LAT_CPPFLAGS = @CPPFLAGS@ - test_LAT_LDADD = $(top_srcdir)/src/libgamma.la + test_LAT_LDADD = $(top_builddir)/src/libgamma.la endif if WITH_INST_COM INST_COM = test_COM @@ -39,7 +54,7 @@ if WITH_INST_COM test_COM_SOURCES = $(top_srcdir)/inst/com/test/test_COM.cpp test_COM_LDFLAGS = @LDFLAGS@ test_COM_CPPFLAGS = @CPPFLAGS@ - test_COM_LDADD = $(top_srcdir)/src/libgamma.la + test_COM_LDADD = $(top_builddir)/src/libgamma.la endif # Optional python bindings @@ -82,7 +97,8 @@ check_PROGRAMS = test_GSupport \ # Set test environment (needed for linking with cfitsio and readline) TESTS_ENVIRONMENT = @RUNSHARED@=$(top_builddir)/src/.libs$(TEST_ENV_DIR):$(@RUNSHARED@) \ $(TEST_PYTHON_ENV) \ - PACKAGE_SOURCE=$(PACKAGE_SOURCE) + TESTS_SRCDIR=$(abs_top_srcdir) \ + TESTS_BUILDDIR=$(abs_top_builddir) # Tests (these are the tests to be executed) TESTS = test_GSupport \ @@ -111,83 +127,82 @@ EXTRA_DIST = data reports testinst \ test_GSupport_SOURCES = test_GSupport.cpp test_GSupport.hpp test_GSupport_LDFLAGS = @LDFLAGS@ test_GSupport_CPPFLAGS = @CPPFLAGS@ -test_GSupport_LDADD = $(top_srcdir)/src/libgamma.la +test_GSupport_LDADD = $(top_builddir)/src/libgamma.la # test_GVector_SOURCES = test_GVector.cpp test_GVector.hpp test_GVector_LDFLAGS = @LDFLAGS@ test_GVector_CPPFLAGS = @CPPFLAGS@ -test_GVector_LDADD = $(top_srcdir)/src/libgamma.la +test_GVector_LDADD = $(top_builddir)/src/libgamma.la # test_GMatrix_SOURCES = test_GMatrix.cpp test_GMatrix.hpp test_GMatrix_LDFLAGS = @LDFLAGS@ test_GMatrix_CPPFLAGS = @CPPFLAGS@ -test_GMatrix_LDADD = $(top_srcdir)/src/libgamma.la +test_GMatrix_LDADD = $(top_builddir)/src/libgamma.la # test_GMatrixSparse_SOURCES = test_GMatrixSparse.cpp test_GMatrixSparse.hpp test_GMatrixSparse_LDFLAGS = @LDFLAGS@ test_GMatrixSparse_CPPFLAGS = @CPPFLAGS@ -test_GMatrixSparse_LDADD = $(top_srcdir)/src/libgamma.la +test_GMatrixSparse_LDADD = $(top_builddir)/src/libgamma.la # test_GMatrixSymmetric_SOURCES = test_GMatrixSymmetric.cpp test_GMatrixSymmetric.hpp test_GMatrixSymmetric_LDFLAGS = @LDFLAGS@ test_GMatrixSymmetric_CPPFLAGS = @CPPFLAGS@ -test_GMatrixSymmetric_LDADD = $(top_srcdir)/src/libgamma.la +test_GMatrixSymmetric_LDADD = $(top_builddir)/src/libgamma.la # test_GNumerics_SOURCES = test_GNumerics.cpp test_GNumerics.hpp test_GNumerics_LDFLAGS = @LDFLAGS@ test_GNumerics_CPPFLAGS = @CPPFLAGS@ -test_GNumerics_LDADD = $(top_srcdir)/src/libgamma.la +test_GNumerics_LDADD = $(top_builddir)/src/libgamma.la # test_GFits_SOURCES = test_GFits.cpp test_GFits.hpp test_GFits_LDFLAGS = @LDFLAGS@ test_GFits_CPPFLAGS = @CPPFLAGS@ -test_GFits_LDADD = $(top_srcdir)/src/libgamma.la +test_GFits_LDADD = $(top_builddir)/src/libgamma.la # test_GXml_SOURCES = test_GXml.cpp test_GXml.hpp test_GXml_LDFLAGS = @LDFLAGS@ test_GXml_CPPFLAGS = @CPPFLAGS@ -test_GXml_LDADD = $(top_srcdir)/src/libgamma.la +test_GXml_LDADD = $(top_builddir)/src/libgamma.la # test_GVO_SOURCES = test_GVO.cpp test_GVO.hpp test_GVO_LDFLAGS = @LDFLAGS@ test_GVO_CPPFLAGS = @CPPFLAGS@ -test_GVO_LDADD = $(top_srcdir)/src/libgamma.la +test_GVO_LDADD = $(top_builddir)/src/libgamma.la # test_GXspec_SOURCES = test_GXspec.cpp test_GXspec.hpp test_GXspec_LDFLAGS = @LDFLAGS@ test_GXspec_CPPFLAGS = @CPPFLAGS@ -test_GXspec_LDADD = $(top_srcdir)/src/libgamma.la +test_GXspec_LDADD = $(top_builddir)/src/libgamma.la # test_GApplication_SOURCES = test_GApplication.cpp test_GApplication.hpp test_GApplication_LDFLAGS = @LDFLAGS@ test_GApplication_CPPFLAGS = @CPPFLAGS@ -test_GApplication_LDADD = $(top_srcdir)/src/libgamma.la +test_GApplication_LDADD = $(top_builddir)/src/libgamma.la # test_GModel_SOURCES = test_GModel.cpp test_GModel.hpp test_GModel_LDFLAGS = @LDFLAGS@ test_GModel_CPPFLAGS = @CPPFLAGS@ -test_GModel_LDADD = $(top_srcdir)/src/libgamma.la +test_GModel_LDADD = $(top_builddir)/src/libgamma.la # test_GSky_SOURCES = test_GSky.cpp test_GSky.hpp test_GSky_LDFLAGS = @LDFLAGS@ test_GSky_CPPFLAGS = @CPPFLAGS@ -test_GSky_LDADD = $(top_srcdir)/src/libgamma.la +test_GSky_LDADD = $(top_builddir)/src/libgamma.la # test_GOptimizer_SOURCES = test_GOptimizer.cpp test_GOptimizer.hpp test_GOptimizer_LDFLAGS = @LDFLAGS@ test_GOptimizer_CPPFLAGS = @CPPFLAGS@ -test_GOptimizer_LDADD = $(top_srcdir)/src/libgamma.la +test_GOptimizer_LDADD = $(top_builddir)/src/libgamma.la # test_GObservation_SOURCES = test_GObservation.cpp test_GObservation.hpp test_GObservation_LDFLAGS = @LDFLAGS@ test_GObservation_CPPFLAGS = @CPPFLAGS@ -test_GObservation_LDADD = $(top_srcdir)/src/libgamma.la +test_GObservation_LDADD = $(top_builddir)/src/libgamma.la # Add Valgrind rule # valgrind: - @export PACKAGE_SOURCE=$(PACKAGE_SOURCE) ; \ - if type valgrind >/dev/null 2>&1; then \ + @if type valgrind >/dev/null 2>&1; then \ cd .. ; \ ln -s test/data data ; \ mkdir reports ; \ diff --git a/test/reports/Makefile.am b/test/reports/Makefile.am new file mode 100644 index 0000000..4588729 --- /dev/null +++ b/test/reports/Makefile.am @@ -0,0 +1,20 @@ +############################################################################# +# Makefile.am for unit test reports module # +# ------------------------------------------------------------------------- # +# Copyright (C) 2016 Juergen Knoedlseder # +# ------------------------------------------------------------------------- # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################# diff --git a/test/test_GApplication.cpp b/test/test_GApplication.cpp index e406cef..9ca8415 100644 --- a/test/test_GApplication.cpp +++ b/test/test_GApplication.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_GApplication.cpp - test GApplication classes * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Juergen Knoedlseder * + * copyright (C) 2012-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -42,10 +42,14 @@ void TestGApplication::set(void) name("GApplication"); // Append tests - append(static_cast(&TestGApplication::test_constructor), "Test GLog constructor"); - append(static_cast(&TestGApplication::test_stream_logger), "Test stream logger"); - append(static_cast(&TestGApplication::test_C_logger), "Test C logger"); - append(static_cast(&TestGApplication::test_GApplicationPar), "Test GApplicationPar class"); + append(static_cast(&TestGApplication::test_constructor), + "Test GLog constructor"); + append(static_cast(&TestGApplication::test_stream_logger), + "Test stream logger"); + append(static_cast(&TestGApplication::test_C_logger), + "Test C logger"); + append(static_cast(&TestGApplication::test_GApplicationPar), + "Test GApplicationPar class"); // Return return; diff --git a/test/test_GFits.py b/test/test_GFits.py index 91cc81a..7b6be72 100755 --- a/test/test_GFits.py +++ b/test/test_GFits.py @@ -17,6 +17,7 @@ # along with this program. If not, see . # # ========================================================================== +import os import math import gammalib @@ -58,8 +59,11 @@ class Test(gammalib.GPythonTestSuite): """ Test GFile class interface. """ + # Get test data directory + datadir = os.environ['TESTS_SRCDIR'] + '/test/data/' + # Set test file names - file = gammalib.GFilename("data/file.fits") + file = gammalib.GFilename(datadir+'file.fits') # Test loading of FITS file self.test_try("Test GFits file load constructor") diff --git a/test/test_GModel.cpp b/test/test_GModel.cpp index b5675f2..170b3ca 100644 --- a/test/test_GModel.cpp +++ b/test/test_GModel.cpp @@ -28,10 +28,11 @@ #ifdef HAVE_CONFIG_H #include #endif +#include #include #include #include -#include +#include // getenv #include "test_GModel.hpp" #include "GTools.hpp" @@ -44,32 +45,39 @@ void TestGModel::set(void) // Set name name("GModel"); + // Set test data directory + std::string datadir = std::string(std::getenv("TESTS_SRCDIR")) + + "/test/data/"; + // Set attributes - m_map_file = "data/cena_lobes_parkes.fits"; - m_cube_file = "data/test_cube.fits"; - m_xml_file = "data/crab.xml"; - m_xml_model_point_const = "data/model_point_const.xml"; - m_xml_model_point_gauss = "data/model_point_gauss.xml"; - m_xml_model_point_plaw = "data/model_point_plaw.xml"; - m_xml_model_point_plaw2 = "data/model_point_plaw2.xml"; - m_xml_model_point_eplaw = "data/model_point_eplaw.xml"; - m_xml_model_point_bplaw = "data/model_point_bplaw.xml"; - m_xml_model_point_supeplaw = "data/model_point_supeplaw.xml"; - m_xml_model_point_logparabola = "data/model_point_logparabola.xml"; - m_xml_model_point_nodes = "data/model_point_nodes.xml"; - m_xml_model_point_filefct = "data/model_point_filefct.xml"; - m_xml_model_diffuse_const = "data/model_diffuse_const.xml"; - m_xml_model_diffuse_cube = "data/model_diffuse_cube.xml"; - m_xml_model_diffuse_map = "data/model_diffuse_map.xml"; - m_xml_model_radial_disk = "data/model_radial_disk.xml"; - m_xml_model_radial_gauss = "data/model_radial_gauss.xml"; - m_xml_model_radial_shell = "data/model_radial_shell.xml"; - m_xml_model_elliptical_disk = "data/model_elliptical_disk.xml"; - m_xml_model_elliptical_gauss = "data/model_elliptical_gauss.xml"; + m_map_file = datadir + "cena_lobes_parkes.fits"; + m_cube_file = datadir + "test_cube.fits"; + m_filefct = datadir + "filefunction.txt"; + m_xml_file = datadir + "crab.xml"; + m_xml_model_point_const = datadir + "model_point_const.xml"; + m_xml_model_point_gauss = datadir + "model_point_gauss.xml"; + m_xml_model_point_plaw = datadir + "model_point_plaw.xml"; + m_xml_model_point_plaw2 = datadir + "model_point_plaw2.xml"; + m_xml_model_point_eplaw = datadir + "model_point_eplaw.xml"; + m_xml_model_point_bplaw = datadir + "model_point_bplaw.xml"; + m_xml_model_point_supeplaw = datadir + "model_point_supeplaw.xml"; + m_xml_model_point_logparabola = datadir + "model_point_logparabola.xml"; + m_xml_model_point_nodes = datadir + "model_point_nodes.xml"; + m_xml_model_point_filefct = datadir + "model_point_filefct.xml"; + m_xml_model_diffuse_const = datadir + "model_diffuse_const.xml"; + m_xml_model_diffuse_cube = datadir + "model_diffuse_cube.xml"; + m_xml_model_diffuse_map = datadir + "model_diffuse_map.xml"; + m_xml_model_radial_disk = datadir + "model_radial_disk.xml"; + m_xml_model_radial_gauss = datadir + "model_radial_gauss.xml"; + m_xml_model_radial_shell = datadir + "model_radial_shell.xml"; + m_xml_model_elliptical_disk = datadir + "model_elliptical_disk.xml"; + m_xml_model_elliptical_gauss = datadir + "model_elliptical_gauss.xml"; // Append tests - append(static_cast(&TestGModel::test_model_par), "Test GModelPar"); - append(static_cast(&TestGModel::test_sky_model), "Test GModelSky"); + append(static_cast(&TestGModel::test_model_par), + "Test GModelPar"); + append(static_cast(&TestGModel::test_sky_model), + "Test GModelSky"); // Append spatial model tests append(static_cast(&TestGModel::test_point_source), @@ -94,20 +102,32 @@ void TestGModel::set(void) "Test spatial model XML I/O"); // Append spectral model tests - append(static_cast(&TestGModel::test_const), "Test GModelSpectralConst"); - append(static_cast(&TestGModel::test_gauss), "Test GModelSpectralGauss"); - append(static_cast(&TestGModel::test_plaw), "Test GModelSpectralPlaw"); - append(static_cast(&TestGModel::test_plaw2), "Test GModelSpectralPlaw2"); - append(static_cast(&TestGModel::test_eplaw), "Test GModelSpectralExpPlaw"); - append(static_cast(&TestGModel::test_supeplaw), "Test GModelSpectralSuperExpPlaw"); - append(static_cast(&TestGModel::test_bplaw), "Test GModelSpectralBrokenPlaw"); - append(static_cast(&TestGModel::test_logparabola), "Test GModelSpectralLogParabola"); - append(static_cast(&TestGModel::test_nodes), "Test GModelSpectralNodes"); - append(static_cast(&TestGModel::test_filefct), "Test GModelSpectralFunc"); - append(static_cast(&TestGModel::test_spectral_model), "Test spectral model XML I/O"); + append(static_cast(&TestGModel::test_const), + "Test GModelSpectralConst"); + append(static_cast(&TestGModel::test_gauss), + "Test GModelSpectralGauss"); + append(static_cast(&TestGModel::test_plaw), + "Test GModelSpectralPlaw"); + append(static_cast(&TestGModel::test_plaw2), + "Test GModelSpectralPlaw2"); + append(static_cast(&TestGModel::test_eplaw), + "Test GModelSpectralExpPlaw"); + append(static_cast(&TestGModel::test_supeplaw), + "Test GModelSpectralSuperExpPlaw"); + append(static_cast(&TestGModel::test_bplaw), + "Test GModelSpectralBrokenPlaw"); + append(static_cast(&TestGModel::test_logparabola), + "Test GModelSpectralLogParabola"); + append(static_cast(&TestGModel::test_nodes), + "Test GModelSpectralNodes"); + append(static_cast(&TestGModel::test_filefct), + "Test GModelSpectralFunc"); + append(static_cast(&TestGModel::test_spectral_model), + "Test spectral model XML I/O"); // Append temporal model tests - append(static_cast(&TestGModel::test_temp_const), "Test GModelTemporalConst"); + append(static_cast(&TestGModel::test_temp_const), + "Test GModelTemporalConst"); // Append genereric model tests append(static_cast(&TestGModel::test_model), "Test GModel"); @@ -116,7 +136,8 @@ void TestGModel::set(void) append(static_cast(&TestGModel::test_models), "Test GModels"); // Append model registry tests - append(static_cast(&TestGModel::test_model_registry), "Test model registries"); + append(static_cast(&TestGModel::test_model_registry), + "Test model registries"); // Return return; @@ -2110,70 +2131,45 @@ void TestGModel::test_nodes(void) void TestGModel::test_filefct(void) { // Test void constructor - test_try("Test void constructor"); - try { - GModelSpectralFunc model; - test_assert(model.type() == "FileFunction", - "Model type \"FileFunction\" expected."); - test_try_success(); - } - catch (std::exception &e) { - test_try_failure(e); - } + GModelSpectralFunc model1; + test_assert(model1.type() == "FileFunction", "Check model type"); // Test value constructor - test_try("Test value constructor"); - try { - GModelSpectralFunc model("data/filefunction.txt", 2.0); - test_assert(model.filename().url() == "data/filefunction.txt", - "Expected \"data/filefunction.txt\""); - test_value(model.norm(), 2.0); - test_try_success(); - } - catch (std::exception &e) { - test_try_failure(e); - } + GModelSpectralFunc model2(m_filefct, 2.0); + test_assert(model2.filename().url() == m_filefct, + "Check file function data file name"); + test_value(model2.norm(), 2.0); - // Test XML constructor and value - test_try("Test XML constructor, value and gradients"); - try { - // Test XML constructor - GXml xml(m_xml_model_point_filefct); - GXmlElement* element = xml.element(0)->element(0)->element("spectrum", 0); - GModelSpectralFunc model(*element); - test_value(model.size(), 1); - test_assert(model.type() == "FileFunction", "Expected \"FileFunction\""); - test_assert(model.filename().url() == "data/filefunction.txt", - "Expected \"data/filefunction.txt\""); - test_value(model.norm(), 1.0); - - // Test filename method - model.filename("data/filefunction.txt"); - test_assert(model.filename().url() == "data/filefunction.txt", - "Expected \"data/filefunction.txt\""); - - // Test norm method - model.norm(3.0); - test_value(model.norm(), 3.0); - - // Test operator access - const char* strarray[] = {"Normalization"}; - for (int i = 0; i < 1; ++i) { - std::string keyname(strarray[i]); - model[keyname].remove_range(); // To allow setting of any value - model[keyname].value(2.1); - model[keyname].error(1.9); - model[keyname].gradient(0.8); - test_value(model[keyname].value(), 2.1); - test_value(model[keyname].error(), 1.9); - test_value(model[keyname].gradient(), 0.8); - } + // Test XML constructor + GXml xml(m_xml_model_point_filefct); + GXmlElement* element = xml.element(0)->element(0)->element("spectrum", 0); + GModelSpectralFunc model3(*element); + test_value(model3.size(), 1); + test_assert(model3.type() == "FileFunction", "Check model type"); + test_assert(model3.filename().url() == m_filefct, + "Check file function data file name"); + test_value(model3.norm(), 1.0); + + // Test filename method + model3.filename(m_filefct); + test_assert(model3.filename().url() == m_filefct, + "Check file function data file name"); + + // Test norm method + model3.norm(3.0); + test_value(model3.norm(), 3.0); - // Success if we reached this point - test_try_success(); - } - catch (std::exception &e) { - test_try_failure(e); + // Test operator access + const char* strarray[] = {"Normalization"}; + for (int i = 0; i < 1; ++i) { + std::string keyname(strarray[i]); + model3[keyname].remove_range(); // To allow setting of any value + model3[keyname].value(2.1); + model3[keyname].error(1.9); + model3[keyname].gradient(0.8); + test_value(model3[keyname].value(), 2.1); + test_value(model3[keyname].error(), 1.9); + test_value(model3[keyname].gradient(), 0.8); } // Exit test @@ -2744,20 +2740,20 @@ int main(void) GTestSuites testsuite("GModel"); // Initialise success flag - bool was_successful=true; + bool success = true; // Create a test suite TestGModel test; - // Append to the container + // Append test to the container testsuite.append(test); - // Run - was_successful=testsuite.run(); + // Run the testsuites + success = testsuite.run(); // Save xml report testsuite.save("reports/GModel.xml"); // Return - return was_successful ? 0:1; + return success ? 0:1; } diff --git a/test/test_GModel.hpp b/test/test_GModel.hpp index 1033df6..c403cac 100644 --- a/test/test_GModel.hpp +++ b/test/test_GModel.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * test_GModel.hpp - Test model module * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Jean-Baptiste Cayrou * + * copyright (C) 2012-2016 by Jean-Baptiste Cayrou * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -82,6 +82,7 @@ private: // Private attributes std::string m_map_file; std::string m_cube_file; + std::string m_filefct; std::string m_xml_file; std::string m_xml_model_point_const; std::string m_xml_model_point_gauss; diff --git a/test/test_GSky.cpp b/test/test_GSky.cpp index 03871e1..60c9ff6 100644 --- a/test/test_GSky.cpp +++ b/test/test_GSky.cpp @@ -43,6 +43,10 @@ #define G_WCS_FORTH_BACK_PIXEL_DEBUG #define G_WCS_COPY_DEBUG +/* __ Constants __________________________________________________________ */ +const std::string srcdir = std::getenv("TESTS_SRCDIR"); +const std::string sky_region = srcdir + "/test/data/test_circle_region.reg"; + /***********************************************************************//** * @brief Set parameters and tests @@ -1383,16 +1387,13 @@ void TestGSky::test_GSkyRegionCircle_logic(void) ***************************************************************************/ void TestGSky::test_GSkyRegions_io(void) { - // Set filenames - const std::string filename = "data/test_circle_region.reg"; - // Allocate regions GSkyRegions regions; // Test regions loading test_try("Test regions loading"); try { - regions.load(filename); + regions.load(sky_region); test_try_success(); } catch (std::exception &e) { diff --git a/test/test_GSky.py b/test/test_GSky.py index cf7742d..72b7a14 100755 --- a/test/test_GSky.py +++ b/test/test_GSky.py @@ -17,9 +17,9 @@ # along with this program. If not, see . # # ========================================================================== -import gammalib import os import math +import gammalib # =========== # @@ -387,9 +387,12 @@ class Test(gammalib.GPythonTestSuite): Test txt files taken from: See https://github.com/astropy/coordinates-benchmark """ + # Get test data directory + datadir = os.environ['TESTS_SRCDIR'] + '/test/data/' + # Set parameters - fk5_filename = "data/initial_coords.txt" - galactic_filename = "data/fk5_to_galactic.txt" + fk5_filename = datadir + 'initial_coords.txt' + galactic_filename = datadir + 'fk5_to_galactic.txt' fk5_coordinates = loadtxt(fk5_filename) galactic_coordinates = loadtxt(galactic_filename) coordinates = zip(fk5_coordinates, galactic_coordinates) diff --git a/test/test_GSupport.cpp b/test/test_GSupport.cpp index 138e3c2..7ca8029 100644 --- a/test/test_GSupport.cpp +++ b/test/test_GSupport.cpp @@ -28,7 +28,7 @@ #ifdef HAVE_CONFIG_H #include #endif -#include // getenv +#include // getenv #include #include "GTools.hpp" #include "test_GSupport.hpp" @@ -39,6 +39,10 @@ /* __ Debug definitions __________________________________________________ */ +/* __ Constants __________________________________________________________ */ +const std::string srcdir = std::getenv("TESTS_SRCDIR"); +const std::string csv_file = srcdir + "/test/data/csv.dat"; + /***********************************************************************//** * @brief Set parameters and tests @@ -49,14 +53,22 @@ void TestGSupport::set(void){ name("GSupport"); // Append tests - append(static_cast(&TestGSupport::test_tools), "Test GTools"); - append(static_cast(&TestGSupport::test_expand_env), "Test Environment variable"); - append(static_cast(&TestGSupport::test_node_array), "Test GNodeArray"); - append(static_cast(&TestGSupport::test_bilinear), "Test GBilinear"); - append(static_cast(&TestGSupport::test_url_file), "Test GUrlFile"); - append(static_cast(&TestGSupport::test_url_string), "Test GUrlString"); - append(static_cast(&TestGSupport::test_filename), "Test GFilename"); - append(static_cast(&TestGSupport::test_csv), "Test GCsv"); + append(static_cast(&TestGSupport::test_tools), + "Test GTools"); + append(static_cast(&TestGSupport::test_expand_env), + "Test Environment variable"); + append(static_cast(&TestGSupport::test_node_array), + "Test GNodeArray"); + append(static_cast(&TestGSupport::test_bilinear), + "Test GBilinear"); + append(static_cast(&TestGSupport::test_url_file), + "Test GUrlFile"); + append(static_cast(&TestGSupport::test_url_string), + "Test GUrlString"); + append(static_cast(&TestGSupport::test_filename), + "Test GFilename"); + append(static_cast(&TestGSupport::test_csv), + "Test GCsv"); // Return return; @@ -878,7 +890,7 @@ void TestGSupport::test_csv(void) test_value(csv2.nrows(), 3); // Test filename constructor - GCsv csv3("data/csv.dat", ","); + GCsv csv3(csv_file, ","); test_value(csv3.size(), 12); test_value(csv3.ncols(), 3); test_value(csv3.nrows(), 4); @@ -971,6 +983,8 @@ int main(void) // Create and append test suite TestGSupport test; + + // Append test to the container testsuites.append(test); // Run the testsuites diff --git a/test/test_GXml.cpp b/test/test_GXml.cpp index cc658f3..94a5b20 100644 --- a/test/test_GXml.cpp +++ b/test/test_GXml.cpp @@ -28,9 +28,12 @@ #ifdef HAVE_CONFIG_H #include #endif +#include // getenv #include "test_GXml.hpp" #include "GTools.hpp" +/* __ Constants __________________________________________________________ */ + /***********************************************************************//** * @brief Set parameters and tests @@ -40,8 +43,11 @@ void TestGXml::set(void) // Test name name("GXml"); + // Set srcdir + std::string srcdir = std::getenv("TESTS_SRCDIR"); + // Set XML filename - m_xml_file = "data/test.xml"; + m_xml_file = srcdir + "/test/data/test.xml"; // Append tests append(static_cast(&TestGXml::test_GXml_attributes), diff --git a/test/test_GXspec.cpp b/test/test_GXspec.cpp index bdb0a5b..04f113d 100644 --- a/test/test_GXspec.cpp +++ b/test/test_GXspec.cpp @@ -28,12 +28,14 @@ #ifdef HAVE_CONFIG_H #include #endif +#include // getenv #include "test_GXspec.hpp" #include "GTools.hpp" /* __ Constants __________________________________________________________ */ -const std::string rmfname = PACKAGE_SOURCE"/test/data/rmf.fits"; +const std::string srcdir = std::getenv("TESTS_SRCDIR"); +const std::string rmfname = srcdir + "/test/data/rmf.fits"; /***********************************************************************//** diff --git a/test/test_examples.py b/test/test_examples.py index 0b3ebb8..c8dc075 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -18,9 +18,9 @@ # along with this program. If not, see . # # ========================================================================== -import gammalib -import sys import os +import sys +import gammalib # =============================================== # @@ -33,14 +33,14 @@ class Test(gammalib.GPythonTestSuite): # Constructor def __init__(self): """ - Constructor. + Constructor """ # Call base class constructor gammalib.GPythonTestSuite.__init__(self) # Examples directory - self._cpp_dir = '../examples/cpp/' - self._python_dir = '../examples/python/' + self._cpp_dir = os.environ['TESTS_BUILDDIR'] + '/examples/cpp/' + self._python_dir = os.environ['TESTS_SRCDIR'] + '/examples/python/' # Return return @@ -127,8 +127,6 @@ class Test(gammalib.GPythonTestSuite): # Execute binary self._execute_binary('createfits') - #TODO: Do any testing - # Return return @@ -140,8 +138,6 @@ class Test(gammalib.GPythonTestSuite): # Execute binary self._execute_binary('createskymap') - #TODO: Do any testing - # Return return @@ -153,8 +149,6 @@ class Test(gammalib.GPythonTestSuite): # Execute binary self._execute_binary('createxml') - #TODO: Do any testing - # Return return @@ -166,8 +160,6 @@ class Test(gammalib.GPythonTestSuite): # Execute binary self._execute_binary('interpolate') - #TODO: Do any testing - # Return return @@ -179,8 +171,6 @@ class Test(gammalib.GPythonTestSuite): # Execute binary self._execute_binary('numerics') - #TODO: Do any testing - # Return return @@ -192,8 +182,6 @@ class Test(gammalib.GPythonTestSuite): # Execute binary self._execute_binary('optimize') - #TODO: Do any testing - # Return return @@ -205,8 +193,6 @@ class Test(gammalib.GPythonTestSuite): # Execute binary self._execute_binary('readmodel') - #TODO: Do any testing - # Return return @@ -218,8 +204,6 @@ class Test(gammalib.GPythonTestSuite): # Execute python script self._execute_python('matrix_howto') - #TODO: Do any testing - # Return return @@ -231,8 +215,6 @@ class Test(gammalib.GPythonTestSuite): # Execute python script self._execute_python('models_howto') - #TODO: Do any testing - # Return return @@ -244,8 +226,6 @@ class Test(gammalib.GPythonTestSuite): # Execute python script self._execute_python('xml_howto') - #TODO: Do any testing - # Return return @@ -257,8 +237,6 @@ class Test(gammalib.GPythonTestSuite): # Execute python script self._execute_python('xml_html_create') - #TODO: Do any testing - # Return return diff --git a/test/test_examples.sh.in b/test/test_examples.sh.in index fc5d689..151fe00 100755 --- a/test/test_examples.sh.in +++ b/test/test_examples.sh.in @@ -22,4 +22,4 @@ # # Run the examples test # ===================== -@PYTHON_COVERAGE@./test_examples.py +@PYTHON_COVERAGE@@srcdir@/test_examples.py diff --git a/test/test_python.py b/test/test_python.py index 7e8b10c..4871905 100755 --- a/test/test_python.py +++ b/test/test_python.py @@ -18,9 +18,9 @@ # along with this program. If not, see . # # ========================================================================== -import gammalib -import sys import os +import sys +import gammalib sys.path.append(os.path.dirname(os.path.abspath(__file__))) import test_GApplication import test_GLinalg @@ -70,7 +70,7 @@ except: # ================== # def test(installed=False): """ - Perform unit testing for Python interface. + Perform unit testing for Python interface """ # Allocate test suites suites = gammalib.GTestSuites('Python interface testing') @@ -131,7 +131,7 @@ def test(installed=False): suite_cta = test_CTA.Test() suite_cta.set() if installed: - suite_cta.caldb_path('cta/caldb') + suite_cta.testdir('cta') # Test data for installed test suites.append(suite_cta) # Optionally handle LAT suite diff --git a/test/test_python.sh.in b/test/test_python.sh.in index fe656d1..e045583 100755 --- a/test/test_python.sh.in +++ b/test/test_python.sh.in @@ -27,4 +27,4 @@ rm -rf .coverage # # Run the Python test # =================== -@PYTHON_COVERAGE@./test_python.py +@PYTHON_COVERAGE@@srcdir@/test_python.py