Browse Source

[2353] Test unknown pids in BoB.reap_children()

Mukund Sivaraman 12 years ago
parent
commit
58f0aac3a8
1 changed files with 15 additions and 0 deletions
  1. 15 0
      src/bin/bind10/tests/bind10_test.py.in

+ 15 - 0
src/bin/bind10/tests/bind10_test.py.in

@@ -717,6 +717,12 @@ class MockBob(BoB):
         self.get_process_exit_status_called = True
         return (53, 0)
 
+    def _get_process_exit_status_unknown_pid(self):
+        if self.get_process_exit_status_called:
+            return (0, 0)
+        self.get_process_exit_status_called = True
+        return (42, 0)
+
     def _get_process_exit_status_raises_oserror_echild(self):
         raise OSError(errno.ECHILD, 'Mock error')
 
@@ -1457,6 +1463,15 @@ class TestBossComponents(unittest.TestCase):
         # now, we should as the mock component.failed() returns False
         self.assertTrue(component in bob.components_to_restart)
 
+        # case where the returned pid is unknown to us. nothing should
+        # happpen then.
+        bob.get_process_exit_status_called = False
+        bob._get_process_exit_status = bob._get_process_exit_status_unknown_pid
+        bob.components_to_restart = []
+        # this should do nothing as the pid is unknown
+        bob.reap_children()
+        self.assertFalse(bob.components_to_restart)
+
         # case where bob._get_process_exit_status() raises OSError with errno.ECHILD
         bob._get_process_exit_status = bob._get_process_exit_status_raises_oserror_echild
         bob.components_to_restart = []