Commit 4f8f9b9d authored by Kevin Marshall's avatar Kevin Marshall Committed by Commit Bot

Fuchsia: adds non-test executable support for V2 runner scripts.

Also redirects program stderr to the stdout stream.

Bug: 798851
Change-Id: I317ef1ab53d6b11b4611f36e4445859bea43a4fa
Reviewed-on: https://chromium-review.googlesource.com/903259
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarScott Graham <scottmg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534590}
parent 3452f187
#!/usr/bin/env python
#
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Packages a user.bootfs for a Fuchsia boot image, pulling in the runtime
dependencies of a test binary, and then uses either QEMU from the Fuchsia SDK
to run, or starts the bootserver to allow running on a hardware device."""
import argparse
import logging
import sys
from common_args import AddCommonArgs, ConfigureLogging, \
GetDeploymentTargetForArgs
from run_package import RunPackage
def main():
parser = argparse.ArgumentParser()
AddCommonArgs(parser)
parser.add_argument('child_args', nargs='*',
help='Arguments for the test process.')
args = parser.parse_args()
ConfigureLogging(args)
with GetDeploymentTargetForArgs(args) as target:
target.Start()
RunPackage(args.output_directory, target, args.package,
args.child_args, args.package_manifest)
if __name__ == '__main__':
sys.exit(main())
...@@ -32,18 +32,23 @@ def RunPackage(output_dir, target, package_path, run_args, symbolizer_config=Non ...@@ -32,18 +32,23 @@ def RunPackage(output_dir, target, package_path, run_args, symbolizer_config=Non
logging.debug(' ' + next_line.strip().split('=')[0]) logging.debug(' ' + next_line.strip().split('=')[0])
logging.debug('') logging.debug('')
# Copy the package. # Deploy the package file to a unique path on the target.
deployed_package_path = '/tmp/package-%s.far' % uuid.uuid1() # The package's UUID length is truncated so as to not overrun the filename
# field in the backtrace output.
unique_package_name = 'package-%s.far' % str(uuid.uuid4())[:18]
deployed_package_path = '/tmp/' + unique_package_name
target.PutFile(package_path, deployed_package_path) target.PutFile(package_path, deployed_package_path)
try: try:
command = ['run', deployed_package_path] + run_args command = ['run', deployed_package_path] + run_args
process = target.RunCommandPiped(command, process = target.RunCommandPiped(command,
stdin=open(os.devnull, 'r'), stdin=open(os.devnull, 'r'),
stdout=subprocess.PIPE) stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
if symbolizer_config: if symbolizer_config:
# Decorate the process output stream with the symbolizer. # Decorate the process output stream with the symbolizer.
output = FilterStream(process.stdout, symbolizer_config, output_dir) output = FilterStream(process.stdout, unique_package_name,
symbolizer_config, output_dir)
else: else:
output = process.stdout output = process.stdout
......
...@@ -47,19 +47,22 @@ def _GetUnstrippedPath(path): ...@@ -47,19 +47,22 @@ def _GetUnstrippedPath(path):
return maybe_unstripped_path return maybe_unstripped_path
def FilterStream(stream, manifest_path, output_dir): def FilterStream(stream, package_name, manifest_path, output_dir):
"""Looks for backtrace lines from an iterable |stream| and symbolizes them. """Looks for backtrace lines from an iterable |stream| and symbolizes them.
Yields a stream of strings with symbolized entries replaced.""" Yields a stream of strings with symbolized entries replaced."""
return _SymbolizerFilter(manifest_path, output_dir).SymbolizeStream(stream) return _SymbolizerFilter(package_name,
manifest_path,
output_dir).SymbolizeStream(stream)
class _SymbolizerFilter(object): class _SymbolizerFilter(object):
"""Adds backtrace symbolization capabilities to a process output stream.""" """Adds backtrace symbolization capabilities to a process output stream."""
def __init__(self, manifest_path, output_dir): def __init__(self, package_name, manifest_path, output_dir):
self._symbols_mapping = {} self._symbols_mapping = {}
self._output_dir = output_dir self._output_dir = output_dir
self._package_name = package_name
# Compute remote/local path mappings using the manifest data. # Compute remote/local path mappings using the manifest data.
for next_line in open(manifest_path): for next_line in open(manifest_path):
...@@ -70,6 +73,8 @@ class _SymbolizerFilter(object): ...@@ -70,6 +73,8 @@ class _SymbolizerFilter(object):
self._symbols_mapping[os.path.basename(target)] = stripped_binary_path self._symbols_mapping[os.path.basename(target)] = stripped_binary_path
self._symbols_mapping[target] = stripped_binary_path self._symbols_mapping[target] = stripped_binary_path
if target == 'bin/app':
self._symbols_mapping[package_name] = stripped_binary_path
logging.debug('Symbols: %s -> %s' % (source, target)) logging.debug('Symbols: %s -> %s' % (source, target))
def _SymbolizeEntries(self, entries): def _SymbolizeEntries(self, entries):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment