build: setup gtester based tests
This commit is contained in:
91
gtester.make
Normal file
91
gtester.make
Normal file
@@ -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
|
@@ -1,6 +1,7 @@
|
|||||||
|
include $(top_srcdir)/gtester.make
|
||||||
|
|
||||||
noinst_PROGRAMS = \
|
noinst_PROGRAMS = test-common-helpers
|
||||||
test-common-helpers
|
TEST_PROGS += $(noinst_PROGRAMS)
|
||||||
|
|
||||||
test_common_helpers_SOURCES = \
|
test_common_helpers_SOURCES = \
|
||||||
test-common-helpers.c
|
test-common-helpers.c
|
||||||
@@ -19,10 +20,3 @@ test_common_helpers_CPPFLAGS = \
|
|||||||
test_common_helpers_LDADD = \
|
test_common_helpers_LDADD = \
|
||||||
$(top_builddir)/libmm-glib/libmm-glib.la \
|
$(top_builddir)/libmm-glib/libmm-glib.la \
|
||||||
$(MM_LIBS)
|
$(MM_LIBS)
|
||||||
|
|
||||||
if WITH_TESTS
|
|
||||||
|
|
||||||
check-local: test-common-helpers
|
|
||||||
$(abs_builddir)/test-common-helpers
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
if WITH_TESTS
|
include $(top_srcdir)/gtester.make
|
||||||
|
|
||||||
|
noinst_PROGRAMS = test-qcdm modepref
|
||||||
|
TEST_PROGS += test-qcdm
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I$(top_srcdir)/libqcdm/src \
|
-I$(top_srcdir)/libqcdm/src \
|
||||||
-I$(top_srcdir)/src
|
-I$(top_srcdir)/src
|
||||||
|
|
||||||
noinst_PROGRAMS = test-qcdm modepref
|
|
||||||
|
|
||||||
test_qcdm_SOURCES = \
|
test_qcdm_SOURCES = \
|
||||||
test-qcdm-crc.c \
|
test-qcdm-crc.c \
|
||||||
test-qcdm-crc.h \
|
test-qcdm-crc.h \
|
||||||
@@ -18,9 +19,7 @@ test_qcdm_SOURCES = \
|
|||||||
test-qcdm-result.c \
|
test-qcdm-result.c \
|
||||||
test-qcdm-result.h \
|
test-qcdm-result.h \
|
||||||
test-qcdm.c
|
test-qcdm.c
|
||||||
|
|
||||||
test_qcdm_CPPFLAGS = $(MM_CFLAGS)
|
test_qcdm_CPPFLAGS = $(MM_CFLAGS)
|
||||||
|
|
||||||
test_qcdm_LDADD = $(MM_LIBS)
|
test_qcdm_LDADD = $(MM_LIBS)
|
||||||
|
|
||||||
modepref_SOURCES = modepref.c
|
modepref_SOURCES = modepref.c
|
||||||
@@ -34,9 +33,3 @@ else
|
|||||||
test_qcdm_LDADD += $(top_builddir)/libqcdm/src/libqcdm.la
|
test_qcdm_LDADD += $(top_builddir)/libqcdm/src/libqcdm.la
|
||||||
modepref_LDADD += $(top_builddir)/libqcdm/src/libqcdm.la
|
modepref_LDADD += $(top_builddir)/libqcdm/src/libqcdm.la
|
||||||
endif
|
endif
|
||||||
|
|
||||||
check-local: test-qcdm
|
|
||||||
$(abs_builddir)/test-qcdm
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
if WITH_TESTS
|
include $(top_srcdir)/gtester.make
|
||||||
|
|
||||||
|
noinst_PROGRAMS = test-wmc
|
||||||
|
TEST_PROGS += $(noinst_PROGRAMS)
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
-I$(top_srcdir)/libwmc/src \
|
-I$(top_srcdir)/libwmc/src \
|
||||||
-I$(top_srcdir)/src
|
-I$(top_srcdir)/src
|
||||||
|
|
||||||
noinst_PROGRAMS = test-wmc
|
|
||||||
|
|
||||||
test_wmc_SOURCES = \
|
test_wmc_SOURCES = \
|
||||||
test-wmc-crc.c \
|
test-wmc-crc.c \
|
||||||
test-wmc-crc.h \
|
test-wmc-crc.h \
|
||||||
@@ -16,10 +17,7 @@ test_wmc_SOURCES = \
|
|||||||
test-wmc-com.c \
|
test-wmc-com.c \
|
||||||
test-wmc-com.h \
|
test-wmc-com.h \
|
||||||
test-wmc.c
|
test-wmc.c
|
||||||
|
test_wmc_CPPFLAGS = $(MM_CFLAGS)
|
||||||
test_wmc_CPPFLAGS = \
|
|
||||||
$(MM_CFLAGS)
|
|
||||||
|
|
||||||
test_wmc_LDADD = $(MM_LIBS)
|
test_wmc_LDADD = $(MM_LIBS)
|
||||||
|
|
||||||
if WMC_STANDALONE
|
if WMC_STANDALONE
|
||||||
@@ -27,9 +25,3 @@ test_wmc_LDADD += $(top_builddir)/src/libwmc.la
|
|||||||
else
|
else
|
||||||
test_wmc_LDADD += $(top_builddir)/libwmc/src/libwmc.la
|
test_wmc_LDADD += $(top_builddir)/libwmc/src/libwmc.la
|
||||||
endif
|
endif
|
||||||
|
|
||||||
check-local: test-wmc
|
|
||||||
$(abs_builddir)/test-wmc
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
include $(top_srcdir)/gtester.make
|
||||||
|
|
||||||
noinst_PROGRAMS = \
|
noinst_PROGRAMS = \
|
||||||
test-modem-helpers \
|
test-modem-helpers \
|
||||||
@@ -10,6 +11,8 @@ if WITH_QMI
|
|||||||
noinst_PROGRAMS += test-modem-helpers-qmi
|
noinst_PROGRAMS += test-modem-helpers-qmi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
TEST_PROGS += $(noinst_PROGRAMS)
|
||||||
|
|
||||||
################
|
################
|
||||||
|
|
||||||
test_modem_helpers_SOURCES = \
|
test_modem_helpers_SOURCES = \
|
||||||
@@ -157,18 +160,3 @@ if WITH_QMI
|
|||||||
test_sms_part_CPPFLAGS += $(QMI_CFLAGS)
|
test_sms_part_CPPFLAGS += $(QMI_CFLAGS)
|
||||||
test_sms_part_LDADD += $(QMI_LIBS)
|
test_sms_part_LDADD += $(QMI_LIBS)
|
||||||
endif
|
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
|
|
||||||
|
Reference in New Issue
Block a user