OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Wrapper for adding logdog streaming support to swarming tasks.""" | 6 """Wrapper for adding logdog streaming support to swarming tasks.""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 parser = CommandParser() | 50 parser = CommandParser() |
51 args, extra_cmd_args = parser.parse_known_args(sys.argv[1:]) | 51 args, extra_cmd_args = parser.parse_known_args(sys.argv[1:]) |
52 | 52 |
53 logging.basicConfig(level=logging.INFO) | 53 logging.basicConfig(level=logging.INFO) |
54 with tempfile_ext.NamedTemporaryDirectory() as logcat_output_dir: | 54 with tempfile_ext.NamedTemporaryDirectory() as logcat_output_dir: |
55 test_cmd = [ | 55 test_cmd = [ |
56 os.path.join('bin', 'run_%s' % args.target), | 56 os.path.join('bin', 'run_%s' % args.target), |
57 '--logcat-output-file', | 57 '--logcat-output-file', |
58 (args.logcat_output_file if args.logcat_output_file | 58 (args.logcat_output_file if args.logcat_output_file |
59 else os.path.join(logcat_output_dir, 'logcats')), | 59 else os.path.join(logcat_output_dir, 'logcats')), |
60 '--upload-logcats-file', | |
61 '--target-devices-file', args.target_devices_file, | 60 '--target-devices-file', args.target_devices_file, |
62 '-v'] + extra_cmd_args | 61 '-v'] |
63 | 62 |
64 with tempfile_ext.NamedTemporaryDirectory( | 63 with tempfile_ext.NamedTemporaryDirectory( |
65 prefix='tmp_android_logdog_wrapper') as temp_directory: | 64 prefix='tmp_android_logdog_wrapper') as temp_directory: |
66 if not os.path.exists(args.logdog_bin_cmd): | 65 if not os.path.exists(args.logdog_bin_cmd): |
67 logging.error( | 66 logging.error( |
68 'Logdog binary %s unavailable. Unable to create logdog client', | 67 'Logdog binary %s unavailable. Unable to create logdog client', |
69 args.logdog_bin_cmd) | 68 args.logdog_bin_cmd) |
70 else: | 69 else: |
| 70 test_cmd += ['--upload-logcats-file'] |
71 streamserver_uri = 'unix:%s' % os.path.join(temp_directory, | 71 streamserver_uri = 'unix:%s' % os.path.join(temp_directory, |
72 'butler.sock') | 72 'butler.sock') |
73 prefix = os.path.join('android', 'swarming', 'logcats', | 73 prefix = os.path.join('android', 'swarming', 'logcats', |
74 os.environ.get('SWARMING_TASK_ID')) | 74 os.environ.get('SWARMING_TASK_ID')) |
75 | 75 |
76 # Call test_cmdline through logdog butler subcommand. | 76 # Call test_cmdline through logdog butler subcommand. |
77 test_cmd = [ | 77 test_cmd = [ |
78 args.logdog_bin_cmd, '-project', PROJECT, | 78 args.logdog_bin_cmd, '-project', PROJECT, |
79 '-output', OUTPUT, | 79 '-output', OUTPUT, |
80 '-prefix', prefix, | 80 '-prefix', prefix, |
81 '--service-account-json', SERVICE_ACCOUNT_JSON, | 81 '--service-account-json', SERVICE_ACCOUNT_JSON, |
82 '-coordinator-host', COORDINATOR_HOST, | 82 '-coordinator-host', COORDINATOR_HOST, |
83 'run', '-streamserver-uri', streamserver_uri, '--'] + test_cmd | 83 'run', '-streamserver-uri', streamserver_uri, '--'] + test_cmd |
84 | 84 |
| 85 test_cmd += extra_cmd_args |
85 test_proc = subprocess.Popen(test_cmd) | 86 test_proc = subprocess.Popen(test_cmd) |
86 with signal_handler.SignalHandler(signal.SIGTERM, | 87 with signal_handler.SignalHandler(signal.SIGTERM, |
87 CreateStopTestsMethod(test_proc)): | 88 CreateStopTestsMethod(test_proc)): |
88 result = test_proc.wait() | 89 result = test_proc.wait() |
89 return result | 90 return result |
90 | 91 |
91 if __name__ == '__main__': | 92 if __name__ == '__main__': |
92 sys.exit(main()) | 93 sys.exit(main()) |
OLD | NEW |