BIND 10 trac2410, updated. aac0dd304b86ee38049480c8155f5eb97142c435 [2410] Changes as a result of review
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Nov 22 19:24:40 UTC 2012
The branch, trac2410 has been updated
via aac0dd304b86ee38049480c8155f5eb97142c435 (commit)
from 56bcca870b41742f47160cae5b30b81ef62c1095 (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 aac0dd304b86ee38049480c8155f5eb97142c435
Author: Stephen Morris <stephen at isc.org>
Date: Thu Nov 22 19:22:25 2012 +0000
[2410] Changes as a result of review
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp4/tests/dhcp4_test.py | 47 +++++++++++++++++++------------------
src/bin/dhcp6/tests/dhcp6_test.py | 47 +++++++++++++++++++------------------
2 files changed, 48 insertions(+), 46 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp4/tests/dhcp4_test.py b/src/bin/dhcp4/tests/dhcp4_test.py
index 19e4282..e493e04 100644
--- a/src/bin/dhcp4/tests/dhcp4_test.py
+++ b/src/bin/dhcp4/tests/dhcp4_test.py
@@ -45,6 +45,25 @@ class TestDhcpv4Daemon(unittest.TestCase):
def tearDown(self):
pass
+ def readPipe(self, pipe_fd):
+ """
+ Reads bytes from a pipe and returns a character string. If nothing is
+ read, or if there is an error, an empty string is returned.
+
+ pipe_fd - Pipe file descriptor to read
+ """
+ try:
+ data = os.read(pipe_fd, 16384)
+ # Make sure we have a string
+ if (data is None):
+ data = ""
+ else:
+ data = str(data)
+ except OSError:
+ data = ""
+
+ return data
+
def runCommand(self, params, wait=1):
"""
This method runs a command and returns a tuple: (returncode, stdout, stderr)
@@ -90,30 +109,13 @@ class TestDhcpv4Daemon(unittest.TestCase):
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
# As we don't know how long the subprocess will take to start and
- # produce output, we'll loop and sleep for 250ms between each
+ # produce output, we'll loop and sleep for 250 ms between each
# iteration. To avoid an infinite loop, we'll loop for a maximum
# of five seconds: that should be enough.
- count = 20
- output = ""
- error = ""
- while count > 0:
- try:
- new_output = os.read(self.stdout_pipes[0], 16384)
- except OSError:
- new_output = ""
-
- # read can return None. Make sure we have a string
- if (new_output is not None):
- output = output + str(new_output)
-
- try:
- new_error = os.read(self.stderr_pipes[0], 16384)
- except OSError:
- new_error = ""
-
- # read can return None. Make sure we have a string
- if (new_error is not None):
- error = error + str(new_error)
+ for count in range(20):
+ # Read something from stderr and stdout (these reads don't block).
+ output = self.readPipe(self.stdout_pipes[0])
+ error = self.readPipe(self.stderr_pipes[0])
# If the process has already exited, or if it has output something,
# quit the loop now.
@@ -121,7 +123,6 @@ class TestDhcpv4Daemon(unittest.TestCase):
break
# Process still running, try again in 250 ms.
- count = count - 1
time.sleep(0.25)
# Exited loop, kill the process if it is still running
diff --git a/src/bin/dhcp6/tests/dhcp6_test.py b/src/bin/dhcp6/tests/dhcp6_test.py
index d82d513..1870392 100644
--- a/src/bin/dhcp6/tests/dhcp6_test.py
+++ b/src/bin/dhcp6/tests/dhcp6_test.py
@@ -45,6 +45,25 @@ class TestDhcpv6Daemon(unittest.TestCase):
def tearDown(self):
pass
+ def readPipe(self, pipe_fd):
+ """
+ Reads bytes from a pipe and returns a character string. If nothing is
+ read, or if there is an error, an empty string is returned.
+
+ pipe_fd - Pipe file descriptor to read
+ """
+ try:
+ data = os.read(pipe_fd, 16384)
+ # Make sure we have a string
+ if (data is None):
+ data = ""
+ else:
+ data = str(data)
+ except OSError:
+ data = ""
+
+ return data
+
def runCommand(self, params, wait=1):
"""
This method runs a command and returns a tuple: (returncode, stdout, stderr)
@@ -90,30 +109,13 @@ class TestDhcpv6Daemon(unittest.TestCase):
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
# As we don't know how long the subprocess will take to start and
- # produce output, we'll loop and sleep for 250ms between each
+ # produce output, we'll loop and sleep for 250 ms between each
# iteration. To avoid an infinite loop, we'll loop for a maximum
# of five seconds: that should be enough.
- count = 20
- output = ""
- error = ""
- while count > 0:
- try:
- new_output = os.read(self.stdout_pipes[0], 16384)
- except OSError:
- new_output = ""
-
- # read can return None. Make sure we have a string
- if (new_output is not None):
- output = output + str(new_output)
-
- try:
- new_error = os.read(self.stderr_pipes[0], 16384)
- except OSError:
- new_error = ""
-
- # read can return None. Make sure we have a string
- if (new_error is not None):
- error = error + str(new_error)
+ for count in range(20):
+ # Read something from stderr and stdout (these reads don't block).
+ output = self.readPipe(self.stdout_pipes[0])
+ error = self.readPipe(self.stderr_pipes[0])
# If the process has already exited, or if it has output something,
# quit the loop now.
@@ -121,7 +123,6 @@ class TestDhcpv6Daemon(unittest.TestCase):
break
# Process still running, try again in 250 ms.
- count = count - 1
time.sleep(0.25)
# Exited loop, kill the process if it is still running
More information about the bind10-changes
mailing list