summaryrefslogtreecommitdiffstats
path: root/tools/isolate/trace_inputs_test.py
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-28 14:09:39 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-28 14:09:39 +0000
commitaff0f719f37715236470e677b363686285802e1d (patch)
treed704debb22064e333cf6b10a1e4684a502a7ee23 /tools/isolate/trace_inputs_test.py
parent9b3c49e23a6d4f004c085153a224cfa38491027a (diff)
downloadchromium_src-aff0f719f37715236470e677b363686285802e1d.zip
chromium_src-aff0f719f37715236470e677b363686285802e1d.tar.gz
chromium_src-aff0f719f37715236470e677b363686285802e1d.tar.bz2
[strace] Add support for interrupted calls and proper chdir handling.
Add support to log a trace without specifying the command line with --from-results to simplify repeated testing. Now uses a whitelist for strace log parser to throw on any unknown line. Add symlink resolving. R=rogerta@chromium.org BUG=98834 TEST= Review URL: https://chromiumcodereview.appspot.com/9834052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/isolate/trace_inputs_test.py')
-rwxr-xr-xtools/isolate/trace_inputs_test.py74
1 files changed, 62 insertions, 12 deletions
diff --git a/tools/isolate/trace_inputs_test.py b/tools/isolate/trace_inputs_test.py
index d1887a1..e1c391f 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():