[tor-commits] [stem/master] Integ check for value of get_system_tor_version()
atagar at torproject.org
atagar at torproject.org
Sun Jan 29 08:54:42 UTC 2012
commit dbf8663cf9b5ca1e31f516109b019045ec63a04c
Author: Damian Johnson <atagar at torproject.org>
Date: Sat Jan 28 13:14:28 2012 -0800
Integ check for value of get_system_tor_version()
We had basic verification tests for get_system_tor_version() but it didn't
check the value. This was a refactoring mistake, iirc it once checked the value
but since we can run with an arbitrary tor binary I removed that, forgetting
that get_system_tor_version() could optionally take that binary path.
Making this a separate test since it relies on the tor instance being
accessible (which isn't the case with all targets).
---
test/integ/version.py | 14 ++++++++++++++
test/runner.py | 13 ++++++++++++-
2 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/test/integ/version.py b/test/integ/version.py
index 616ae57..e344ef8 100644
--- a/test/integ/version.py
+++ b/test/integ/version.py
@@ -29,6 +29,20 @@ class TestVersion(unittest.TestCase):
# try running against a command that doesn't exist
self.assertRaises(IOError, stem.version.get_system_tor_version, "blarg")
+ def test_get_system_tor_version_value(self):
+ """
+ Checks that the get_system_tor_version() provides the same value as our
+ test instance provides.
+ """
+
+ runner = test.runner.get_runner()
+
+ if not runner.is_accessible():
+ self.skipTest("(no connection)")
+
+ system_tor_version = stem.version.get_system_tor_version(runner.get_tor_command())
+ self.assertEquals(runner.get_tor_version(), system_tor_version)
+
def test_getinfo_version_parsing(self):
"""
Issues a 'GETINFO version' query to our test instance and makes sure that
diff --git a/test/runner.py b/test/runner.py
index d3c6143..0e71ade 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -21,7 +21,8 @@ Runner - Runtime context for our integration tests.
|- get_torrc_contents - contents of our tor instance's torrc
|- get_pid - process id of our tor process
|- get_tor_socket - provides a socket to the tor instance
- +- get_tor_version - provides the version of tor we're running against
+ |- get_tor_version - provides the version of tor we're running against
+ +- get_tor_command - provides the command used to start tor
"""
import os
@@ -115,6 +116,7 @@ class Runner:
# runtime attributes, set by the start method
self._test_dir = ""
+ self._tor_cmd = None
self._tor_cwd = ""
self._torrc_contents = ""
self._custom_opts = None
@@ -160,6 +162,7 @@ class Runner:
os.chdir(tor_cwd)
data_dir_path = "./%s" % os.path.basename(self._test_dir)
+ self._tor_cmd = tor_cmd
self._custom_opts = extra_torrc_opts
self._torrc_contents = BASE_TORRC % data_dir_path
@@ -197,6 +200,7 @@ class Runner:
shutil.rmtree(self._test_dir, ignore_errors = True)
self._test_dir = ""
+ self._tor_cmd = None
self._tor_cwd = ""
self._torrc_contents = ""
self._custom_opts = None
@@ -393,6 +397,13 @@ class Runner:
tor_version = list(version_response)[0][8:]
return stem.version.Version(tor_version)
+ def get_tor_command(self):
+ """
+ Provides the command used to run our tor instance.
+ """
+
+ return self._get("_tor_cmd")
+
def _get(self, attr):
"""
Fetches one of our attributes in a thread safe manner, raising if we aren't
More information about the tor-commits
mailing list