Commit fd120575 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

sync with trunk


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac313@2780 e5f2f494-b856-4b98-b285-d166d9295462
parents e99f46c6 261c1bec
89. [build] jinmei
Generate b10-config.db for tests at build time so that the source
tree does not have to be writable. (Trac #315, r2776)
88. [func] jelte
Blocking reads on the msgq command channel now have a timeout
(defaults to 4 seconds, modifiable as needed by modules).
......
......@@ -449,6 +449,7 @@ AC_CONFIG_FILES([Makefile
src/lib/python/isc/notify/tests/Makefile
src/lib/config/Makefile
src/lib/config/tests/Makefile
src/lib/config/testdata/Makefile
src/lib/dns/Makefile
src/lib/dns/tests/Makefile
src/lib/dns/python/Makefile
......
......@@ -559,7 +559,7 @@ def raise_interrupt():
def raise_ccerror():
raise isc.cc.session.SessionError('test error')
def raise_excpetion():
def raise_exception():
raise Exception('test exception')
class TestMain(unittest.TestCase):
......@@ -581,7 +581,7 @@ class TestMain(unittest.TestCase):
main(MockXfrin, False)
def test_startup_generalerror(self):
MockXfrin.check_command_hook = raise_excpetion
MockXfrin.check_command_hook = raise_exception
main(MockXfrin, False)
if __name__== "__main__":
......
SUBDIRS = . tests
SUBDIRS = . testdata tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
......@@ -13,7 +13,7 @@ EXTRA_DIST = testdata/b10-config-bad1.db
EXTRA_DIST += testdata/b10-config-bad2.db
EXTRA_DIST += testdata/b10-config-bad3.db
EXTRA_DIST += testdata/b10-config-bad4.db
EXTRA_DIST += testdata/b10-config.db
EXTRA_DIST += testdata/b10-config.db.master #.db will be auto-generated
EXTRA_DIST += testdata/data22_1.data
EXTRA_DIST += testdata/data22_2.data
EXTRA_DIST += testdata/data22_3.data
......
CLEANFILES = b10-config.db
BUILT_SOURCES = b10-config.db
# cfgmgr_test (under lib/python) will override b10-config.db, so we make a
# writable copy in the builddir.
b10-config.db: b10-config.db.master
cp $(srcdir)/b10-config.db.master $@
......@@ -7,9 +7,12 @@ EXTRA_DIST += unittest_fakesession.py
PYCOVERAGE = $(PYTHON)
# test using command-line arguments, so use check-local target instead of TESTS
check-local:
ret=0 ; \
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python \
CONFIG_TESTDATA_PATH=$(abs_top_srcdir)/src/lib/config/testdata \
$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
done
CONFIG_WR_TESTDATA_PATH=$(abs_top_builddir)/src/lib/config/testdata \
$(PYCOVERAGE) $(abs_srcdir)/$$pytest || ret=1; \
done; \
exit $$ret
......@@ -28,19 +28,20 @@ from unittest_fakesession import FakeModuleCCSession
class TestConfigManagerData(unittest.TestCase):
def setUp(self):
self.data_path = os.environ['CONFIG_TESTDATA_PATH']
self.config_manager_data = ConfigManagerData(self.data_path)
self.writable_data_path = os.environ['CONFIG_WR_TESTDATA_PATH']
self.config_manager_data = ConfigManagerData(self.writable_data_path)
self.assert_(self.config_manager_data)
def test_init(self):
self.assertEqual(self.config_manager_data.data['version'],
config_data.BIND10_CONFIG_DATA_VERSION)
self.assertEqual(self.config_manager_data.data_path,
self.data_path)
self.writable_data_path)
self.assertEqual(self.config_manager_data.db_filename,
self.data_path + os.sep + "b10-config.db")
self.writable_data_path + os.sep + "b10-config.db")
def test_read_from_file(self):
ConfigManagerData.read_from_file(self.data_path)
ConfigManagerData.read_from_file(self.writable_data_path)
self.assertRaises(ConfigManagerDataEmpty,
ConfigManagerData.read_from_file,
"doesnotexist")
......@@ -84,14 +85,15 @@ class TestConfigManager(unittest.TestCase):
def setUp(self):
self.data_path = os.environ['CONFIG_TESTDATA_PATH']
self.writable_data_path = os.environ['CONFIG_WR_TESTDATA_PATH']
self.fake_session = FakeModuleCCSession()
self.cm = ConfigManager(self.data_path, self.fake_session)
self.cm = ConfigManager(self.writable_data_path, self.fake_session)
self.name = "TestModule"
self.spec = isc.config.module_spec_from_file(self.data_path + os.sep + "/spec2.spec")
def test_init(self):
self.assert_(self.cm.module_specs == {})
self.assert_(self.cm.data_path == self.data_path)
self.assert_(self.cm.data_path == self.writable_data_path)
self.assert_(self.cm.config != None)
self.assert_(self.fake_session.has_subscription("ConfigManager"))
self.assert_(self.fake_session.has_subscription("Boss", "ConfigManager"))
......@@ -293,8 +295,8 @@ class TestConfigManager(unittest.TestCase):
if __name__ == '__main__':
if not 'CONFIG_TESTDATA_PATH' in os.environ:
print("You need to set the environment variable CONFIG_TESTDATA_PATH to point to the directory containing the test data files")
if not 'CONFIG_TESTDATA_PATH' in os.environ or not 'CONFIG_WR_TESTDATA_PATH' in os.environ:
print("You need to set the environment variable CONFIG_TESTDATA_PATH and CONFIG_WR_TESTDATA_PATH to point to the directory containing the test data files")
exit(1)
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment