Aleksander Morgado | 63288de | 2013-06-21 10:18:00 +0200 | [diff] [blame] | 1 | |
| 2 | GTESTER = gtester |
| 3 | GTESTER_REPORT = gtester-report |
| 4 | |
| 5 | # initialize variables for unconditional += appending |
| 6 | EXTRA_DIST = |
| 7 | TEST_PROGS = |
| 8 | |
| 9 | ### testing rules |
| 10 | |
| 11 | # test: run all tests in cwd and subdirs |
| 12 | test: test-nonrecursive |
| 13 | @ for subdir in $(SUBDIRS) . ; do \ |
| 14 | test "$$subdir" = "." -o "$$subdir" = "po" || \ |
| 15 | ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \ |
| 16 | done |
| 17 | |
| 18 | # test-nonrecursive: run tests only in cwd |
| 19 | test-nonrecursive: ${TEST_PROGS} |
| 20 | @test -z "${TEST_PROGS}" || G_DEBUG=gc-friendly MALLOC_CHECK_=2 MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) ${GTESTER} --verbose ${TEST_PROGS} |
| 21 | |
| 22 | # test-report: run tests in subdirs and generate report |
| 23 | # perf-report: run tests in subdirs with -m perf and generate report |
| 24 | # full-report: like test-report: with -m perf and -m slow |
| 25 | test-report perf-report full-report: ${TEST_PROGS} |
| 26 | @test -z "${TEST_PROGS}" || { \ |
| 27 | case $@ in \ |
| 28 | test-report) test_options="-k";; \ |
| 29 | perf-report) test_options="-k -m=perf";; \ |
| 30 | full-report) test_options="-k -m=perf -m=slow";; \ |
| 31 | esac ; \ |
| 32 | if test -z "$$GTESTER_LOGDIR" ; then \ |
| 33 | ${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \ |
| 34 | elif test -n "${TEST_PROGS}" ; then \ |
| 35 | ${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \ |
| 36 | fi ; \ |
| 37 | } |
| 38 | @ ignore_logdir=true ; \ |
| 39 | if test -z "$$GTESTER_LOGDIR" ; then \ |
| 40 | GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \ |
| 41 | ignore_logdir=false ; \ |
| 42 | fi ; \ |
| 43 | if test -d "$(top_srcdir)/.git" ; then \ |
| 44 | REVISION=`git describe` ; \ |
| 45 | else \ |
| 46 | REVISION=$(VERSION) ; \ |
| 47 | fi ; \ |
| 48 | for subdir in $(SUBDIRS) . ; do \ |
| 49 | test "$$subdir" = "." -o "$$subdir" = "po" || \ |
| 50 | ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \ |
| 51 | done ; \ |
| 52 | $$ignore_logdir || { \ |
| 53 | echo '<?xml version="1.0"?>' > $@.xml ; \ |
| 54 | echo '<report-collection>' >> $@.xml ; \ |
| 55 | echo '<info>' >> $@.xml ; \ |
| 56 | echo ' <package>$(PACKAGE)</package>' >> $@.xml ; \ |
| 57 | echo ' <version>$(VERSION)</version>' >> $@.xml ; \ |
| 58 | echo " <revision>$$REVISION</revision>" >> $@.xml ; \ |
| 59 | echo '</info>' >> $@.xml ; \ |
| 60 | for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \ |
| 61 | sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \ |
| 62 | done ; \ |
| 63 | echo >> $@.xml ; \ |
| 64 | echo '</report-collection>' >> $@.xml ; \ |
| 65 | rm -rf "$$GTESTER_LOGDIR"/ ; \ |
| 66 | ${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \ |
| 67 | } |
| 68 | .PHONY: test test-report perf-report full-report test-nonrecursive |
| 69 | |
| 70 | .PHONY: lcov genlcov lcov-clean |
| 71 | # use recursive makes in order to ignore errors during check |
| 72 | lcov: |
| 73 | -$(MAKE) $(AM_MAKEFLAGS) -k check |
| 74 | $(MAKE) $(AM_MAKEFLAGS) genlcov |
| 75 | |
| 76 | # we have to massage the lcov.info file slightly to hide the effect of libtool |
| 77 | # placing the objects files in the .libs/ directory separate from the *.c |
| 78 | # we also have to delete tests/.libs/libmoduletestplugin_*.gcda |
| 79 | genlcov: |
| 80 | rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda |
| 81 | $(LTP) --directory $(top_builddir) --capture --output-file glib-lcov.info --test-name GLIB_PERF --no-checksum --compat-libtool |
| 82 | LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory glib-lcov --title "GLib Code Coverage" --legend --show-details glib-lcov.info |
| 83 | @echo "file://$(abs_top_builddir)/glib-lcov/index.html" |
| 84 | |
| 85 | lcov-clean: |
| 86 | -$(LTP) --directory $(top_builddir) -z |
| 87 | -rm -rf glib-lcov.info glib-lcov |
| 88 | -find -name '*.gcda' -print | xargs rm |
| 89 | |
| 90 | # run tests in cwd as part of make check |
| 91 | check-local: test-nonrecursive |