def test_system_start_time(self, get_line_mock): """ Tests the system_start_time function. """ get_line_mock.side_effect = lambda *params: { ('/proc/stat', 'btime', 'system start time'): 'btime 1001001', }[params] self.assertEqual(1001001, proc.system_start_time())
def test_stats(self): """ Checks that stem.util.proc.stats looks somewhat reasonable. """ tor_cmd = test.runner.get_runner().get_tor_command(True) tor_pid = test.runner.get_runner().get_pid() command, utime, stime, start_time = proc.stats(tor_pid, 'command', 'utime', 'stime', 'start time') self.assertEqual(tor_cmd, command) self.assertTrue(float(utime) > 0) self.assertTrue(float(stime) >= 0) self.assertTrue(float(start_time) > proc.system_start_time())
def test_stats(self): """ Checks that stem.util.proc.stats looks somewhat reasonable. """ if not proc.is_available(): test.runner.skip(self, '(proc unavailable)') return tor_cmd = test.runner.get_runner().get_tor_command(True) tor_pid = test.runner.get_runner().get_pid() command, utime, stime, start_time = proc.stats(tor_pid, 'command', 'utime', 'stime', 'start time') self.assertEqual(tor_cmd, command) self.assertTrue(float(utime) > 0) self.assertTrue(float(stime) >= 0) self.assertTrue(float(start_time) > proc.system_start_time())