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

Side by Side Diff: tools/isolate/read_trace.py

Issue 10377105: Add scripts to list or trace all test cases in a gtest executable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/isolate/list_test_cases.py ('k') | tools/isolate/trace_inputs.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Reads a trace. Mostly for testing."""
7
8 import logging
9 import optparse
10 import os
11 import sys
12
13 import trace_inputs
14
15 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
16 ROOT_DIR = os.path.dirname(os.path.dirname(BASE_DIR))
17
18
19 def read_trace(logname, root_dir, cwd_dir, product_dir):
20 # Resolve any symlink
21 root_dir = os.path.realpath(root_dir)
22 api = trace_inputs.get_api()
23 _, _, _, _, simplified = trace_inputs.load_trace(logname, root_dir, api)
24 variables = trace_inputs.generate_dict(simplified, cwd_dir, product_dir)
25 trace_inputs.pretty_print(variables, sys.stdout)
26
27
28 def main():
29 """CLI frontend to validate arguments."""
30 parser = optparse.OptionParser(
31 usage='%prog <options> [gtest]')
32 parser.add_option(
33 '-v', '--verbose',
34 action='count',
35 default=0,
36 help='Use up to 3 times to increase logging level')
37 parser.add_option(
38 '-c', '--cwd',
39 default='chrome',
40 help='Signal to start the process from this relative directory. When '
41 'specified, outputs the inputs files in a way compatible for '
42 'gyp processing. Should be set to the relative path containing the '
43 'gyp file, e.g. \'chrome\' or \'net\'')
44 parser.add_option(
45 '-p', '--product-dir',
46 default='out/Release',
47 help='Directory for PRODUCT_DIR. Default: %default')
48 parser.add_option(
49 '--root-dir',
50 default=ROOT_DIR,
51 help='Root directory to base everything off. Default: %default')
52 options, args = parser.parse_args()
53
54 level = [logging.ERROR, logging.INFO, logging.DEBUG][min(2, options.verbose)]
55 logging.basicConfig(
56 level=level,
57 format='%(levelname)5s %(module)15s(%(lineno)3d):%(message)s')
58
59 if len(args) != 1:
60 parser.error('Please provide the log to read')
61 if not options.product_dir:
62 parser.error('--product-dir is required')
63 if not options.cwd:
64 parser.error('--cwd is required')
65
66 return read_trace(
67 args[0],
68 options.root_dir,
69 options.cwd,
70 options.product_dir)
71
72
73 if __name__ == '__main__':
74 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/isolate/list_test_cases.py ('k') | tools/isolate/trace_inputs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698