[stem/master] Integ tests failed when the tor binary was named something else

commit ee538767ffcc352e75cece3a9b380c8b04ecb2d0 Author: Damian Johnson <atagar@torproject.org> Date: Tue Jan 6 09:31:23 2015 -0800 Integ tests failed when the tor binary was named something else Some of our tests respected non-standardly named tor binaries but not all. Fixing the system tests... https://trac.torproject.org/projects/tor/ticket/14111 --- test/integ/util/proc.py | 3 ++- test/integ/util/system.py | 23 +++++++++++++++-------- test/runner.py | 7 +++++-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/test/integ/util/proc.py b/test/integ/util/proc.py index 66203dd..79da938 100644 --- a/test/integ/util/proc.py +++ b/test/integ/util/proc.py @@ -65,10 +65,11 @@ class TestProc(unittest.TestCase): 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', command) + self.assertEqual(tor_cmd, command) self.assertTrue(float(utime) > 0) self.assertTrue(float(stime) >= 0) self.assertTrue(float(start_time) > proc.system_start_time()) diff --git a/test/integ/util/system.py b/test/integ/util/system.py index d754ddb..beea501 100644 --- a/test/integ/util/system.py +++ b/test/integ/util/system.py @@ -73,7 +73,7 @@ class TestSystem(unittest.TestCase): test.runner.skip(self, '(ps unavailable)') return - self.assertTrue(stem.util.system.is_running('tor')) + self.assertTrue(stem.util.system.is_running(test.runner.get_runner().get_tor_command(True))) self.assertFalse(stem.util.system.is_running('blarg_and_stuff')) def test_pid_by_name(self): @@ -90,7 +90,8 @@ class TestSystem(unittest.TestCase): return tor_pid = test.runner.get_runner().get_pid() - self.assertEqual(tor_pid, stem.util.system.pid_by_name('tor')) + tor_cmd = test.runner.get_runner().get_tor_command(True) + self.assertEqual(tor_pid, stem.util.system.pid_by_name(tor_cmd)) self.assertEqual(None, stem.util.system.pid_by_name('blarg_and_stuff')) def test_pid_by_name_pgrep(self): @@ -113,7 +114,8 @@ class TestSystem(unittest.TestCase): call_mock.side_effect = call_replacement tor_pid = test.runner.get_runner().get_pid() - self.assertEqual(tor_pid, stem.util.system.pid_by_name('tor')) + tor_cmd = test.runner.get_runner().get_tor_command(True) + self.assertEqual(tor_pid, stem.util.system.pid_by_name(tor_cmd)) def test_pid_by_name_pidof(self): """ @@ -135,7 +137,8 @@ class TestSystem(unittest.TestCase): call_mock.side_effect = call_replacement tor_pid = test.runner.get_runner().get_pid() - self.assertEqual(tor_pid, stem.util.system.pid_by_name('tor')) + tor_cmd = test.runner.get_runner().get_tor_command(True) + self.assertEqual(tor_pid, stem.util.system.pid_by_name(tor_cmd)) def test_pid_by_name_ps_linux(self): """ @@ -160,7 +163,8 @@ class TestSystem(unittest.TestCase): call_mock.side_effect = call_replacement tor_pid = test.runner.get_runner().get_pid() - self.assertEqual(tor_pid, stem.util.system.pid_by_name('tor')) + tor_cmd = test.runner.get_runner().get_tor_command(True) + self.assertEqual(tor_pid, stem.util.system.pid_by_name(tor_cmd)) def test_pid_by_name_ps_bsd(self): """ @@ -185,7 +189,8 @@ class TestSystem(unittest.TestCase): call_mock.side_effect = call_replacement tor_pid = test.runner.get_runner().get_pid() - self.assertEqual(tor_pid, stem.util.system.pid_by_name('tor')) + tor_cmd = test.runner.get_runner().get_tor_command(True) + self.assertEqual(tor_pid, stem.util.system.pid_by_name(tor_cmd)) def test_pid_by_name_lsof(self): """ @@ -210,8 +215,9 @@ class TestSystem(unittest.TestCase): with patch('stem.util.system.call') as call_mock: call_mock.side_effect = call_replacement + tor_cmd = test.runner.get_runner().get_tor_command(True) our_tor_pid = test.runner.get_runner().get_pid() - all_tor_pids = stem.util.system.pid_by_name('tor', multiple = True) + all_tor_pids = stem.util.system.pid_by_name(tor_cmd, multiple = True) if len(all_tor_pids) == 1: self.assertEqual(our_tor_pid, all_tor_pids[0]) @@ -561,7 +567,8 @@ class TestSystem(unittest.TestCase): # TODO: not sure how to check for this on windows IS_EXTRA_TOR_RUNNING = False elif not stem.util.system.is_bsd(): - pgrep_results = stem.util.system.call(stem.util.system.GET_PID_BY_NAME_PGREP % 'tor') + tor_cmd = test.runner.get_runner().get_tor_command(True) + pgrep_results = stem.util.system.call(stem.util.system.GET_PID_BY_NAME_PGREP % tor_cmd) IS_EXTRA_TOR_RUNNING = len(pgrep_results) > 1 else: ps_results = stem.util.system.call(stem.util.system.GET_PID_BY_NAME_PS_BSD) diff --git a/test/runner.py b/test/runner.py index ee261b7..9019eae 100644 --- a/test/runner.py +++ b/test/runner.py @@ -584,12 +584,15 @@ class Runner(object): except TorInaccessable: return stem.version.get_system_tor_version(self.get_tor_command()) - def get_tor_command(self): + def get_tor_command(self, base_cmd = False): """ Provides the command used to run our tor instance. + + :param bool base_cmd: provides just the command name if true rather than + the full '--tor path' argument """ - return self._get('_tor_cmd') + return os.path.basename(self._get('_tor_cmd')) if base_cmd else self._get('_tor_cmd') def _get(self, attr): """
participants (1)
-
atagar@torproject.org