def test_get_process_info_state_preserves_case(self): """ C{get_process_info} retains the case of the process state, since for example both x and X can be different states. """ self._add_process_info(12, state="a (some state)") process_info = ProcessInformation(self.proc_dir) info = process_info.get_process_info(12) self.assertEqual(b"a", info["state"])
def test_get_process_info_state(self): """ C{get_process_info} reads the process state from the status file and uses the first character to represent the process state. """ self._add_process_info(12, state="A (some state)") process_info = ProcessInformation(self.proc_dir) info = process_info.get_process_info(12) self.assertEqual(b"A", info["state"])
def _test_signal_real_process(self, signame): """ When a 'signal-process' message is received the plugin should signal the appropriate process and generate an operation-result message with details of the outcome. Data is gathered from internal plugin methods to get the start time of the test process being signalled. """ process_info_factory = ProcessInformation() signaller = ProcessKiller() signaller.register(self.manager) popen = get_active_process() process_info = process_info_factory.get_process_info(popen.pid) self.assertNotEquals(process_info, None) start_time = process_info["start-time"] self.manager.dispatch_message({ "type": "signal-process", "operation-id": 1, "pid": popen.pid, "name": "python", "start-time": start_time, "signal": signame }) # We're waiting on the child process here so that we (the # parent process) consume it's return code; this prevents it # from becoming a zombie and makes the test do a better job of # reflecting the real world. return_code = popen.wait() # The return code is negative if the process was terminated by # a signal. self.assertTrue(return_code < 0) process_info = process_info_factory.get_process_info(popen.pid) self.assertEqual(process_info, None) service = self.broker_service self.assertMessages(service.message_store.get_pending_messages(), [{ "type": "operation-result", "status": SUCCEEDED, "operation-id": 1 }])
def test_get_process_info_state_tracing_stop_lucid(self): """ In Lucid, capital T was used for both stopped and tracing stop. From Natty and onwards lowercase t is used for tracing stop, so we special-case that state and always return lowercase t for tracing stop. """ self._add_process_info(12, state="T (tracing stop)") self._add_process_info(13, state="t (tracing stop)") process_info = ProcessInformation(self.proc_dir) info1 = process_info.get_process_info(12) info2 = process_info.get_process_info(12) self.assertEqual(b"t", info1["state"]) self.assertEqual(b"t", info2["state"])