From 1b233b95b5907a242ee453cbea3ad4bc4cd4fec2 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 27 Jul 2009 16:40:11 -0700 Subject: [PATCH] Use Autotest for the Open vSwitch test suite. Autotest doesn't provide a lot of benefit by itself but it does allow us to easily put a wrapper around each test by using a macro to invoke it. (To do that with the built-in Automake test framework you need to write or generate a separate wrapper script for each test, which is a pain.) The next commit will take advantage of this possibility by adding support for code coverage analysis. --- .gitignore | 1 + Makefile.am | 2 - configure.ac | 6 +- tests/.gitignore | 1 + tests/atlocal.in | 2 + tests/automake.mk | 68 +++--- tests/library.at | 39 ++++ tests/stp.at | 303 +++++++++++++++++++++++++ tests/test-flows.sh | 24 -- tests/test-stp-ieee802.1d-1998 | 12 - tests/test-stp-ieee802.1d-2004-fig17.4 | 31 --- tests/test-stp-ieee802.1d-2004-fig17.6 | 14 -- tests/test-stp-ieee802.1d-2004-fig17.7 | 17 -- tests/test-stp-iol-io-1.1 | 25 -- tests/test-stp-iol-io-1.2 | 14 -- tests/test-stp-iol-io-1.4 | 13 -- tests/test-stp-iol-io-1.5 | 40 ---- tests/test-stp-iol-op-1.1 | 7 - tests/test-stp-iol-op-1.4 | 8 - tests/test-stp-iol-op-3.1 | 11 - tests/test-stp-iol-op-3.3 | 11 - tests/test-stp-iol-op-3.4 | 11 - tests/test-stp.sh | 22 -- tests/testsuite.at | 20 ++ 24 files changed, 408 insertions(+), 294 deletions(-) create mode 100644 tests/atlocal.in create mode 100644 tests/library.at create mode 100644 tests/stp.at delete mode 100755 tests/test-flows.sh delete mode 100644 tests/test-stp-ieee802.1d-1998 delete mode 100644 tests/test-stp-ieee802.1d-2004-fig17.4 delete mode 100644 tests/test-stp-ieee802.1d-2004-fig17.6 delete mode 100644 tests/test-stp-ieee802.1d-2004-fig17.7 delete mode 100644 tests/test-stp-iol-io-1.1 delete mode 100644 tests/test-stp-iol-io-1.2 delete mode 100644 tests/test-stp-iol-io-1.4 delete mode 100644 tests/test-stp-iol-io-1.5 delete mode 100644 tests/test-stp-iol-op-1.1 delete mode 100644 tests/test-stp-iol-op-1.4 delete mode 100644 tests/test-stp-iol-op-3.1 delete mode 100644 tests/test-stp-iol-op-3.3 delete mode 100644 tests/test-stp-iol-op-3.4 delete mode 100755 tests/test-stp.sh create mode 100644 tests/testsuite.at diff --git a/.gitignore b/.gitignore index 480615ac9..3230266c4 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ /depcomp /install-sh /missing +/package.m4 /stamp-h1 Module.symvers TAGS diff --git a/Makefile.am b/Makefile.am index 1b40cdea9..dccb8cfdf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,8 +32,6 @@ EXTRA_DIST = INSTALL.bridge \ INSTALL.OpenFlow \ INSTALL.SSL \ INSTALL.XenServer -TESTS = -TESTS_ENVIRONMENT = bin_PROGRAMS = sbin_PROGRAMS = bin_SCRIPTS = diff --git a/configure.ac b/configure.ac index 27f9da544..162814639 100644 --- a/configure.ac +++ b/configure.ac @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -AC_PREREQ(2.60) +AC_PREREQ(2.63) AC_INIT(openvswitch, 0.90.3, bugs@openvswitch.org) NX_BUILDNR AC_CONFIG_SRCDIR([datapath/datapath.c]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_TESTDIR([tests]) AM_INIT_AUTOMAKE AC_PROG_CC @@ -84,6 +85,7 @@ AC_CONFIG_FILES([Makefile datapath/Makefile datapath/linux-2.6/Kbuild datapath/linux-2.6/Makefile -datapath/linux-2.6/Makefile.main]) +datapath/linux-2.6/Makefile.main +tests/atlocal]) AC_OUTPUT diff --git a/tests/.gitignore b/tests/.gitignore index 111250351..706aa1474 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -8,3 +8,4 @@ /test-list /test-stp /test-type-props +/testsuite diff --git a/tests/atlocal.in b/tests/atlocal.in new file mode 100644 index 000000000..1328d4a48 --- /dev/null +++ b/tests/atlocal.in @@ -0,0 +1,2 @@ +# -*- shell-script -*- +PERL='@PERL@' diff --git a/tests/automake.mk b/tests/automake.mk index e25131739..6dc109d60 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -1,40 +1,68 @@ -TESTS += tests/test-classifier +EXTRA_DIST += \ + $(TESTSUITE_AT) \ + $(TESTSUITE) \ + tests/atlocal.in \ + $(srcdir)/package.m4 \ + $(srcdir)/tests/testsuite +TESTSUITE_AT = \ + tests/testsuite.at \ + tests/library.at \ + tests/stp.at +TESTSUITE = $(srcdir)/tests/testsuite +DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE) + +check-local: tests/atconfig tests/atlocal $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH='utilities:vswitchd:tests' $(TESTSUITEFLAGS) + +clean-local: + test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' -C tests --clean + +AUTOM4TE = autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): package.m4 $(TESTSUITE_AT) + $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at + mv $@.tmp $@ + +# 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], [@PACKAGE_NAME@])' && \ + echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])' && \ + echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])' && \ + echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])' && \ + echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ + } >'$(srcdir)/package.m4' + noinst_PROGRAMS += tests/test-classifier tests_test_classifier_SOURCES = tests/test-classifier.c tests_test_classifier_LDADD = lib/libopenvswitch.a -TESTS += tests/test-csum noinst_PROGRAMS += tests/test-csum tests_test_csum_SOURCES = tests/test-csum.c tests_test_csum_LDADD = lib/libopenvswitch.a -TESTS += tests/test-flows.sh noinst_PROGRAMS += tests/test-flows tests_test_flows_SOURCES = tests/test-flows.c tests_test_flows_LDADD = lib/libopenvswitch.a -dist_check_SCRIPTS = tests/test-flows.sh tests/flowgen.pl +dist_check_SCRIPTS = tests/flowgen.pl -TESTS += tests/test-hash noinst_PROGRAMS += tests/test-hash tests_test_hash_SOURCES = tests/test-hash.c tests_test_hash_LDADD = lib/libopenvswitch.a -TESTS += tests/test-hmap noinst_PROGRAMS += tests/test-hmap tests_test_hmap_SOURCES = tests/test-hmap.c tests_test_hmap_LDADD = lib/libopenvswitch.a -TESTS += tests/test-list noinst_PROGRAMS += tests/test-list tests_test_list_SOURCES = tests/test-list.c tests_test_list_LDADD = lib/libopenvswitch.a -TESTS += tests/test-sha1 noinst_PROGRAMS += tests/test-sha1 tests_test_sha1_SOURCES = tests/test-sha1.c tests_test_sha1_LDADD = lib/libopenvswitch.a -TESTS += tests/test-type-props noinst_PROGRAMS += tests/test-type-props tests_test_type_props_SOURCES = tests/test-type-props.c @@ -42,30 +70,10 @@ noinst_PROGRAMS += tests/test-dhcp-client tests_test_dhcp_client_SOURCES = tests/test-dhcp-client.c tests_test_dhcp_client_LDADD = lib/libopenvswitch.a $(FAULT_LIBS) -TESTS += tests/test-stp.sh -EXTRA_DIST += tests/test-stp.sh noinst_PROGRAMS += tests/test-stp - tests_test_stp_SOURCES = tests/test-stp.c tests_test_stp_LDADD = lib/libopenvswitch.a -stp_files = \ - tests/test-stp-ieee802.1d-1998 \ - tests/test-stp-ieee802.1d-2004-fig17.4 \ - tests/test-stp-ieee802.1d-2004-fig17.6 \ - tests/test-stp-ieee802.1d-2004-fig17.7 \ - tests/test-stp-iol-op-1.1 \ - tests/test-stp-iol-op-1.4 \ - tests/test-stp-iol-op-3.1 \ - tests/test-stp-iol-op-3.3 \ - tests/test-stp-iol-io-1.1 \ - tests/test-stp-iol-io-1.2 \ - tests/test-stp-iol-io-1.4 \ - tests/test-stp-iol-io-1.5 -TESTS_ENVIRONMENT += stp_files='$(stp_files)' - -EXTRA_DIST += $(stp_files) - -TESTS += tests/test-vconn + noinst_PROGRAMS += tests/test-vconn tests_test_vconn_SOURCES = tests/test-vconn.c tests_test_vconn_LDADD = lib/libopenvswitch.a $(SSL_LIBS) diff --git a/tests/library.at b/tests/library.at new file mode 100644 index 000000000..c70324185 --- /dev/null +++ b/tests/library.at @@ -0,0 +1,39 @@ +AT_BANNER([library unit tests]) + +AT_SETUP([test flow extractor]) +AT_CHECK([$PERL `which flowgen.pl` >/dev/null 3>flows 4>pcap]) +AT_CHECK([test-flows /dev/null 3>flows$$ 4>pcap$$ -./test-flows out$$ || true -diff -u - out$$ <