BIND 10 trac2353, updated. 67f4798a8a2457b8d284b75dcf1a6bcfeb8a0fa5 [2353] Check remove_socket_srv() with different states of BoB._srv_socket
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Nov 9 05:42:42 UTC 2012
The branch, trac2353 has been updated
via 67f4798a8a2457b8d284b75dcf1a6bcfeb8a0fa5 (commit)
via 32e88854b4ab9b2484d1f5ad0597869c8d1f5da4 (commit)
via 9d23c50d12b04b51c10889fe9b476823550bd733 (commit)
via 83d4f414a296dfc757a7a4f6e8c8fcf7bd24ca2e (commit)
from 424b8d83f6059738f2edb01564ec9ce1db223b08 (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 67f4798a8a2457b8d284b75dcf1a6bcfeb8a0fa5
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Nov 9 11:12:01 2012 +0530
[2353] Check remove_socket_srv() with different states of BoB._srv_socket
commit 32e88854b4ab9b2484d1f5ad0597869c8d1f5da4
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Nov 9 11:09:04 2012 +0530
[2353] Ensure that the server listens on the socket
commit 9d23c50d12b04b51c10889fe9b476823550bd733
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Nov 9 10:45:21 2012 +0530
[2353] Check that getsockname() on the socket returns what we expect
commit 83d4f414a296dfc757a7a4f6e8c8fcf7bd24ca2e
Author: Mukund Sivaraman <muks at isc.org>
Date: Fri Nov 9 10:41:38 2012 +0530
[2353] Test that the socket and tmpdir are deleted
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/bind10_src.py.in | 9 ++++-----
src/bin/bind10/tests/bind10_test.py.in | 31 ++++++++++++++++++++++++++++---
2 files changed, 32 insertions(+), 8 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index 4c73b78..8807393 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -914,11 +914,10 @@ class BoB:
"""
if self._srv_socket is not None:
self._srv_socket.close()
- os.remove(self._socket_path)
- os.rmdir(self._tmpdir)
- self._srv_socket = None
- self._tmpdir = None
- self._socket_path = None
+ if os.path.exists(self._socket_path):
+ os.remove(self._socket_path)
+ if os.path.isdir(self._tmpdir):
+ os.rmdir(self._tmpdir)
def _srv_accept(self):
"""
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index 82d96d2..cae56ca 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -378,16 +378,41 @@ class TestBoB(unittest.TestCase):
bob.init_socket_srv()
self.assertIsNotNone(bob._srv_socket)
+ self.assertNotEqual(-1, bob._srv_socket.fileno())
+ self.assertEqual(os.path.join(bob._tmpdir, 'sockcreator'),
+ bob._srv_socket.getsockname())
+
self.assertIsNotNone(bob._tmpdir)
self.assertTrue(os.path.isdir(bob._tmpdir))
self.assertIsNotNone(bob._socket_path)
self.assertTrue(os.path.exists(bob._socket_path))
+ # Check that it's possible to connect to the socket file (this
+ # only works if the socket file exists and the server listens on
+ # it).
+ s = socket.socket(socket.AF_UNIX)
+ try:
+ s.connect(bob._socket_path)
+ can_connect = True
+ s.close()
+ except socket.error as e:
+ can_connect = False
+
+ self.assertTrue(can_connect)
+
bob.remove_socket_srv()
- self.assertIsNone(bob._srv_socket)
- self.assertIsNone(bob._tmpdir)
- self.assertIsNone(bob._socket_path)
+ self.assertEqual(-1, bob._srv_socket.fileno())
+ self.assertFalse(os.path.exists(bob._socket_path))
+ self.assertFalse(os.path.isdir(bob._tmpdir))
+
+ # These should not fail either:
+
+ # second call
+ bob.remove_socket_srv()
+
+ bob._srv_socket = None
+ bob.remove_socket_srv()
def test_init_alternate_socket(self):
bob = BoB("alt_socket_file")
More information about the bind10-changes
mailing list