| 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 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return_code, stdout = self.RunPerfScript('run_benchmark foo') | 36 return_code, stdout = self.RunPerfScript('run_benchmark foo') |
| 37 self.assertIn('No benchmark named "foo"', stdout) | 37 self.assertIn('No benchmark named "foo"', stdout) |
| 38 self.assertNotEquals(return_code, 0) | 38 self.assertNotEquals(return_code, 0) |
| 39 | 39 |
| 40 def testRunBenchmarkListListsOutBenchmarks(self): | 40 def testRunBenchmarkListListsOutBenchmarks(self): |
| 41 return_code, stdout = self.RunPerfScript('run_benchmark list') | 41 return_code, stdout = self.RunPerfScript('run_benchmark list') |
| 42 self.assertEquals(return_code, 0, stdout) | 42 self.assertEquals(return_code, 0, stdout) |
| 43 self.assertIn('Pass --browser to list benchmarks', stdout) | 43 self.assertIn('Pass --browser to list benchmarks', stdout) |
| 44 self.assertIn('dummy_benchmark.stable_benchmark_1', stdout) | 44 self.assertIn('dummy_benchmark.stable_benchmark_1', stdout) |
| 45 | 45 |
| 46 def testRunTrybotWithTypo(self): |
| 47 return_code, stdout = self.RunPerfScript('run_benchmark try linux octaenz') |
| 48 self.assertIn('No benchmark named "octaenz"', stdout) |
| 49 self.assertIn('octane', stdout) |
| 50 self.assertNotEqual(return_code, 0) |
| 51 |
| 46 def testRunRecordWprHelp(self): | 52 def testRunRecordWprHelp(self): |
| 47 return_code, stdout = self.RunPerfScript('record_wpr') | 53 return_code, stdout = self.RunPerfScript('record_wpr') |
| 48 self.assertEquals(return_code, 0, stdout) | 54 self.assertEquals(return_code, 0, stdout) |
| 49 self.assertIn('optional arguments:', stdout) | 55 self.assertIn('optional arguments:', stdout) |
| 50 | 56 |
| 51 def testRunRecordWprList(self): | 57 def testRunRecordWprList(self): |
| 52 return_code, stdout = self.RunPerfScript('record_wpr --list-benchmarks') | 58 return_code, stdout = self.RunPerfScript('record_wpr --list-benchmarks') |
| 53 # TODO(nednguyen): Remove this once we figure out why importing | 59 # TODO(nednguyen): Remove this once we figure out why importing |
| 54 # small_profile_extender fails on Android dbg. | 60 # small_profile_extender fails on Android dbg. |
| 55 # crbug.com/561668 | 61 # crbug.com/561668 |
| 56 if 'ImportError: cannot import name small_profile_extender' in stdout: | 62 if 'ImportError: cannot import name small_profile_extender' in stdout: |
| 57 self.skipTest('small_profile_extender is missing') | 63 self.skipTest('small_profile_extender is missing') |
| 58 self.assertEquals(return_code, 0, stdout) | 64 self.assertEquals(return_code, 0, stdout) |
| 59 self.assertIn('kraken', stdout) | 65 self.assertIn('kraken', stdout) |
| 60 | 66 |
| 61 def testRunBenchmarkListJSONListsOutBenchmarks(self): | 67 def testRunBenchmarkListJSONListsOutBenchmarks(self): |
| 62 tmp_file = tempfile.NamedTemporaryFile(delete=False) | 68 tmp_file = tempfile.NamedTemporaryFile(delete=False) |
| 63 tmp_file_name = tmp_file.name | 69 tmp_file_name = tmp_file.name |
| 64 tmp_file.close() | 70 tmp_file.close() |
| 65 try: | 71 try: |
| 66 return_code, _ = self.RunPerfScript( | 72 return_code, _ = self.RunPerfScript( |
| 67 'run_benchmark list --json-output %s' % tmp_file_name) | 73 'run_benchmark list --json-output %s' % tmp_file_name) |
| 68 self.assertEquals(return_code, 0) | 74 self.assertEquals(return_code, 0) |
| 69 with open(tmp_file_name, 'r') as f: | 75 with open(tmp_file_name, 'r') as f: |
| 70 benchmark_data = json.load(f) | 76 benchmark_data = json.load(f) |
| 71 self.assertIn('dummy_benchmark.stable_benchmark_1', | 77 self.assertIn('dummy_benchmark.stable_benchmark_1', |
| 72 benchmark_data['steps']) | 78 benchmark_data['steps']) |
| 73 finally: | 79 finally: |
| 74 os.remove(tmp_file_name) | 80 os.remove(tmp_file_name) |
| OLD | NEW |