Browse Source

Merge from trac153 for ticket #153.

This was also tested by jinmei and and older version by shane and jelte.
A couple Makefile.am's were looked at. There was not a thorough review
of this.

Moved msgq tests to own directory.

Added targets for all known python unittests.
Note this is for those that use the unittest module.
Other tests are ignored for now.

These tests are ran using "make check" even if not built
with gtest.

Some tests are disabled, tickets opened to track the problems.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1762 e5f2f494-b856-4b98-b285-d166d9295462
Jeremy C. Reed 15 years ago
parent
commit
1d35d19b26

+ 10 - 2
configure.ac

@@ -361,16 +361,22 @@ AC_CONFIG_FILES([Makefile
                  src/Makefile
                  src/Makefile
                  src/bin/Makefile
                  src/bin/Makefile
                  src/bin/bind10/Makefile
                  src/bin/bind10/Makefile
+                 src/bin/bind10/tests/Makefile
                  src/bin/cmdctl/Makefile
                  src/bin/cmdctl/Makefile
+                 src/bin/cmdctl/tests/Makefile
                  src/bin/bindctl/Makefile
                  src/bin/bindctl/Makefile
+                 src/bin/bindctl/tests/Makefile
                  src/bin/cfgmgr/Makefile
                  src/bin/cfgmgr/Makefile
                  src/bin/host/Makefile
                  src/bin/host/Makefile
                  src/bin/loadzone/Makefile
                  src/bin/loadzone/Makefile
                  src/bin/msgq/Makefile
                  src/bin/msgq/Makefile
+                 src/bin/msgq/tests/Makefile
                  src/bin/auth/Makefile
                  src/bin/auth/Makefile
                  src/bin/auth/tests/Makefile
                  src/bin/auth/tests/Makefile
                  src/bin/xfrin/Makefile
                  src/bin/xfrin/Makefile
+                 src/bin/xfrin/tests/Makefile
                  src/bin/xfrout/Makefile
                  src/bin/xfrout/Makefile
+                 src/bin/xfrout/tests/Makefile
                  src/bin/usermgr/Makefile
                  src/bin/usermgr/Makefile
                  src/lib/Makefile
                  src/lib/Makefile
                  src/lib/cc/Makefile
                  src/lib/cc/Makefile
@@ -378,7 +384,9 @@ AC_CONFIG_FILES([Makefile
                  src/lib/python/isc/Makefile
                  src/lib/python/isc/Makefile
                  src/lib/python/isc/auth/Makefile
                  src/lib/python/isc/auth/Makefile
                  src/lib/python/isc/cc/Makefile
                  src/lib/python/isc/cc/Makefile
+                 src/lib/python/isc/cc/tests/Makefile
                  src/lib/python/isc/config/Makefile
                  src/lib/python/isc/config/Makefile
+                 src/lib/python/isc/config/tests/Makefile
                  src/lib/config/Makefile
                  src/lib/config/Makefile
                  src/lib/config/tests/Makefile
                  src/lib/config/tests/Makefile
                  src/lib/dns/Makefile
                  src/lib/dns/Makefile
@@ -411,7 +419,7 @@ AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
            src/bin/usermgr/run_b10-cmdctl-usermgr.sh
            src/bin/usermgr/run_b10-cmdctl-usermgr.sh
            src/bin/usermgr/b10-cmdctl-usermgr.py
            src/bin/usermgr/b10-cmdctl-usermgr.py
            src/bin/msgq/msgq.py
            src/bin/msgq/msgq.py
-           src/bin/msgq/msgq_test
+           src/bin/msgq/tests/msgq_test
            src/bin/msgq/run_msgq.sh
            src/bin/msgq/run_msgq.sh
            src/bin/auth/auth.spec.pre
            src/bin/auth/auth.spec.pre
            src/bin/auth/spec_config.h
            src/bin/auth/spec_config.h
@@ -433,7 +441,7 @@ AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
            chmod +x src/bin/loadzone/run_loadzone.sh
            chmod +x src/bin/loadzone/run_loadzone.sh
            chmod +x src/bin/usermgr/run_b10-cmdctl-usermgr.sh
            chmod +x src/bin/usermgr/run_b10-cmdctl-usermgr.sh
            chmod +x src/bin/msgq/run_msgq.sh
            chmod +x src/bin/msgq/run_msgq.sh
-           chmod +x src/bin/msgq/msgq_test
+           chmod +x src/bin/msgq/tests/msgq_test
            chmod +x src/lib/dns/gen-rdatacode.py
            chmod +x src/lib/dns/gen-rdatacode.py
            chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
            chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
           ])
           ])

+ 4 - 2
src/bin/bind10/Makefile.am

@@ -1,5 +1,7 @@
+SUBDIRS = tests
+
 sbin_SCRIPTS = bind10
 sbin_SCRIPTS = bind10
-CLEANFILES = bind10
+CLEANFILES = bind10 bind10.pyc
 
 
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 
 
@@ -8,7 +10,7 @@ bind10_DATA = bob.spec
 EXTRA_DIST = bob.spec
 EXTRA_DIST = bob.spec
 
 
 man_MANS = bind10.8
 man_MANS = bind10.8
-EXTRA_DIST += $(man_MANS) bind10.xml tests/bind10_test.py
+EXTRA_DIST += $(man_MANS) bind10.xml
 
 
 if ENABLE_MAN
 if ENABLE_MAN
 
 

+ 12 - 0
src/bin/bind10/tests/Makefile.am

@@ -0,0 +1,12 @@
+PYTESTS = bind10_test.py
+EXTRA_DIST = $(PYTESTS)
+
+# later will have configure option to choose this, like: coverage run --branch
+PYCOVERAGE = $(PYTHON)
+# test using command-line arguments, so use check-local target instead of TESTS
+check-local:
+	for pytest in $(PYTESTS) ; do \
+	echo Running test: $$pytest ; \
+	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/bin/bind10 \
+	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
+	done

+ 2 - 1
src/bin/bindctl/Makefile.am

@@ -1,3 +1,5 @@
+SUBDIRS = tests
+
 bin_SCRIPTS = bindctl
 bin_SCRIPTS = bindctl
 man_MANS = bindctl.1
 man_MANS = bindctl.1
 
 
@@ -9,7 +11,6 @@ pythondir = $(pyexecdir)/bindctl
 bindctldir = $(DESTDIR)$(pkgdatadir)
 bindctldir = $(DESTDIR)$(pkgdatadir)
 bindctl_DATA = bindctl.pem
 bindctl_DATA = bindctl.pem
 EXTRA_DIST += bindctl.pem
 EXTRA_DIST += bindctl.pem
-EXTRA_DIST += tests/bindctl_test.py
 
 
 CLEANFILES = bindctl
 CLEANFILES = bindctl
 
 

+ 12 - 0
src/bin/bindctl/tests/Makefile.am

@@ -0,0 +1,12 @@
+PYTESTS = bindctl_test.py
+EXTRA_DIST = $(PYTESTS)
+
+# later will have configure option to choose this, like: coverage run --branch
+PYCOVERAGE = $(PYTHON)
+# test using command-line arguments, so use check-local target instead of TESTS
+check-local:
+	for pytest in $(PYTESTS) ; do \
+	echo Running test: $$pytest ; \
+	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_srcdir)/src/bin \
+	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
+	done

+ 2 - 1
src/bin/cmdctl/Makefile.am

@@ -1,3 +1,5 @@
+SUBDIRS = tests
+
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 
 
 pkglibexec_SCRIPTS = b10-cmdctl
 pkglibexec_SCRIPTS = b10-cmdctl
@@ -16,7 +18,6 @@ b10_cmdctl_DATA += cmdctl.spec
  
  
 EXTRA_DIST = $(CMDCTL_CONFIGURATIONS)
 EXTRA_DIST = $(CMDCTL_CONFIGURATIONS)
 EXTRA_DIST += cmdctl.spec
 EXTRA_DIST += cmdctl.spec
-EXTRA_DIST += tests/cmdctl_test.py
 
 
 CLEANFILES=	b10-cmdctl
 CLEANFILES=	b10-cmdctl
 
 

+ 14 - 0
src/bin/cmdctl/tests/Makefile.am

@@ -0,0 +1,14 @@
+PYTESTS = cmdctl_test.py
+EXTRA_DIST = $(PYTESTS)
+
+### # exclude for now because it fails
+###
+#### later will have configure option to choose this, like: coverage run --branch
+###PYCOVERAGE = $(PYTHON)
+#### test using command-line arguments, so use check-local target instead of TESTS
+###check-local:
+###	for pytest in $(PYTESTS) ; do \
+###	echo Running test: $$pytest ; \
+###	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_srcdir)/src/bin/cmdctl \
+###	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
+###	done

+ 4 - 2
src/bin/msgq/Makefile.am

@@ -1,11 +1,13 @@
+SUBDIRS = tests
+
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 pkglibexecdir = $(libexecdir)/@PACKAGE@
  
  
 pkglibexec_SCRIPTS = b10-msgq
 pkglibexec_SCRIPTS = b10-msgq
 
 
-CLEANFILES = b10-msgq
+CLEANFILES = b10-msgq msgq.pyc
 
 
 man_MANS = b10-msgq.8
 man_MANS = b10-msgq.8
-EXTRA_DIST = $(man_MANS) msgq.xml msgq_test.py
+EXTRA_DIST = $(man_MANS) msgq.xml
 
 
 if ENABLE_MAN
 if ENABLE_MAN
 
 

+ 13 - 0
src/bin/msgq/tests/Makefile.am

@@ -0,0 +1,13 @@
+PYTESTS = msgq_test.py
+EXTRA_DIST = $(PYTESTS)
+
+# later will have configure option to choose this, like: coverage run --branch
+PYCOVERAGE = $(PYTHON)
+# test using command-line arguments, so use check-local target instead of TESTS
+check-local:
+	for pytest in $(PYTESTS) ; do \
+	echo Running test: $$pytest ; \
+	env PYTHONPATH=$(abs_top_builddir)/src/bin/msgq:$(abs_top_srcdir)/src/lib/python \
+	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
+	done
+

+ 2 - 2
src/bin/msgq/msgq_test.in

@@ -18,9 +18,9 @@
 PYTHON_EXEC=${PYTHON_EXEC:-@PYTHON@}
 PYTHON_EXEC=${PYTHON_EXEC:-@PYTHON@}
 export PYTHON_EXEC
 export PYTHON_EXEC
 
 
-MYPATH_PATH=@abs_top_srcdir@/src/bin/msgq
+MYPATH_PATH=@abs_top_srcdir@/src/bin/msgq/tests
 
 
-PYTHONPATH=@abs_top_srcdir@/src/lib/python
+PYTHONPATH=@abs_top_srcdir@/src/bin/msgq:@abs_top_srcdir@/src/lib/python
 
 
 export PYTHONPATH
 export PYTHONPATH
 
 

src/bin/msgq/msgq_test.py → src/bin/msgq/tests/msgq_test.py


+ 3 - 2
src/bin/xfrin/Makefile.am

@@ -1,3 +1,5 @@
+SUBDIRS = tests
+
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 
 
 pkglibexec_SCRIPTS = b10-xfrin
 pkglibexec_SCRIPTS = b10-xfrin
@@ -5,11 +7,10 @@ pkglibexec_SCRIPTS = b10-xfrin
 b10_xfrindir = $(DESTDIR)$(pkgdatadir)
 b10_xfrindir = $(DESTDIR)$(pkgdatadir)
 b10_xfrin_DATA = xfrin.spec
 b10_xfrin_DATA = xfrin.spec
 
 
-CLEANFILES = b10-xfrin xfrin.spec
+CLEANFILES = b10-xfrin xfrin.pyc xfrin.spec
 
 
 man_MANS = b10-xfrin.8
 man_MANS = b10-xfrin.8
 EXTRA_DIST = $(man_MANS) b10-xfrin.xml
 EXTRA_DIST = $(man_MANS) b10-xfrin.xml
-EXTRA_DIST += tests/xfrin_test.py
 
 
 if ENABLE_MAN
 if ENABLE_MAN
 
 

+ 16 - 0
src/bin/xfrin/tests/Makefile.am

@@ -0,0 +1,16 @@
+PYTESTS = xfrin_test.py
+EXTRA_DIST = $(PYTESTS)
+
+if HAVE_BOOST_PYTHON
+
+# later will have configure option to choose this, like: coverage run --branch
+PYCOVERAGE = $(PYTHON)
+# test using command-line arguments, so use check-local target instead of TESTS
+check-local:
+	for pytest in $(PYTESTS) ; do \
+	echo Running test: $$pytest ; \
+	env PYTHONPATH=$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/bin/xfrin:$(abs_top_srcdir)/src/lib/python \
+	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
+	done
+
+endif

+ 3 - 3
src/bin/xfrout/Makefile.am

@@ -1,3 +1,5 @@
+SUBDIRS = tests
+
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 pkglibexecdir = $(libexecdir)/@PACKAGE@
 
 
 pkglibexec_SCRIPTS = b10-xfrout
 pkglibexec_SCRIPTS = b10-xfrout
@@ -5,9 +7,7 @@ pkglibexec_SCRIPTS = b10-xfrout
 b10_xfroutdir = $(DESTDIR)$(pkgdatadir)
 b10_xfroutdir = $(DESTDIR)$(pkgdatadir)
 b10_xfrout_DATA = xfrout.spec
 b10_xfrout_DATA = xfrout.spec
 
 
-CLEANFILES=	b10-xfrout xfrout.spec
-
-EXTRA_DIST = tests/xfrout_test.py
+CLEANFILES=	b10-xfrout xfrout.pyc xfrout.spec
 
 
 xfrout.spec: xfrout.spec.pre
 xfrout.spec: xfrout.spec.pre
 	$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" xfrout.spec.pre >$@
 	$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" xfrout.spec.pre >$@

+ 16 - 0
src/bin/xfrout/tests/Makefile.am

@@ -0,0 +1,16 @@
+PYTESTS = xfrout_test.py
+EXTRA_DIST = $(PYTESTS)
+
+if HAVE_BOOST_PYTHON
+
+# later will have configure option to choose this, like: coverage run --branch
+PYCOVERAGE = $(PYTHON)
+# test using command-line arguments, so use check-local target instead of TESTS
+check-local:
+	for pytest in $(PYTESTS) ; do \
+	echo Running test: $$pytest ; \
+	env PYTHONPATH=$(abs_top_builddir)/src/bin/xfrout:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/xfr/.libs \
+	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
+	done
+
+endif

+ 2 - 6
src/lib/python/isc/cc/Makefile.am

@@ -1,9 +1,5 @@
+SUBDIRS = tests
+
 python_PYTHON =	__init__.py data.py session.py message.py
 python_PYTHON =	__init__.py data.py session.py message.py
 
 
 pythondir = $(pyexecdir)/isc/cc
 pythondir = $(pyexecdir)/isc/cc
-
-EXTRA_DIST =  tests/data_test.py
-EXTRA_DIST += tests/sendcmd.py
-EXTRA_DIST += tests/session_test.py
-EXTRA_DIST += tests/test.py
-EXTRA_DIST += tests/test_session.py

+ 19 - 0
src/lib/python/isc/cc/tests/Makefile.am

@@ -0,0 +1,19 @@
+# NOTE: test.py remove since is broken. See ticket #156
+PYTESTS = data_test.py session_test.py
+# NOTE: test_session.py is to be run manually, so not automated.
+EXTRA_DIST = $(PYTESTS)
+EXTRA_DIST += sendcmd.py
+EXTRA_DIST += test_session.py
+
+# TODO: remove this when readded to PYTESTS
+EXTRA_DIST += test.py
+
+# later will have configure option to choose this, like: coverage run --branch
+PYCOVERAGE = $(PYTHON)
+# test using command-line arguments, so use check-local target instead of TESTS
+check-local:
+	for pytest in $(PYTESTS) ; do \
+	echo Running test: $$pytest ; \
+	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python \
+	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
+	done

+ 2 - 6
src/lib/python/isc/config/Makefile.am

@@ -1,9 +1,5 @@
+SUBDIRS = tests
+
 python_PYTHON = __init__.py ccsession.py cfgmgr.py config_data.py module_spec.py
 python_PYTHON = __init__.py ccsession.py cfgmgr.py config_data.py module_spec.py
 
 
 pythondir = $(pyexecdir)/isc/config
 pythondir = $(pyexecdir)/isc/config
-
-EXTRA_DIST = tests/ccsession_test.py
-EXTRA_DIST += tests/cfgmgr_test.py
-EXTRA_DIST += tests/config_data_test.py
-EXTRA_DIST += tests/module_spec_test.py
-EXTRA_DIST += tests/unittest_fakesession.py

+ 15 - 0
src/lib/python/isc/config/tests/Makefile.am

@@ -0,0 +1,15 @@
+PYTESTS = ccsession_test.py cfgmgr_test.py config_data_test.py
+PYTESTS += module_spec_test.py
+EXTRA_DIST = $(PYTESTS)
+EXTRA_DIST += unittest_fakesession.py
+
+# later will have configure option to choose this, like: coverage run --branch
+PYCOVERAGE = $(PYTHON)
+# test using command-line arguments, so use check-local target instead of TESTS
+check-local:
+	for pytest in $(PYTESTS) ; do \
+	echo Running test: $$pytest ; \
+	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python \
+	CONFIG_TESTDATA_PATH=$(abs_top_srcdir)/src/lib/config/testdata \
+	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
+	done