| 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 logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import subprocess | 7 import subprocess |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 from mopy.config import Config | 10 from mopy.config import Config |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 def run_test_android(shell, shell_args, apps_and_args): | 48 def run_test_android(shell, shell_args, apps_and_args): |
| 49 """Run the given test on the single/default android device.""" | 49 """Run the given test on the single/default android device.""" |
| 50 assert shell | 50 assert shell |
| 51 (r, w) = os.pipe() | 51 (r, w) = os.pipe() |
| 52 with os.fdopen(r, "r") as rf: | 52 with os.fdopen(r, "r") as rf: |
| 53 with os.fdopen(w, "w") as wf: | 53 with os.fdopen(w, "w") as wf: |
| 54 arguments = build_shell_arguments(shell_args, apps_and_args) | 54 arguments = build_shell_arguments(shell_args, apps_and_args) |
| 55 _logger.debug("Starting shell with arguments: %s" % arguments) | 55 _logger.debug("Starting shell with arguments: %s" % arguments) |
| 56 start_time = time.time() | 56 start_time = time.time() |
| 57 # TODO(vtl): Do more logging in lower layers. | 57 # TODO(vtl): Do more logging in lower layers. |
| 58 shell.StartShell(arguments, wf, wf.close, False) | 58 shell.StartShell(arguments, wf, wf.close) |
| 59 rv = rf.read() | 59 rv = rf.read() |
| 60 run_time = time.time() - start_time | 60 run_time = time.time() - start_time |
| 61 _logger.debug("Shell completed") | 61 _logger.debug("Shell completed") |
| 62 # Only log if it took more than 3 seconds. | 62 # Only log if it took more than 3 seconds. |
| 63 if run_time >= 3: | 63 if run_time >= 3: |
| 64 _logger.info("Shell test took %.3f seconds; arguments: %s" % | 64 _logger.info("Shell test took %.3f seconds; arguments: %s" % |
| 65 (run_time, arguments)) | 65 (run_time, arguments)) |
| 66 return rv | 66 return rv |
| 67 | 67 |
| 68 | 68 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 86 | 86 |
| 87 def try_run_test(config, shell, shell_args, apps_and_args): | 87 def try_run_test(config, shell, shell_args, apps_and_args): |
| 88 """Returns the output of a command line or an empty string on error.""" | 88 """Returns the output of a command line or an empty string on error.""" |
| 89 command_line = build_command_line(config, shell_args, apps_and_args) | 89 command_line = build_command_line(config, shell_args, apps_and_args) |
| 90 _logger.debug("Running command line: %s" % command_line) | 90 _logger.debug("Running command line: %s" % command_line) |
| 91 try: | 91 try: |
| 92 return run_test(config, shell, shell_args, apps_and_args) | 92 return run_test(config, shell, shell_args, apps_and_args) |
| 93 except Exception as e: | 93 except Exception as e: |
| 94 print_process_error(command_line, e) | 94 print_process_error(command_line, e) |
| 95 return None | 95 return None |
| OLD | NEW |