Remove stdout result parsing from cros-vm test runner.

Instead, it just pulls the file from the VM directly, which was added in
CL:1021531.

Bug: 828607
Change-Id: I6c71f557bf91dafc8c5f638d0c07c49bde728ed4
Reviewed-on: https://chromium-review.googlesource.com/1044755
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: John Budorick <jbudorick@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#556213}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 5a53981ff196802bba5e5436b4cb433a2fccc8c7
This commit is contained in:
Ben Pastene 2018-05-04 21:59:11 +00:00 коммит произвёл Commit Bot
Родитель 2de8c3d754
Коммит e3785a882c
1 изменённых файлов: 20 добавлений и 31 удалений

Просмотреть файл

@ -97,6 +97,19 @@ def vm_test(args):
for f in read_runtime_files(args.runtime_deps_path, args.path_to_outdir): for f in read_runtime_files(args.runtime_deps_path, args.path_to_outdir):
cros_run_vm_test_cmd.extend(['--files', f]) cros_run_vm_test_cmd.extend(['--files', f])
if args.test_launcher_summary_output:
result_dir, result_file = os.path.split(args.test_launcher_summary_output)
# If args.test_launcher_summary_output is a file in cwd, result_dir will be
# an empty string, so replace it with '.' when this is the case so
# cros_run_vm_test can correctly handle it.
if not result_dir:
result_dir = '.'
vm_result_file = '/tmp/%s' % result_file
cros_run_vm_test_cmd += [
'--results-src', vm_result_file,
'--results-dest-dir', result_dir,
]
cros_run_vm_test_cmd += [ cros_run_vm_test_cmd += [
'--cmd', '--cmd',
'--', '--',
@ -105,42 +118,16 @@ def vm_test(args):
'--test-launcher-total-shards=%d' % args.test_launcher_total_shards, '--test-launcher-total-shards=%d' % args.test_launcher_total_shards,
] ]
stdout_results_delimiter = '@@@@@results-file-delimiter@@@@@'
if args.test_launcher_summary_output: if args.test_launcher_summary_output:
result_file = 'gtest_results.json' cros_run_vm_test_cmd += [
cros_run_vm_test_cmd.extend([ '--test-launcher-summary-output=%s' % vm_result_file,
'--test-launcher-summary-output=%s' % result_file, ]
';', 'export test_code=$?',
';', 'echo %s' % stdout_results_delimiter,
';', 'cat %s' % result_file,
';', 'echo %s' % stdout_results_delimiter,
';', 'exit $test_code',
])
logging.info('Running the following command:') logging.info('Running the following command:')
logging.info(' '.join(cros_run_vm_test_cmd)) logging.info(' '.join(cros_run_vm_test_cmd))
vm_proc = subprocess.Popen( return subprocess.call(
cros_run_vm_test_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) cros_run_vm_test_cmd, stdout=sys.stdout, stderr=sys.stderr)
# Stream cros_run_vm_test's stdout to our stdout while capturing it so we can
# strip out the results json file.
# TODO(crbug.com/835061): Remove all this stdout parsing and just pull the
# file directly.
vm_output = ''
while True:
line = vm_proc.stdout.readline()
if not line:
break
print line, # End with a comma so print doesn't auto append a newline.
vm_output += line
if args.test_launcher_summary_output:
json_contents = vm_output.split(stdout_results_delimiter)[-2]
with open(args.test_launcher_summary_output, 'w') as f:
f.write(json_contents)
return vm_proc.returncode
def main(): def main():
@ -190,6 +177,8 @@ def main():
help='Total number of external shards.') help='Total number of external shards.')
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.WARN)
if not os.path.exists('/dev/kvm'): if not os.path.exists('/dev/kvm'):
logging.error('/dev/kvm is missing. Is KVM installed on this machine?') logging.error('/dev/kvm is missing. Is KVM installed on this machine?')
return 1 return 1