[aravis] tests: add glib testing support.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] tests: add glib testing support.
- Date: Sun, 25 Apr 2010 21:12:46 +0000 (UTC)
commit 1411ec6306fc71026ed10ca3b17e2b6bfcb78ecf
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Sun Apr 25 23:12:14 2010 +0200
tests: add glib testing support.
.gitignore | 1 +
Makefile.am | 4 ++-
Makefile.decl | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 1 +
gst/Makefile.am | 2 +
src/Makefile.am | 8 +++++-
src/tests/.gitignore | 1 +
src/tests/Makefile.am | 9 +++++++
src/tests/formula.c | 27 ++++++++++++++++++++++
9 files changed, 108 insertions(+), 3 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index c2268c4..18c5a47 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,4 @@ tmp-introspect*
make*.out
genicam.xml
test.png
+test-report.*
diff --git a/Makefile.am b/Makefile.am
index ba93c6f..b6bd66d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,5 @@
+include $(top_srcdir)/Makefile.decl
+
ACLOCAL_AMFLAGS = -I m4
DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
@@ -13,7 +15,7 @@ aravisdoc_DATA = \
INSTALL \
NEWS
-EXTRA_DIST = $(aravisdoc_DATA) m4/introspection.m4
+EXTRA_DIST += $(aravisdoc_DATA) m4/introspection.m4
# Copy all the spec files. Of cource, only one is actually used.
dist-hook:
diff --git a/Makefile.decl b/Makefile.decl
new file mode 100644
index 0000000..4c14ff8
--- /dev/null
+++ b/Makefile.decl
@@ -0,0 +1,58 @@
+# GLIB - Library of useful C routines
+
+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_PROGS}
+ @test -z "${TEST_PROGS}" || ${GTESTER} --verbose ${TEST_PROGS}
+ @ for subdir in $(SUBDIRS) . ; do \
+ test "$$subdir" = "." -o "$$subdir" = "po" || \
+ ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
+ done
+
+# 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 ; \
+ 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 ; \
+ 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
+# run make test as part of make check
+check-local: test
diff --git a/configure.ac b/configure.ac
index 4896b13..a95c588 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,7 @@ GOBJECT_INTROSPECTION_CHECK([0.6.7])
AC_CONFIG_FILES([
Makefile
src/Makefile
+src/tests/Makefile
gst/Makefile
po/Makefile.in
aravis.pc
diff --git a/gst/Makefile.am b/gst/Makefile.am
index 0f8335f..4b33e0e 100644
--- a/gst/Makefile.am
+++ b/gst/Makefile.am
@@ -1,3 +1,5 @@
+include $(top_srcdir)/Makefile.decl
+
INCLUDES = \
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
diff --git a/src/Makefile.am b/src/Makefile.am
index fce54e2..1871e89 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,3 +1,7 @@
+include $(top_srcdir)/Makefile.decl
+
+SUBDIRS = tests
+
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
@@ -15,8 +19,8 @@ lib_LTLIBRARIES = libaravis.la
BUILT_SOURCES = arvenumtypes.h arvenumtypes.c
-EXTRA_DIST = arvenumtypes.h.template \
- arvenumtypes.c.template
+EXTRA_DIST += arvenumtypes.h.template \
+ arvenumtypes.c.template
libaravis_la_LIBADD = \
$(ARAVIS_LIBS)
diff --git a/src/tests/.gitignore b/src/tests/.gitignore
new file mode 100644
index 0000000..e7ee66b
--- /dev/null
+++ b/src/tests/.gitignore
@@ -0,0 +1 @@
+formula
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
new file mode 100644
index 0000000..3e79321
--- /dev/null
+++ b/src/tests/Makefile.am
@@ -0,0 +1,9 @@
+include $(top_srcdir)/Makefile.decl
+
+INCLUDES = $(ARAVIS_CFLAGS)
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+TEST_PROGS += formula
+formula_SOURCES = formula.c
+formula_LDADD = $(ARAVIS_LIBS) $(top_srcdir)/src/libaravis.la
diff --git a/src/tests/formula.c b/src/tests/formula.c
new file mode 100644
index 0000000..1b75020
--- /dev/null
+++ b/src/tests/formula.c
@@ -0,0 +1,27 @@
+#include <glib.h>
+#include <arv.h>
+
+static void
+test_int (void)
+{
+ ArvCamera *camera;
+
+ camera = arv_camera_new (NULL);
+ if (camera != NULL)
+ g_object_unref (camera);
+
+ g_assert (TRUE);
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_type_init ();
+
+ g_test_add_func ("/formula/test_int", test_int);
+
+ return g_test_run();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]