Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: tools/isolate/trace_inputs_test.py

Issue 9834052: [strace] Add support for interrupted calls and proper chdir handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test again Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/isolate/trace_inputs.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/isolate/trace_inputs_test.py
diff --git a/tools/isolate/trace_inputs_test.py b/tools/isolate/trace_inputs_test.py
index d1887a182eff49035f07c8a6f39f1d956c9db6ec..e1c391f2017096c35dc693edbab2b3f3ed17e726 100755
--- a/tools/isolate/trace_inputs_test.py
+++ b/tools/isolate/trace_inputs_test.py
@@ -18,9 +18,15 @@ VERBOSE = False
class CalledProcessError(subprocess.CalledProcessError):
"""Makes 2.6 version act like 2.7"""
- def __init__(self, returncode, cmd, output):
+ def __init__(self, returncode, cmd, output, cwd):
super(CalledProcessError, self).__init__(returncode, cmd)
self.output = output
+ self.cwd = cwd
+
+ def __str__(self):
+ return super(CalledProcessError, self).__str__() + (
+ '\n'
+ 'cwd=%s\n%s') % (self.cwd, self.output)
class TraceInputs(unittest.TestCase):
@@ -33,19 +39,24 @@ class TraceInputs(unittest.TestCase):
def _execute(self, args):
cmd = [
- sys.executable, os.path.join(ROOT_DIR, 'trace_inputs.py'),
- '--log', self.log,
- '--gyp', os.path.join('data', 'trace_inputs'),
- '--product', '.', # Not tested.
- '--root-dir', ROOT_DIR,
+ sys.executable, os.path.join(ROOT_DIR, 'trace_inputs.py'),
+ '--log', self.log,
+ '--root-dir', ROOT_DIR,
] + args
p = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=ROOT_DIR)
out = p.communicate()[0]
if p.returncode:
- raise CalledProcessError(p.returncode, cmd, out)
+ raise CalledProcessError(p.returncode, cmd, out, ROOT_DIR)
return out
+ @staticmethod
+ def _gyp():
+ return [
+ '--gyp', os.path.join('data', 'trace_inputs'),
+ '--product', '.', # Not tested.
+ ]
+
def test_trace(self):
if sys.platform == 'linux2':
return self._test_trace_linux()
@@ -53,8 +64,31 @@ class TraceInputs(unittest.TestCase):
return self._test_trace_mac()
print 'Unsupported: %s' % sys.platform
+ def test_trace_gyp(self):
+ if sys.platform == 'linux2':
+ return self._test_trace_gyp_linux()
+ if sys.platform == 'darwin':
+ return self._test_trace_gyp_mac()
+ print 'Unsupported: %s' % sys.platform
+
def _test_trace_linux(self):
- # TODO(maruel): BUG: Note that child.py is missing.
+ expected_end = [
+ "Interesting: 4 reduced to 3",
+ " data/trace_inputs/",
+ " trace_inputs.py",
+ " trace_inputs_test.py",
+ ]
+ actual = self._execute(['trace_inputs_test.py', '--child1']).splitlines()
+ self.assertTrue(actual[0].startswith('Tracing... ['))
+ self.assertTrue(actual[1].startswith('Loading traces... '))
+ self.assertTrue(actual[2].startswith('Total: '))
+ self.assertEquals("Non existent: 0", actual[3])
+ # Ignore any Unexpected part.
+ # TODO(maruel): Make sure there is no Unexpected part, even in the case of
+ # virtualenv usage.
+ self.assertEquals(expected_end, actual[-len(expected_end):])
+
+ def _test_trace_gyp_linux(self):
expected = (
"{\n"
" 'variables': {\n"
@@ -63,16 +97,32 @@ class TraceInputs(unittest.TestCase):
" '<(DEPTH)/trace_inputs_test.py',\n"
" ],\n"
" 'isolate_dirs': [\n"
+ " './',\n"
" ],\n"
" },\n"
"},\n")
- gyp = self._execute(['trace_inputs_test.py', '--child1'])
- self.assertEquals(expected, gyp)
+ actual = self._execute(self._gyp() + ['trace_inputs_test.py', '--child1'])
+ self.assertEquals(expected, actual)
def _test_trace_mac(self):
# It is annoying in the case of dtrace because it requires root access.
# TODO(maruel): BUG: Note that child.py is missing.
expected = (
+ "Total: 2\n"
+ "Non existent: 0\n"
+ "Interesting: 2 reduced to 2\n"
+ " trace_inputs.py\n"
+ " trace_inputs_test.py\n")
+ actual = self._execute(
+ ['trace_inputs_test.py', '--child1']).splitlines(True)
+ self.assertTrue(actual[0].startswith('Tracing... ['))
+ self.assertTrue(actual[1].startswith('Loading traces... '))
+ self.assertEquals(expected, ''.join(actual[2:]))
+
+ def _test_trace_gyp_mac(self):
+ # It is annoying in the case of dtrace because it requires root access.
+ # TODO(maruel): BUG: Note that child.py is missing.
+ expected = (
"{\n"
" 'variables': {\n"
" 'isolate_files': [\n"
@@ -83,8 +133,8 @@ class TraceInputs(unittest.TestCase):
" ],\n"
" },\n"
"},\n")
- gyp = self._execute(['trace_inputs_test.py', '--child1'])
- self.assertEquals(expected, gyp)
+ actual = self._execute(self._gyp() + ['trace_inputs_test.py', '--child1'])
+ self.assertEquals(expected, actual)
def child1():
« no previous file with comments | « tools/isolate/trace_inputs.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698