OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 json | 5 import json |
6 import os | 6 import os |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 import unittest | 10 import unittest |
11 | 11 |
| 12 from telemetry import decorators |
| 13 |
12 | 14 |
13 class ScriptsSmokeTest(unittest.TestCase): | 15 class ScriptsSmokeTest(unittest.TestCase): |
14 | 16 |
15 perf_dir = os.path.dirname(__file__) | 17 perf_dir = os.path.dirname(__file__) |
16 | 18 |
17 def RunPerfScript(self, command): | 19 def RunPerfScript(self, command): |
18 args = [sys.executable] + command.split(' ') | 20 args = [sys.executable] + command.split(' ') |
19 proc = subprocess.Popen(args, stdout=subprocess.PIPE, | 21 proc = subprocess.Popen(args, stdout=subprocess.PIPE, |
20 stderr=subprocess.STDOUT, cwd=self.perf_dir) | 22 stderr=subprocess.STDOUT, cwd=self.perf_dir) |
21 stdout = proc.communicate()[0] | 23 stdout = proc.communicate()[0] |
(...skipping 19 matching lines...) Expand all Loading... |
41 return_code, stdout = self.RunPerfScript('run_benchmark list') | 43 return_code, stdout = self.RunPerfScript('run_benchmark list') |
42 self.assertEquals(return_code, 0, stdout) | 44 self.assertEquals(return_code, 0, stdout) |
43 self.assertIn('Pass --browser to list benchmarks', stdout) | 45 self.assertIn('Pass --browser to list benchmarks', stdout) |
44 self.assertIn('dummy_benchmark.stable_benchmark_1', stdout) | 46 self.assertIn('dummy_benchmark.stable_benchmark_1', stdout) |
45 | 47 |
46 def testRunRecordWprHelp(self): | 48 def testRunRecordWprHelp(self): |
47 return_code, stdout = self.RunPerfScript('record_wpr') | 49 return_code, stdout = self.RunPerfScript('record_wpr') |
48 self.assertEquals(return_code, 0, stdout) | 50 self.assertEquals(return_code, 0, stdout) |
49 self.assertIn('optional arguments:', stdout) | 51 self.assertIn('optional arguments:', stdout) |
50 | 52 |
| 53 @decorators.Disabled('all') # crbug.com/581103 |
51 def testRunRecordWprList(self): | 54 def testRunRecordWprList(self): |
52 return_code, stdout = self.RunPerfScript('record_wpr --list-benchmarks') | 55 return_code, stdout = self.RunPerfScript('record_wpr --list-benchmarks') |
53 # TODO(nednguyen): Remove this once we figure out why importing | 56 # TODO(nednguyen): Remove this once we figure out why importing |
54 # small_profile_extender fails on Android dbg. | 57 # small_profile_extender fails on Android dbg. |
55 # crbug.com/561668 | 58 # crbug.com/561668 |
56 if 'ImportError: cannot import name small_profile_extender' in stdout: | 59 if 'ImportError: cannot import name small_profile_extender' in stdout: |
57 self.skipTest('small_profile_extender is missing') | 60 self.skipTest('small_profile_extender is missing') |
58 self.assertEquals(return_code, 0, stdout) | 61 self.assertEquals(return_code, 0, stdout) |
59 self.assertIn('kraken', stdout) | 62 self.assertIn('kraken', stdout) |
60 | 63 |
61 def testRunBenchmarkListJSONListsOutBenchmarks(self): | 64 def testRunBenchmarkListJSONListsOutBenchmarks(self): |
62 tmp_file = tempfile.NamedTemporaryFile(delete=False) | 65 tmp_file = tempfile.NamedTemporaryFile(delete=False) |
63 tmp_file_name = tmp_file.name | 66 tmp_file_name = tmp_file.name |
64 tmp_file.close() | 67 tmp_file.close() |
65 try: | 68 try: |
66 return_code, _ = self.RunPerfScript( | 69 return_code, _ = self.RunPerfScript( |
67 'run_benchmark list --json-output %s' % tmp_file_name) | 70 'run_benchmark list --json-output %s' % tmp_file_name) |
68 self.assertEquals(return_code, 0) | 71 self.assertEquals(return_code, 0) |
69 with open(tmp_file_name, 'r') as f: | 72 with open(tmp_file_name, 'r') as f: |
70 benchmark_data = json.load(f) | 73 benchmark_data = json.load(f) |
71 self.assertIn('dummy_benchmark.stable_benchmark_1', | 74 self.assertIn('dummy_benchmark.stable_benchmark_1', |
72 benchmark_data['steps']) | 75 benchmark_data['steps']) |
73 finally: | 76 finally: |
74 os.remove(tmp_file_name) | 77 os.remove(tmp_file_name) |
OLD | NEW |