BIND 10 trac875, updated. f80cdaf115a8ad80184240b283b243ac07bb9739 [trac875] Loading of spec file
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed May 11 12:07:31 UTC 2011
The branch, trac875 has been updated
via f80cdaf115a8ad80184240b283b243ac07bb9739 (commit)
via c2693bb84ea22e3b44617d729d8d2e8dbd99c51c (commit)
from 2f25f64f9f7a1021b67b9c37cfca41e86f5ae032 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f80cdaf115a8ad80184240b283b243ac07bb9739
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed May 11 14:07:16 2011 +0200
[trac875] Loading of spec file
commit c2693bb84ea22e3b44617d729d8d2e8dbd99c51c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Wed May 11 13:35:40 2011 +0200
[trac875] Utility to search for file in several dirs
-----------------------------------------------------------------------
Summary of changes:
src/bin/cfgmgr/plugins/Makefile.am | 3 ++
src/bin/cfgmgr/plugins/tests/Makefile.am | 2 +-
src/bin/cfgmgr/plugins/tests/tsig_keys_test.py | 4 +-
src/bin/cfgmgr/plugins/tsig_keys.py | 6 +++-
src/lib/python/bind10_config.py.in | 3 ++
src/lib/python/isc/util/Makefile.am | 2 +-
.../isc/{testutils/parse_args.py => util/file.py} | 21 +++++++--------
src/lib/python/isc/util/tests/Makefile.am | 2 +-
.../parse_args.py => util/tests/file_test.py} | 28 ++++++++++---------
9 files changed, 40 insertions(+), 31 deletions(-)
copy src/lib/python/isc/{testutils/parse_args.py => util/file.py} (64%)
copy src/lib/python/isc/{testutils/parse_args.py => util/tests/file_test.py} (54%)
-----------------------------------------------------------------------
diff --git a/src/bin/cfgmgr/plugins/Makefile.am b/src/bin/cfgmgr/plugins/Makefile.am
index 2a3b506..d49d50d 100644
--- a/src/bin/cfgmgr/plugins/Makefile.am
+++ b/src/bin/cfgmgr/plugins/Makefile.am
@@ -1,2 +1,5 @@
SUBDIRS = tests
EXTRA_DIST = README
+
+# TODO: We need to distribute the .py files and .spec files. We also need to
+# install them. How to do that correctly?
diff --git a/src/bin/cfgmgr/plugins/tests/Makefile.am b/src/bin/cfgmgr/plugins/tests/Makefile.am
index 817a4c9..f8ed7df 100644
--- a/src/bin/cfgmgr/plugins/tests/Makefile.am
+++ b/src/bin/cfgmgr/plugins/tests/Makefile.am
@@ -10,7 +10,7 @@ if ENABLE_PYTHON_COVERAGE
endif
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
- env PLUGIN_DIR=$(abs_srcdir)/.. \
+ env B10_TEST_PLUGIN_DIR=$(abs_srcdir)/..:$(abs_builddir)/.. \
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/cfgmgr \
$(PYCOVERAGE_RUN) $(abs_builddir)/$$pytest || exit ; \
done
diff --git a/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py b/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
index cd6a743..ee38ee6 100644
--- a/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
+++ b/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
@@ -16,7 +16,7 @@
# Make sure we can load the module, put it into path
import sys
import os
-sys.path.append(os.environ["PLUGIN_DIR"])
+sys.path.extend(os.environ["B10_TEST_PLUGIN_DIR"].split(':'))
import tsig_keys
import unittest
@@ -47,7 +47,7 @@ class TSigKeysTest(unittest.TestCase):
# Correct name
self.assertEqual("tsig_keys", spec.get_module_name())
# There are no commands, nobody would handle them anyway
- self.assertEqual({}, spec.get_commands_spec())
+ self.assertEqual([], spec.get_commands_spec())
# There's some nonempty configuration
self.assertNotEqual({}, spec.get_config_spec())
diff --git a/src/bin/cfgmgr/plugins/tsig_keys.py b/src/bin/cfgmgr/plugins/tsig_keys.py
index 78a756c..f3ba881 100644
--- a/src/bin/cfgmgr/plugins/tsig_keys.py
+++ b/src/bin/cfgmgr/plugins/tsig_keys.py
@@ -13,8 +13,10 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-# TODO: Put the real spec definition here
-spec = None
+from isc.config.module_spec import module_spec_from_file
+from isc.util.file import path_search
+from bind10_config import PLUGIN_PATHS
+spec = module_spec_from_file(path_search('tsig_keys.spec', PLUGIN_PATHS))
def check():
pass
diff --git a/src/lib/python/bind10_config.py.in b/src/lib/python/bind10_config.py.in
index e041d73..fe4adb5 100644
--- a/src/lib/python/bind10_config.py.in
+++ b/src/lib/python/bind10_config.py.in
@@ -46,5 +46,8 @@ def reload():
PREFIX = "@prefix@"
DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
PLUGIN_PATHS = ["@prefix@/share/@PACKAGE@/config_plugins"]
+ # For testing the plugins so they can find their own spec files
+ if "B10_TEST_PLUGIN_DIR" in os.environ:
+ PLUGIN_PATHS = os.environ["B10_TEST_PLUGIN_DIR"].split(':')
reload()
diff --git a/src/lib/python/isc/util/Makefile.am b/src/lib/python/isc/util/Makefile.am
index 7ab8048..f6cbb78 100644
--- a/src/lib/python/isc/util/Makefile.am
+++ b/src/lib/python/isc/util/Makefile.am
@@ -1,5 +1,5 @@
SUBDIRS = . tests
-python_PYTHON = __init__.py process.py socketserver_mixin.py
+python_PYTHON = __init__.py process.py socketserver_mixin.py file.py
pythondir = $(pyexecdir)/isc/util
diff --git a/src/lib/python/isc/util/file.py b/src/lib/python/isc/util/file.py
new file mode 100644
index 0000000..faef9a8
--- /dev/null
+++ b/src/lib/python/isc/util/file.py
@@ -0,0 +1,29 @@
+# Copyright (C) 2011 Internet Systems Consortium.
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+"""Various functions for working with files and directories."""
+
+from os.path import exists, join
+
+def path_search(filename, paths):
+ """
+ Searches list of paths to find filename in one of them. The found one will
+ be returned or IOError will be returned if it isn't found.
+ """
+ for p in paths:
+ f = join(p, filename)
+ if exists(f):
+ return f
+ raise IOError("'" + filename + "' not found in " + str(paths))
diff --git a/src/lib/python/isc/util/tests/Makefile.am b/src/lib/python/isc/util/tests/Makefile.am
index f32fda0..0ce96de 100644
--- a/src/lib/python/isc/util/tests/Makefile.am
+++ b/src/lib/python/isc/util/tests/Makefile.am
@@ -1,5 +1,5 @@
PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
-PYTESTS = process_test.py socketserver_mixin_test.py
+PYTESTS = process_test.py socketserver_mixin_test.py file_test.py
EXTRA_DIST = $(PYTESTS)
# test using command-line arguments, so use check-local target instead of TESTS
diff --git a/src/lib/python/isc/util/tests/file_test.py b/src/lib/python/isc/util/tests/file_test.py
new file mode 100644
index 0000000..01e32d7
--- /dev/null
+++ b/src/lib/python/isc/util/tests/file_test.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2011 Internet Systems Consortium.
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+import isc.util.file
+import unittest
+
+class FileTest(unittest.TestCase):
+ def test_search_path_find(self):
+ """Test it returns the first occurence of the file"""
+ self.assertEqual('./file_test.py',
+ isc.util.file.path_search('file_test.py',
+ ['/no/such/directory/', '.',
+ '../tests/']))
+
+ def test_search_path_notfound(self):
+ """Test it throws an exception when the file can't be found"""
+ self.assertRaises(IOError, isc.util.file.path_search, 'no file', ['/no/such/directory'])
+
+if __name__ == "__main__":
+ unittest.main()
More information about the bind10-changes
mailing list