diff --git a/configure.ac b/configure.ac index 173555297c..15559a46d3 100644 --- a/configure.ac +++ b/configure.ac @@ -433,6 +433,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 diff --git a/src/lib/config/Makefile.am b/src/lib/config/Makefile.am index 28278e1945..174a030445 100644 --- a/src/lib/config/Makefile.am +++ b/src/lib/config/Makefile.am @@ -1,4 +1,4 @@ -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 diff --git a/src/lib/config/testdata/Makefile.am b/src/lib/config/testdata/Makefile.am new file mode 100644 index 0000000000..4aa348a87a --- /dev/null +++ b/src/lib/config/testdata/Makefile.am @@ -0,0 +1,8 @@ +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 $< $@ diff --git a/src/lib/config/testdata/b10-config.db b/src/lib/config/testdata/b10-config.db.master similarity index 100% rename from src/lib/config/testdata/b10-config.db rename to src/lib/config/testdata/b10-config.db.master diff --git a/src/lib/python/isc/config/tests/Makefile.am b/src/lib/python/isc/config/tests/Makefile.am index 18d378b15b..9fb36aee5f 100644 --- a/src/lib/python/isc/config/tests/Makefile.am +++ b/src/lib/python/isc/config/tests/Makefile.am @@ -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 diff --git a/src/lib/python/isc/config/tests/cfgmgr_test.py b/src/lib/python/isc/config/tests/cfgmgr_test.py index 819a29c07d..849c7da854 100644 --- a/src/lib/python/isc/config/tests/cfgmgr_test.py +++ b/src/lib/python/isc/config/tests/cfgmgr_test.py @@ -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()