|
@@ -34,7 +34,7 @@ class TestDhcpv4Daemon(unittest.TestCase):
|
|
|
def tearDown(self):
|
|
|
pass
|
|
|
|
|
|
- def runDhcp4(self, params, wait=1):
|
|
|
+ def runCommand(self, params, wait=1):
|
|
|
"""
|
|
|
This method runs dhcp4 and returns a touple: (returncode, stdout, stderr)
|
|
|
"""
|
|
@@ -127,14 +127,14 @@ class TestDhcpv4Daemon(unittest.TestCase):
|
|
|
print("Note: Purpose of some of the tests is to check if DHCPv4 server can be started,")
|
|
|
print(" not that is can bind sockets correctly. Please ignore binding errors.")
|
|
|
|
|
|
- (returncode, output, error) = self.runDhcp4(["../b10-dhcp4", "-v"])
|
|
|
+ (returncode, output, error) = self.runCommand(["../b10-dhcp4", "-v"])
|
|
|
|
|
|
self.assertEqual( str(output).count("[b10-dhcp4] Initiating DHCPv4 server operation."), 1)
|
|
|
|
|
|
def test_portnumber_0(self):
|
|
|
print("Check that specifying port number 0 is not allowed.")
|
|
|
|
|
|
- (returncode, output, error) = self.runDhcp4(['../b10-dhcp4', '-p', '0'])
|
|
|
+ (returncode, output, error) = self.runCommand(['../b10-dhcp4', '-p', '0'])
|
|
|
|
|
|
|
|
|
self.assertTrue(returncode != 0)
|
|
@@ -145,7 +145,7 @@ class TestDhcpv4Daemon(unittest.TestCase):
|
|
|
def test_portnumber_missing(self):
|
|
|
print("Check that -p option requires a parameter.")
|
|
|
|
|
|
- (returncode, output, error) = self.runDhcp4(['../b10-dhcp4', '-p'])
|
|
|
+ (returncode, output, error) = self.runCommand(['../b10-dhcp4', '-p'])
|
|
|
|
|
|
|
|
|
self.assertTrue(returncode != 0)
|
|
@@ -153,10 +153,32 @@ class TestDhcpv4Daemon(unittest.TestCase):
|
|
|
|
|
|
self.assertEqual( str(error).count("option requires an argument"), 1)
|
|
|
|
|
|
+ def test_portnumber_invalid1(self):
|
|
|
+ print("Check that -p option is check against bogus port number (999999).")
|
|
|
+
|
|
|
+ (returncode, output, error) = self.runCommand(['../b10-dhcp4', '-p','999999'])
|
|
|
+
|
|
|
+
|
|
|
+ self.assertTrue(returncode != 0)
|
|
|
+
|
|
|
+
|
|
|
+ self.assertEqual( str(error).count("Failed to parse port number"), 1)
|
|
|
+
|
|
|
+ def test_portnumber_invalid2(self):
|
|
|
+ print("Check that -p option is check against bogus port number (123garbage).")
|
|
|
+
|
|
|
+ (returncode, output, error) = self.runCommand(['../b10-dhcp4', '-p','123garbage'])
|
|
|
+
|
|
|
+
|
|
|
+ self.assertTrue(returncode != 0)
|
|
|
+
|
|
|
+
|
|
|
+ self.assertEqual( str(error).count("Failed to parse port number"), 1)
|
|
|
+
|
|
|
def test_portnumber_nonroot(self):
|
|
|
print("Check that specifying unprivileged port number will work.")
|
|
|
|
|
|
- (returncode, output, error) = self.runDhcp4(['../b10-dhcp4', '-p', '10057'])
|
|
|
+ (returncode, output, error) = self.runCommand(['../b10-dhcp4', '-s', '-p', '10057'])
|
|
|
|
|
|
|
|
|
|
|
@@ -169,7 +191,7 @@ class TestDhcpv4Daemon(unittest.TestCase):
|
|
|
def test_skip_msgq(self):
|
|
|
print("Check that connection to BIND10 msgq can be disabled.")
|
|
|
|
|
|
- (returncode, output, error) = self.runDhcp4(['../b10-dhcp4', '-s', '-p', '10057'])
|
|
|
+ (returncode, output, error) = self.runCommand(['../b10-dhcp4', '-s', '-p', '10057'])
|
|
|
|
|
|
|
|
|
|