From 0b4b824887db23fb3b922286c3229be75393a92d Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 8 Sep 2016 15:09:16 +0200 Subject: tests: Enable the vty tests for the osmo-pcap as well Change-Id: I1704e0d58a04770a3aac1f70f3e01ee9ac585dbf --- .gitignore | 7 +++++++ Makefile.am | 2 +- configure.ac | 16 ++++++++++++++++ contrib/travis.sh | 9 ++++++++- osmoappdesc.py | 30 ++++++++++++++++++++++++++++++ tests/Makefile.am | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 3 +++ 7 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 osmoappdesc.py create mode 100644 tests/Makefile.am create mode 100644 tests/testsuite.at diff --git a/.gitignore b/.gitignore index 7b12006..7e4da82 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ Makefile Makefile.in *.*~ *.sw? +*.pyc #configure aclocal.m4 @@ -27,3 +28,9 @@ osmopcapconfig.h* # apps src/osmo_pcap_client src/osmo_pcap_server + +# tests +tests/atconfig +tests/package.m4 +tests/testsuite +tests/testsuite.log diff --git a/Makefile.am b/Makefile.am index 196e784..798c092 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 -SUBDIRS = include src contrib +SUBDIRS = include src contrib tests BUILT_SOURCES = $(top_srcdir)/.version EXTRA_DIST = git-version-gen .version diff --git a/configure.ac b/configure.ac index 35b4ee0..fbd1331 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,7 @@ AC_INIT([osmo-pcap], [openbsc-devel@lists.openbsc.org]) AM_INIT_AUTOMAKE([dist-bzip2]) +AC_CONFIG_TESTDIR(tests) dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -17,6 +18,20 @@ AC_PROG_RANLIB dnl checks for header files AC_HEADER_STDC +AC_ARG_ENABLE([external_tests], + AC_HELP_STRING([--enable-external-tests], + [Include the VTY tests in make check [default=no]]), + [enable_ext_tests="$enableval"],[enable_ext_tests="no"]) +if test "x$enable_ext_tests" = "xyes" ; then + AM_PATH_PYTHON + AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes) + if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then + AC_MSG_ERROR([Please install osmocom-python to run the VTY tests.]) + fi +fi +AC_MSG_CHECKING([whether to enable VTY tests]) +AC_MSG_RESULT([$enable_ext_tests]) +AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes") dnl Checks for typedefs, structures and compiler characteristics AC_ARG_WITH([pcap-config], @@ -72,4 +87,5 @@ AC_OUTPUT( include/osmo-pcap/Makefile src/Makefile contrib/Makefile + tests/Makefile Makefile) diff --git a/contrib/travis.sh b/contrib/travis.sh index 7e73522..4614414 100755 --- a/contrib/travis.sh +++ b/contrib/travis.sh @@ -12,9 +12,16 @@ git reset --hard 460f9ef7da1db11b104fdfe635ebcbd8a071f205 autoreconf --install --force ./configure --prefix=$PWD/../install make -j 4 install +export LD_LIBRARY_PATH=$PWD/../install/lib + +cd ../ +git clone git://git.osmocom.org/python/osmo-python-tests +cd osmo-python-tests +sudo ./setup.py install cd ../../ autoreconf --install --force -PCAP_LIBS="-lpcap" PCAP_CFLAGS="" PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig ./configure --with-pcap-config=/bin/true +PCAP_LIBS="-lpcap" PCAP_CFLAGS="" PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig ./configure --with-pcap-config=/bin/true --enable-external-tests PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig make -j 4 +PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig make check DISTCHECK_CONFIGURE_FLAGS="--with-pcap-config=/bin/true" PCAP_LIBS="-lpcap" PCAP_CFLAGS="" PKG_CONFIG_PATH=$PWD/deps/install/lib/pkgconfig LD_LIBRARY_PATH=$PWD/deps/install/lib make distcheck diff --git a/osmoappdesc.py b/osmoappdesc.py new file mode 100644 index 0000000..fce58fb --- /dev/null +++ b/osmoappdesc.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# (C) 2016 by Holger Hans Peter Freyther +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +app_configs = { + "osmo-pcap-client": ["contrib/osmo-pcap-client.cfg"], + "osmo-pcap-server": ["contrib/osmo-pcap-server.cfg"] +} + +apps = [ + (4241, "src/osmo_pcap_server", "OsmoPCAPServer", "osmo-pcap-server"), + (4240, "src/osmo_pcap_client", "OsmoPCAPClient", "osmo-pcap-client"), + ] + +vty_command = ["src/osmo_pcap_server", "-c", "contrib/osmo-pcap-server.cfg"] +vty_app = apps[0] + + diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..def6e8b --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,49 @@ +# 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 + +if ENABLE_EXT_TESTS +python-tests: $(BUILT_SOURCES) + osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v + osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v +else +python-tests: $(BUILT_SOURCES) + echo "Not running python-based tests (determined at configure-time)" +endif + +check-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) + $(MAKE) $(AM_MAKEFLAGS) python-tests + +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..d928bb6 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,3 @@ +AT_INIT +AT_BANNER([Regression tests.]) + -- cgit v1.2.3