OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import copy | 5 import copy |
6 import json | 6 import json |
7 import os | 7 import os |
8 import shutil | 8 import shutil |
9 import subprocess | 9 import subprocess |
10 import tempfile | 10 import tempfile |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 def testPullMetricsFromTrace(self): | 139 def testPullMetricsFromTrace(self): |
140 metrics = puller._PullMetricsFromTrace(_MINIMALIST_TRACE) | 140 metrics = puller._PullMetricsFromTrace(_MINIMALIST_TRACE) |
141 self.assertEquals(4, len(metrics)) | 141 self.assertEquals(4, len(metrics)) |
142 self.assertEquals(20, metrics['total_load']) | 142 self.assertEquals(20, metrics['total_load']) |
143 self.assertEquals(5, metrics['onload']) | 143 self.assertEquals(5, metrics['onload']) |
144 self.assertEquals(30971, metrics['browser_malloc_avg']) | 144 self.assertEquals(30971, metrics['browser_malloc_avg']) |
145 self.assertEquals(55044, metrics['browser_malloc_max']) | 145 self.assertEquals(55044, metrics['browser_malloc_max']) |
146 | 146 |
147 def testCommandLine(self): | 147 def testCommandLine(self): |
148 tmp_dir = tempfile.mkdtemp() | 148 tmp_dir = tempfile.mkdtemp() |
| 149 with open(os.path.join(tmp_dir, 'run_infos.json'), 'w') as out_file: |
| 150 json.dump({'urls': ['a.com', 'b.com', 'c.org']}, out_file) |
149 for dirname in ['1', '2', 'whatever']: | 151 for dirname in ['1', '2', 'whatever']: |
150 os.mkdir(os.path.join(tmp_dir, dirname)) | 152 os.mkdir(os.path.join(tmp_dir, dirname)) |
151 with open(os.path.join(tmp_dir, dirname, 'trace.json'), 'w') as out_file: | 153 with open(os.path.join(tmp_dir, dirname, 'trace.json'), 'w') as out_file: |
152 json.dump(_MINIMALIST_TRACE, out_file) | 154 json.dump(_MINIMALIST_TRACE, out_file) |
153 | 155 |
154 process = subprocess.Popen(['python', puller.__file__, tmp_dir]) | 156 process = subprocess.Popen(['python', puller.__file__, tmp_dir]) |
155 process.wait() | 157 process.wait() |
156 shutil.rmtree(tmp_dir) | 158 shutil.rmtree(tmp_dir) |
157 | 159 |
158 self.assertEquals(0, process.returncode) | 160 self.assertEquals(0, process.returncode) |
159 | 161 |
160 | 162 |
161 if __name__ == '__main__': | 163 if __name__ == '__main__': |
162 unittest.main() | 164 unittest.main() |
OLD | NEW |