Commit e9b90e4ec9ac1d0b3c6e7d4541a34af9285b8931
1 parent
1531900e
Add cscripts and Python coverage measure.
Showing
6 changed files
with
88 additions
and
26 deletions
.gitignore
| ... | ... | @@ -40,6 +40,7 @@ stamp-h1 |
| 40 | 40 | depcomp |
| 41 | 41 | test-driver |
| 42 | 42 | testconf.sh |
| 43 | +coverage-report-python.xml | |
| 43 | 44 | |
| 44 | 45 | doc/html |
| 45 | 46 | doc/man |
| ... | ... | @@ -77,6 +78,8 @@ test/reports/*.xml |
| 77 | 78 | test/butterfly.txt |
| 78 | 79 | test/model.reg |
| 79 | 80 | test/obs.reg |
| 81 | +test/.coverage | |
| 82 | +test/test_python.sh | |
| 80 | 83 | examples/*.fits |
| 81 | 84 | examples/*.xml |
| 82 | 85 | examples/*.dat | ... | ... |
Makefile.am
| ... | ... | @@ -93,9 +93,15 @@ cppncss: |
| 93 | 93 | # Add coverage rule |
| 94 | 94 | coverage: |
| 95 | 95 | @if type gcovr >/dev/null 2>&1; then \ |
| 96 | - gcovr -r . -x -o gcovr-reports-data.xml; \ | |
| 96 | + gcovr -r . -x -o coverage-report-cxx.xml; \ | |
| 97 | 97 | else \ |
| 98 | 98 | echo "gcovr script not found in PATH."; \ |
| 99 | + fi; \ | |
| 100 | + if type coverage >/dev/null 2>&1; then \ | |
| 101 | + export COVERAGE_FILE=test/.coverage; \ | |
| 102 | + coverage xml --omit=**/gammalib/** -o coverage-report-python.xml; \ | |
| 103 | + else \ | |
| 104 | + echo "coverage script not found in PATH."; \ | |
| 99 | 105 | fi |
| 100 | 106 | |
| 101 | 107 | # Add Valgrind rule | ... | ... |
configure.ac
| ... | ... | @@ -754,6 +754,32 @@ fi |
| 754 | 754 | |
| 755 | 755 | |
| 756 | 756 | ############################################################################# |
| 757 | +# Checks for coverage option # | |
| 758 | +############################################################################# | |
| 759 | +# Initialise Python coverage with empty string | |
| 760 | +PYTHON_COVERAGE= | |
| 761 | + | |
| 762 | +# Check for coverage option | |
| 763 | +AC_MSG_CHECKING(whether to build ctools for code coverage measure) | |
| 764 | +AC_ARG_ENABLE([coverage], | |
| 765 | + AS_HELP_STRING([--enable-coverage], | |
| 766 | + [turn on code coverage measure [default=no]]), | |
| 767 | + [enable_coverage="$enableval"], | |
| 768 | + [enable_coverage="no"]) | |
| 769 | +if test "x$enable_coverage" = "xyes"; then | |
| 770 | + CXXFLAGS="--coverage $CXXFLAGS" | |
| 771 | + LDFLAGS="--coverage $LDFLAGS" | |
| 772 | + if test "x$has_python" = "xyes"; then | |
| 773 | + PYTHON_COVERAGE="coverage run --append " | |
| 774 | + fi | |
| 775 | + AC_MSG_RESULT(yes) | |
| 776 | +else | |
| 777 | + AC_MSG_RESULT(no) | |
| 778 | +fi | |
| 779 | +AC_SUBST(PYTHON_COVERAGE) | |
| 780 | + | |
| 781 | + | |
| 782 | +############################################################################# | |
| 757 | 783 | # Checks for GammaLib library # |
| 758 | 784 | ############################################################################# |
| 759 | 785 | # Initialise GammaLib availability |
| ... | ... | @@ -971,6 +997,7 @@ AC_CONFIG_FILES([Makefile |
| 971 | 997 | src/ctools-setup |
| 972 | 998 | test/Makefile |
| 973 | 999 | test/test_cscripts.sh |
| 1000 | + test/test_python.sh | |
| 974 | 1001 | pyext/Makefile |
| 975 | 1002 | pyext/setup.py |
| 976 | 1003 | pyext/ctools/__init__.py |
| ... | ... | @@ -982,6 +1009,7 @@ AC_CONFIG_FILES([Makefile |
| 982 | 1009 | ctools.pc |
| 983 | 1010 | testconf.sh], |
| 984 | 1011 | [if test -f test/test_cscripts.sh; then chmod +x test/test_cscripts.sh; fi; |
| 1012 | + if test -f test/test_python.sh; then chmod +x test/test_python.sh; fi; | |
| 985 | 1013 | if test -f testconf.sh; then chmod +x testconf.sh; fi]) |
| 986 | 1014 | AC_OUTPUT |
| 987 | 1015 | ... | ... |
test/Makefile.am
| ... | ... | @@ -7,7 +7,7 @@ MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ |
| 7 | 7 | # Optional python bindings |
| 8 | 8 | if WITH_PYTHON |
| 9 | 9 | TEST_CSCRIPTS = test_cscripts.sh |
| 10 | - TEST_PYTHON_SCRIPT = test_python.py | |
| 10 | + TEST_PYTHON_SCRIPT = test_python.sh | |
| 11 | 11 | TEST_PYTHON_ENV = PYTHONPATH=$(top_builddir):$(top_builddir)/pyext:$(top_builddir)/pyext/build/ctools/ctools:$(pythondir):$(pyexecdir):$(PYTHONPATH) |
| 12 | 12 | endif |
| 13 | 13 | ... | ... |
test/test_cscripts.sh.in
| ... | ... | @@ -36,7 +36,7 @@ $ECHO "*****************" |
| 36 | 36 | # |
| 37 | 37 | # Remove any existing result files |
| 38 | 38 | # ================================ |
| 39 | -rm -rf *.fits *.xml *.dat *.reg | |
| 39 | +rm -rf *.fits *.xml *.dat *.reg .coverage | |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | # |
| ... | ... | @@ -56,7 +56,7 @@ mkdir -p $CALDB |
| 56 | 56 | # ================ |
| 57 | 57 | $ECHO -n "Test csobs2caldb: " |
| 58 | 58 | chmod +x @abs_top_srcdir@/cscripts/csobs2caldb.py |
| 59 | -@abs_top_srcdir@/cscripts/csobs2caldb.py \ | |
| 59 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobs2caldb.py \ | |
| 60 | 60 | inobs="data/obs_unbinned.xml" \ |
| 61 | 61 | rspname="test_irfs" \ |
| 62 | 62 | chatter=4 > csobs2caldb.log |
| ... | ... | @@ -76,7 +76,7 @@ $ECHO " ok" |
| 76 | 76 | # ============= |
| 77 | 77 | $ECHO -n "Test csobsdef: " |
| 78 | 78 | chmod +x @abs_top_srcdir@/cscripts/csobsdef.py |
| 79 | -@abs_top_srcdir@/cscripts/csobsdef.py \ | |
| 79 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobsdef.py \ | |
| 80 | 80 | inpnt="data/pntdef.dat" \ |
| 81 | 81 | outobs="obs.xml" \ |
| 82 | 82 | caldb="irf" \ |
| ... | ... | @@ -101,7 +101,7 @@ $ECHO " ok" |
| 101 | 101 | # ============== |
| 102 | 102 | $ECHO -n "Test csobsinfo: " |
| 103 | 103 | chmod +x @abs_top_srcdir@/cscripts/csobsinfo.py |
| 104 | -@abs_top_srcdir@/cscripts/csobsinfo.py \ | |
| 104 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csobsinfo.py \ | |
| 105 | 105 | inobs="obs.xml" \ |
| 106 | 106 | ds9file="obs.reg" \ |
| 107 | 107 | offset=yes \ |
| ... | ... | @@ -123,7 +123,7 @@ $ECHO " ok" |
| 123 | 123 | # ================ |
| 124 | 124 | $ECHO -n "Test csmodelinfo: " |
| 125 | 125 | chmod +x @abs_top_srcdir@/cscripts/csmodelinfo.py |
| 126 | -@abs_top_srcdir@/cscripts/csmodelinfo.py \ | |
| 126 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelinfo.py \ | |
| 127 | 127 | inmodel="data/crab.xml" \ |
| 128 | 128 | ds9file="model.reg" > csmodelinfo.log |
| 129 | 129 | $ECHO -n "." |
| ... | ... | @@ -143,7 +143,7 @@ $ECHO " ok" |
| 143 | 143 | $ECHO -n "Test csmodelmerge: " |
| 144 | 144 | # === space-separated === |
| 145 | 145 | chmod +x @abs_top_srcdir@/cscripts/csmodelmerge.py |
| 146 | -@abs_top_srcdir@/cscripts/csmodelmerge.py \ | |
| 146 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \ | |
| 147 | 147 | inmodels="data/crab.xml data/source1.xml" \ |
| 148 | 148 | outmodel="merged_models.xml" > csmodelmerge.log |
| 149 | 149 | $ECHO -n "." |
| ... | ... | @@ -155,7 +155,7 @@ else |
| 155 | 155 | exit 1 |
| 156 | 156 | fi |
| 157 | 157 | # === comma-separated === |
| 158 | -@abs_top_srcdir@/cscripts/csmodelmerge.py \ | |
| 158 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \ | |
| 159 | 159 | inmodels="data/crab.xml,data/source1.xml" \ |
| 160 | 160 | outmodel="merged_models2.xml" > csmodelmerge.log |
| 161 | 161 | $ECHO -n "." |
| ... | ... | @@ -167,7 +167,7 @@ else |
| 167 | 167 | exit 1 |
| 168 | 168 | fi |
| 169 | 169 | # === wildcard string === |
| 170 | -@abs_top_srcdir@/cscripts/csmodelmerge.py \ | |
| 170 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \ | |
| 171 | 171 | inmodels="data/model_cube_background*.xml" \ |
| 172 | 172 | outmodel="merged_models3.xml" > csmodelmerge.log |
| 173 | 173 | $ECHO -n "." |
| ... | ... | @@ -180,7 +180,7 @@ else |
| 180 | 180 | fi |
| 181 | 181 | # === ascii-file === |
| 182 | 182 | ls data/model_cube_background* > models.txt |
| 183 | -@abs_top_srcdir@/cscripts/csmodelmerge.py \ | |
| 183 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csmodelmerge.py \ | |
| 184 | 184 | inmodels="@models.txt" \ |
| 185 | 185 | outmodel="merged_models4.xml" > csmodelmerge.log |
| 186 | 186 | $ECHO -n "." |
| ... | ... | @@ -201,7 +201,7 @@ rm models.txt |
| 201 | 201 | $ECHO -n "Test cstsmapmerge: " |
| 202 | 202 | # === comma-separated === |
| 203 | 203 | chmod +x @abs_top_srcdir@/cscripts/cstsmapmerge.py |
| 204 | -@abs_top_srcdir@/cscripts/cstsmapmerge.py \ | |
| 204 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \ | |
| 205 | 205 | inmaps="data/tsmap_0.fits,data/tsmap_1.fits" \ |
| 206 | 206 | outmap="merged_tsmap1.fits" > cstsmapmerge.log |
| 207 | 207 | $ECHO -n "." |
| ... | ... | @@ -213,7 +213,7 @@ else |
| 213 | 213 | exit 1 |
| 214 | 214 | fi |
| 215 | 215 | # === space-separated === |
| 216 | -@abs_top_srcdir@/cscripts/cstsmapmerge.py \ | |
| 216 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \ | |
| 217 | 217 | inmaps="data/tsmap_0.fits data/tsmap_1.fits" \ |
| 218 | 218 | outmap="merged_tsmap2.fits" > cstsmapmerge.log |
| 219 | 219 | $ECHO -n "." |
| ... | ... | @@ -225,7 +225,7 @@ else |
| 225 | 225 | exit 1 |
| 226 | 226 | fi |
| 227 | 227 | # === wildcard string === |
| 228 | -@abs_top_srcdir@/cscripts/cstsmapmerge.py \ | |
| 228 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \ | |
| 229 | 229 | inmaps="data/tsmap_*.fits" \ |
| 230 | 230 | outmap="merged_tsmap3.fits" > cstsmapmerge.log |
| 231 | 231 | $ECHO -n "." |
| ... | ... | @@ -238,7 +238,7 @@ else |
| 238 | 238 | fi |
| 239 | 239 | # === ascii-file === |
| 240 | 240 | ls data/tsmap_*.fits > tsmaps.txt |
| 241 | -@abs_top_srcdir@/cscripts/cstsmapmerge.py \ | |
| 241 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsmapmerge.py \ | |
| 242 | 242 | inmaps="@tsmaps.txt" \ |
| 243 | 243 | outmap="merged_tsmap4.fits" > cstsmapmerge.log |
| 244 | 244 | $ECHO -n "." |
| ... | ... | @@ -258,7 +258,7 @@ rm tsmaps.txt |
| 258 | 258 | # =========== |
| 259 | 259 | $ECHO -n "Test cspull: " |
| 260 | 260 | chmod +x @abs_top_srcdir@/cscripts/cspull.py |
| 261 | -@abs_top_srcdir@/cscripts/cspull.py \ | |
| 261 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cspull.py \ | |
| 262 | 262 | inmodel="data/crab.xml" \ |
| 263 | 263 | outfile="pull.dat" \ |
| 264 | 264 | ntrials="3" \ |
| ... | ... | @@ -291,7 +291,7 @@ $ECHO " ok" |
| 291 | 291 | # =========== |
| 292 | 292 | $ECHO -n "Test cssens: " |
| 293 | 293 | chmod +x @abs_top_srcdir@/cscripts/cssens.py |
| 294 | -@abs_top_srcdir@/cscripts/cssens.py \ | |
| 294 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cssens.py \ | |
| 295 | 295 | inmodel="data/crab.xml" \ |
| 296 | 296 | srcname="Crab" \ |
| 297 | 297 | caldb="irf" \ |
| ... | ... | @@ -317,7 +317,7 @@ $ECHO " ok" |
| 317 | 317 | # ============= |
| 318 | 318 | $ECHO -n "Test cstsdist: " |
| 319 | 319 | chmod +x @abs_top_srcdir@/cscripts/cstsdist.py |
| 320 | -@abs_top_srcdir@/cscripts/cstsdist.py \ | |
| 320 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cstsdist.py \ | |
| 321 | 321 | inmodel="data/crab.xml" \ |
| 322 | 322 | srcname="Crab" \ |
| 323 | 323 | outfile="ts.dat" \ |
| ... | ... | @@ -349,7 +349,7 @@ $ECHO " ok" |
| 349 | 349 | # ============= |
| 350 | 350 | $ECHO -n "Test csresmap: " |
| 351 | 351 | chmod +x @abs_top_srcdir@/cscripts/csresmap.py |
| 352 | -@abs_top_srcdir@/cscripts/csresmap.py \ | |
| 352 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csresmap.py \ | |
| 353 | 353 | inobs="data/crab_events.fits" \ |
| 354 | 354 | outmap="resmap.fits" \ |
| 355 | 355 | inmodel="data/crab.xml" \ |
| ... | ... | @@ -381,7 +381,7 @@ $ECHO " ok" |
| 381 | 381 | $ECHO -n "Test csspec: " |
| 382 | 382 | # === Unbinned === |
| 383 | 383 | chmod +x @abs_top_srcdir@/cscripts/csspec.py |
| 384 | -@abs_top_srcdir@/cscripts/csspec.py \ | |
| 384 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csspec.py \ | |
| 385 | 385 | inobs="data/crab_events.fits" \ |
| 386 | 386 | inmodel="data/crab.xml" \ |
| 387 | 387 | caldb="irf" \ |
| ... | ... | @@ -401,7 +401,7 @@ else |
| 401 | 401 | exit 1 |
| 402 | 402 | fi |
| 403 | 403 | # === Binned === |
| 404 | -@abs_top_srcdir@/cscripts/csspec.py \ | |
| 404 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csspec.py \ | |
| 405 | 405 | inobs="data/crab_cntmap_small.fits.gz" \ |
| 406 | 406 | expcube="data/crab_expcube.fits.gz" \ |
| 407 | 407 | psfcube="data/crab_psfcube.fits.gz" \ |
| ... | ... | @@ -431,7 +431,7 @@ $ECHO " ok" |
| 431 | 431 | $ECHO -n "Test cslightcrv: " |
| 432 | 432 | # === unbinned === |
| 433 | 433 | chmod +x @abs_top_srcdir@/cscripts/cslightcrv.py |
| 434 | -@abs_top_srcdir@/cscripts/cslightcrv.py \ | |
| 434 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cslightcrv.py \ | |
| 435 | 435 | inobs="data/crab_events.fits" \ |
| 436 | 436 | inmodel="data/crab.xml" \ |
| 437 | 437 | srcname="Crab" \ |
| ... | ... | @@ -454,7 +454,7 @@ else |
| 454 | 454 | exit 1 |
| 455 | 455 | fi |
| 456 | 456 | # === binned === |
| 457 | -@abs_top_srcdir@/cscripts/cslightcrv.py \ | |
| 457 | +@PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/cslightcrv.py \ | |
| 458 | 458 | inobs="data/crab_events.fits" \ |
| 459 | 459 | inmodel="data/crab.xml" \ |
| 460 | 460 | srcname="Crab" \ |
| ... | ... | @@ -494,7 +494,7 @@ if [ $python_version -ge 26 ]; then |
| 494 | 494 | # ============== |
| 495 | 495 | $ECHO -n "Test csfindobs: " |
| 496 | 496 | chmod +x @abs_top_srcdir@/cscripts/csfindobs.py |
| 497 | - @abs_top_srcdir@/cscripts/csfindobs.py \ | |
| 497 | + @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csfindobs.py \ | |
| 498 | 498 | datapath="iactdata/" \ |
| 499 | 499 | prodname="unit-test" \ |
| 500 | 500 | ra="83.6331" \ |
| ... | ... | @@ -517,7 +517,7 @@ if [ $python_version -ge 26 ]; then |
| 517 | 517 | # =============== |
| 518 | 518 | $ECHO -n "Test csiactcopy: " |
| 519 | 519 | chmod +x @abs_top_srcdir@/cscripts/csiactcopy.py |
| 520 | - @abs_top_srcdir@/cscripts/csiactcopy.py \ | |
| 520 | + @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csiactcopy.py \ | |
| 521 | 521 | remote_master="iactdata/master.json" \ |
| 522 | 522 | outpath="iactdata_test" \ |
| 523 | 523 | prodname="unit-test" > csiactcopy.log |
| ... | ... | @@ -537,7 +537,7 @@ if [ $python_version -ge 26 ]; then |
| 537 | 537 | # ============== |
| 538 | 538 | $ECHO -n "Test csiactobs: " |
| 539 | 539 | chmod +x @abs_top_srcdir@/cscripts/csiactobs.py |
| 540 | - @abs_top_srcdir@/cscripts/csiactobs.py \ | |
| 540 | + @PYTHON_COVERAGE@@abs_top_srcdir@/cscripts/csiactobs.py \ | |
| 541 | 541 | datapath="iactdata/" \ |
| 542 | 542 | prodname="unit-test" \ |
| 543 | 543 | infile="iactrunlist.dat" \ | ... | ... |
test/test_python.sh.in
0 → 100755
| 1 | +#! /bin/sh | |
| 2 | +# ========================================================================== | |
| 3 | +# This script tests the ctools Python module | |
| 4 | +# | |
| 5 | +# Copyright (C) 2016 Juergen Knoedlseder | |
| 6 | +# | |
| 7 | +# This program is free software: you can redistribute it and/or modify | |
| 8 | +# it under the terms of the GNU General Public License as published by | |
| 9 | +# the Free Software Foundation, either version 3 of the License, or | |
| 10 | +# (at your option) any later version. | |
| 11 | +# | |
| 12 | +# This program is distributed in the hope that it will be useful, | |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | +# GNU General Public License for more details. | |
| 16 | +# | |
| 17 | +# You should have received a copy of the GNU General Public License | |
| 18 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 19 | +# | |
| 20 | +# ========================================================================== | |
| 21 | + | |
| 22 | +# | |
| 23 | +# Run the Python test | |
| 24 | +# =================== | |
| 25 | +@PYTHON_COVERAGE@./test_python.py | ... | ... |