tests: Add boilerplate to be able to have tests in libosmo-abis

This commit is contained in:
Holger Hans Peter Freyther 2012-10-11 08:05:14 +02:00
parent 84e5cb9b34
commit 5c65e79edc
4 changed files with 61 additions and 0 deletions

6
.gitignore vendored
View File

@ -26,3 +26,9 @@ tests/*_test
.tarball-version
.version
# tests
tests/atconfig
tests/package.m4
tests/testsuite
tests/testsuite.log

View File

@ -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])])

View File

@ -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 $@

12
tests/testsuite.at Normal file
View File

@ -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