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