aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-10-11 08:05:14 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-10-11 08:18:43 +0200
commit5c65e79edcbf220b0422151e08547ca796a44221 (patch)
tree8312a65c0603ff565c043c90f29c5171aad8e196
parent84e5cb9b3496527d43af974f2f89396d8145d743 (diff)
tests: Add boilerplate to be able to have tests in libosmo-abis
-rw-r--r--.gitignore6
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am42
-rw-r--r--tests/testsuite.at12
4 files changed, 61 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 50320dd..b1f44cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,3 +26,9 @@ tests/*_test
.tarball-version
.version
+
+# tests
+tests/atconfig
+tests/package.m4
+tests/testsuite
+tests/testsuite.log
diff --git a/configure.ac b/configure.ac
index fdaf15a..8b4014a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,6 +3,7 @@ AC_INIT([libosmo-abis],
[openbsc@lists.osmocom.org])
AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip 1.6])
+AC_CONFIG_TESTDIR(tests)
dnl kernel style compile messages
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 640f4ef..724285c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,3 +28,45 @@ ipa_proxy_test_SOURCES = ipa_proxy_test.c
ipa_proxy_test_LDADD = $(top_builddir)/src/libosmoabis.la \
$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) \
$(LIBOSMOVTY_LIBS)
+
+
+# boilerplate for the tests
+# The `:;' works around a Bash 3.2 bug when the output is not writeable.
+$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+ :;{ \
+ echo '# Signature of the current package.' && \
+ echo 'm4_define([AT_PACKAGE_NAME],' && \
+ echo ' [$(PACKAGE_NAME)])' && \
+ echo 'm4_define([AT_PACKAGE_TARNAME],' && \
+ echo ' [$(PACKAGE_TARNAME)])' && \
+ echo 'm4_define([AT_PACKAGE_VERSION],' && \
+ echo ' [$(PACKAGE_VERSION)])' && \
+ echo 'm4_define([AT_PACKAGE_STRING],' && \
+ echo ' [$(PACKAGE_STRING)])' && \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \
+ echo ' [$(PACKAGE_BUGREPORT)])'; \
+ echo 'm4_define([AT_PACKAGE_URL],' && \
+ echo ' [$(PACKAGE_URL)])'; \
+ } >'$(srcdir)/package.m4'
+
+EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE)
+
+TESTSUITE = $(srcdir)/testsuite
+
+check-local: atconfig $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
+
+installcheck-local: atconfig $(TESTSUITE)
+ $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \
+ $(TESTSUITEFLAGS)
+
+clean-local:
+ test ! -f '$(TESTSUITE)' || \
+ $(SHELL) '$(TESTSUITE)' --clean
+ $(RM) -f atconfig
+
+AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te
+AUTOTEST = $(AUTOM4TE) --language=autotest
+$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4
+ $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
+ mv $@.tmp $@
diff --git a/tests/testsuite.at b/tests/testsuite.at
new file mode 100644
index 0000000..1358534
--- /dev/null
+++ b/tests/testsuite.at
@@ -0,0 +1,12 @@
+AT_INIT
+AT_BANNER([Regression tests.])
+
+# Example for tests.. copy and uncomment. This creates a new category
+# and test. It will copy the expected output to expout and then run
+# the given test. The stdout will be compared with the expout to determine
+# if the test was successfull.
+# AT_SETUP([NAME])
+# AT_KEYWORDS([NAME])
+# cat $abs_srcdir/NAME/NAME_test.ok > expout
+# AT_CHECK([$abs_top_builddir/tests/NAME/NAME_test], [], [expout])
+# AT_CLEANUP