Skip to content

Commit

Permalink
Use Autotest for the Open vSwitch test suite.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
blp committed Jul 29, 2009
1 parent baa905d commit 1b233b9
Show file tree
Hide file tree
Showing 24 changed files with 408 additions and 294 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/depcomp
/install-sh
/missing
/package.m4
/stamp-h1
Module.symvers
TAGS
Expand Down
2 changes: 0 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ EXTRA_DIST = INSTALL.bridge \
INSTALL.OpenFlow \
INSTALL.SSL \
INSTALL.XenServer
TESTS =
TESTS_ENVIRONMENT =
bin_PROGRAMS =
sbin_PROGRAMS =
bin_SCRIPTS =
Expand Down
6 changes: 4 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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, [email protected])
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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/test-list
/test-stp
/test-type-props
/testsuite
2 changes: 2 additions & 0 deletions tests/atlocal.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- shell-script -*-
PERL='@PERL@'
68 changes: 38 additions & 30 deletions tests/automake.mk
Original file line number Diff line number Diff line change
@@ -1,71 +1,79 @@
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

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)
Expand Down
39 changes: 39 additions & 0 deletions tests/library.at
Original file line number Diff line number Diff line change
@@ -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 <flows 3<pcap], [0], [checked 247 packets, 0 errors
])
AT_CLEANUP

AT_SETUP([test TCP/IP checksumming])
AT_CHECK([test-csum], [0], [ignore])
AT_CLEANUP

AT_SETUP([test flow classifier])
AT_CHECK([test-classifier], [0], [ignore])
AT_CLEANUP

AT_SETUP([test hash functions])
AT_CHECK([test-hash], [0], [ignore])
AT_CLEANUP

AT_SETUP([test hash map])
AT_CHECK([test-hmap], [0], [ignore])
AT_CLEANUP

AT_SETUP([test linked lists])
AT_CHECK([test-list], [0], [ignore])
AT_CLEANUP

AT_SETUP([test SHA-1])
AT_CHECK([test-sha1], [0], [ignore])
AT_CLEANUP

AT_SETUP([test type properties])
AT_CHECK([test-type-props], [0], [ignore])
AT_CLEANUP

AT_SETUP([test vconn library])
AT_CHECK([test-vconn], [0], [ignore])
AT_CLEANUP
Loading

0 comments on commit 1b233b9

Please sign in to comment.