aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtester.make91
-rw-r--r--libmm-glib/tests/Makefile.am12
-rw-r--r--libqcdm/tests/Makefile.am15
-rw-r--r--libwmc/tests/Makefile.am18
-rw-r--r--src/tests/Makefile.am18
5 files changed, 106 insertions, 48 deletions
diff --git a/gtester.make b/gtester.make
new file mode 100644
index 00000000..40348dcd
--- /dev/null
+++ b/gtester.make
@@ -0,0 +1,91 @@
+
+GTESTER = gtester
+GTESTER_REPORT = gtester-report
+
+# initialize variables for unconditional += appending
+EXTRA_DIST =
+TEST_PROGS =
+
+### testing rules
+
+# test: run all tests in cwd and subdirs
+test: test-nonrecursive
+ @ for subdir in $(SUBDIRS) . ; do \
+ test "$$subdir" = "." -o "$$subdir" = "po" || \
+ ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
+ done
+
+# test-nonrecursive: run tests only in cwd
+test-nonrecursive: ${TEST_PROGS}
+ @test -z "${TEST_PROGS}" || G_DEBUG=gc-friendly MALLOC_CHECK_=2 MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256)) ${GTESTER} --verbose ${TEST_PROGS}
+
+# test-report: run tests in subdirs and generate report
+# perf-report: run tests in subdirs with -m perf and generate report
+# full-report: like test-report: with -m perf and -m slow
+test-report perf-report full-report: ${TEST_PROGS}
+ @test -z "${TEST_PROGS}" || { \
+ case $@ in \
+ test-report) test_options="-k";; \
+ perf-report) test_options="-k -m=perf";; \
+ full-report) test_options="-k -m=perf -m=slow";; \
+ esac ; \
+ if test -z "$$GTESTER_LOGDIR" ; then \
+ ${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \
+ elif test -n "${TEST_PROGS}" ; then \
+ ${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \
+ fi ; \
+ }
+ @ ignore_logdir=true ; \
+ if test -z "$$GTESTER_LOGDIR" ; then \
+ GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \
+ ignore_logdir=false ; \
+ fi ; \
+ if test -d "$(top_srcdir)/.git" ; then \
+ REVISION=`git describe` ; \
+ else \
+ REVISION=$(VERSION) ; \
+ fi ; \
+ for subdir in $(SUBDIRS) . ; do \
+ test "$$subdir" = "." -o "$$subdir" = "po" || \
+ ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
+ done ; \
+ $$ignore_logdir || { \
+ echo '<?xml version="1.0"?>' > $@.xml ; \
+ echo '<report-collection>' >> $@.xml ; \
+ echo '<info>' >> $@.xml ; \
+ echo ' <package>$(PACKAGE)</package>' >> $@.xml ; \
+ echo ' <version>$(VERSION)</version>' >> $@.xml ; \
+ echo " <revision>$$REVISION</revision>" >> $@.xml ; \
+ echo '</info>' >> $@.xml ; \
+ for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \
+ sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \
+ done ; \
+ echo >> $@.xml ; \
+ echo '</report-collection>' >> $@.xml ; \
+ rm -rf "$$GTESTER_LOGDIR"/ ; \
+ ${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \
+ }
+.PHONY: test test-report perf-report full-report test-nonrecursive
+
+.PHONY: lcov genlcov lcov-clean
+# use recursive makes in order to ignore errors during check
+lcov:
+ -$(MAKE) $(AM_MAKEFLAGS) -k check
+ $(MAKE) $(AM_MAKEFLAGS) genlcov
+
+# we have to massage the lcov.info file slightly to hide the effect of libtool
+# placing the objects files in the .libs/ directory separate from the *.c
+# we also have to delete tests/.libs/libmoduletestplugin_*.gcda
+genlcov:
+ rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda
+ $(LTP) --directory $(top_builddir) --capture --output-file glib-lcov.info --test-name GLIB_PERF --no-checksum --compat-libtool
+ LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory glib-lcov --title "GLib Code Coverage" --legend --show-details glib-lcov.info
+ @echo "file://$(abs_top_builddir)/glib-lcov/index.html"
+
+lcov-clean:
+ -$(LTP) --directory $(top_builddir) -z
+ -rm -rf glib-lcov.info glib-lcov
+ -find -name '*.gcda' -print | xargs rm
+
+# run tests in cwd as part of make check
+check-local: test-nonrecursive
diff --git a/libmm-glib/tests/Makefile.am b/libmm-glib/tests/Makefile.am
index 92c77d86..be93d4c6 100644
--- a/libmm-glib/tests/Makefile.am
+++ b/libmm-glib/tests/Makefile.am
@@ -1,6 +1,7 @@
+include $(top_srcdir)/gtester.make
-noinst_PROGRAMS = \
- test-common-helpers
+noinst_PROGRAMS = test-common-helpers
+TEST_PROGS += $(noinst_PROGRAMS)
test_common_helpers_SOURCES = \
test-common-helpers.c
@@ -19,10 +20,3 @@ test_common_helpers_CPPFLAGS = \
test_common_helpers_LDADD = \
$(top_builddir)/libmm-glib/libmm-glib.la \
$(MM_LIBS)
-
-if WITH_TESTS
-
-check-local: test-common-helpers
- $(abs_builddir)/test-common-helpers
-
-endif
diff --git a/libqcdm/tests/Makefile.am b/libqcdm/tests/Makefile.am
index 50a7170d..ddf7d7b5 100644
--- a/libqcdm/tests/Makefile.am
+++ b/libqcdm/tests/Makefile.am
@@ -1,11 +1,12 @@
-if WITH_TESTS
+include $(top_srcdir)/gtester.make
+
+noinst_PROGRAMS = test-qcdm modepref
+TEST_PROGS += test-qcdm
INCLUDES = \
-I$(top_srcdir)/libqcdm/src \
-I$(top_srcdir)/src
-noinst_PROGRAMS = test-qcdm modepref
-
test_qcdm_SOURCES = \
test-qcdm-crc.c \
test-qcdm-crc.h \
@@ -18,9 +19,7 @@ test_qcdm_SOURCES = \
test-qcdm-result.c \
test-qcdm-result.h \
test-qcdm.c
-
test_qcdm_CPPFLAGS = $(MM_CFLAGS)
-
test_qcdm_LDADD = $(MM_LIBS)
modepref_SOURCES = modepref.c
@@ -34,9 +33,3 @@ else
test_qcdm_LDADD += $(top_builddir)/libqcdm/src/libqcdm.la
modepref_LDADD += $(top_builddir)/libqcdm/src/libqcdm.la
endif
-
-check-local: test-qcdm
- $(abs_builddir)/test-qcdm
-
-endif
-
diff --git a/libwmc/tests/Makefile.am b/libwmc/tests/Makefile.am
index ee988871..09141a08 100644
--- a/libwmc/tests/Makefile.am
+++ b/libwmc/tests/Makefile.am
@@ -1,11 +1,12 @@
-if WITH_TESTS
+include $(top_srcdir)/gtester.make
+
+noinst_PROGRAMS = test-wmc
+TEST_PROGS += $(noinst_PROGRAMS)
INCLUDES = \
-I$(top_srcdir)/libwmc/src \
-I$(top_srcdir)/src
-noinst_PROGRAMS = test-wmc
-
test_wmc_SOURCES = \
test-wmc-crc.c \
test-wmc-crc.h \
@@ -16,10 +17,7 @@ test_wmc_SOURCES = \
test-wmc-com.c \
test-wmc-com.h \
test-wmc.c
-
-test_wmc_CPPFLAGS = \
- $(MM_CFLAGS)
-
+test_wmc_CPPFLAGS = $(MM_CFLAGS)
test_wmc_LDADD = $(MM_LIBS)
if WMC_STANDALONE
@@ -27,9 +25,3 @@ test_wmc_LDADD += $(top_builddir)/src/libwmc.la
else
test_wmc_LDADD += $(top_builddir)/libwmc/src/libwmc.la
endif
-
-check-local: test-wmc
- $(abs_builddir)/test-wmc
-
-endif
-
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 38c4627c..dc583668 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -1,3 +1,4 @@
+include $(top_srcdir)/gtester.make
noinst_PROGRAMS = \
test-modem-helpers \
@@ -10,6 +11,8 @@ if WITH_QMI
noinst_PROGRAMS += test-modem-helpers-qmi
endif
+TEST_PROGS += $(noinst_PROGRAMS)
+
################
test_modem_helpers_SOURCES = \
@@ -157,18 +160,3 @@ if WITH_QMI
test_sms_part_CPPFLAGS += $(QMI_CFLAGS)
test_sms_part_LDADD += $(QMI_LIBS)
endif
-
-################
-
-if WITH_TESTS
-
-check-local: $(noinst_PROGRAMS)
- $(abs_builddir)/test-modem-helpers
- $(abs_builddir)/test-charsets
- $(abs_builddir)/test-qcdm-serial-port
- $(abs_builddir)/test-sms-part
-if WITH_QMI
- $(abs_builddir)/test-modem-helpers-qmi
-endif
-
-endif