Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into meta/bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Aug 25, 2020
2 parents 4ab7d23 + 59e8120 commit 85812bd
Show file tree
Hide file tree
Showing 25 changed files with 223 additions and 518 deletions.
22 changes: 1 addition & 21 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ deps = {
'7bde79cc274d06451bf65ae82c012a5d3e476b5a',
'crashpad/third_party/mini_chromium/mini_chromium':
Var('chromium_git') + '/chromium/mini_chromium@' +
'891e31d0b649ec9fa98ca5745f9dcd14a34de34c',
'f3cfec80ca521881c97629adf6fcdf21158d635d',
'crashpad/third_party/libfuzzer/src':
Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' +
'fda403cf93ecb8792cb1d061564d89a6553ca020',
Expand Down Expand Up @@ -81,26 +81,6 @@ deps = {
'condition': 'checkout_fuchsia and host_os == "linux"',
'dep_type': 'cipd'
},
'crashpad/third_party/fuchsia/qemu/mac-amd64': {
'packages': [
{
'package': 'fuchsia/qemu/mac-amd64',
'version': 'latest'
},
],
'condition': 'checkout_fuchsia and host_os == "mac"',
'dep_type': 'cipd'
},
'crashpad/third_party/fuchsia/qemu/linux-amd64': {
'packages': [
{
'package': 'fuchsia/qemu/linux-amd64',
'version': 'latest'
},
],
'condition': 'checkout_fuchsia and host_os == "linux"',
'dep_type': 'cipd'
},
'crashpad/third_party/fuchsia/sdk/mac-amd64': {
'packages': [
{
Expand Down
2 changes: 1 addition & 1 deletion build/crashpad_buildconfig.gni
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (crashpad_is_in_chromium) {
crashpad_is_mac = is_mac
crashpad_is_ios = is_ios
crashpad_is_win = is_win
crashpad_is_linux = is_linux
crashpad_is_linux = is_linux || is_chromeos
crashpad_is_android = is_android
crashpad_is_fuchsia = is_fuchsia

Expand Down
145 changes: 0 additions & 145 deletions build/run_fuchsia_qemu.py

This file was deleted.

159 changes: 1 addition & 158 deletions build/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _adb_shell(command_args, env={}):
# pseudo-terminal device, Google Test will not normally enable colored
# output, so mimic Google Test’s own logic for deciding whether to
# enable color by checking this script’s own standard output connection.
# The whitelist of TERM values comes from Google Test’s
# The list of TERM values comes from Google Test’s
# googletest/src/gtest.cc testing::internal::ShouldUseColor().
env = {'CRASHPAD_TEST_DATA_ROOT': device_temp_dir}
gtest_color = os.environ.get('GTEST_COLOR')
Expand All @@ -313,144 +313,6 @@ def _adb_shell(command_args, env={}):
_adb_shell(['rm', '-rf', device_temp_dir])


def _GetFuchsiaSDKRoot():
arch = 'mac-amd64' if sys.platform == 'darwin' else 'linux-amd64'
return os.path.join(CRASHPAD_DIR, 'third_party', 'fuchsia', 'sdk', arch)


def _GenerateFuchsiaRuntimeDepsFiles(binary_dir, tests):
"""Ensures a <binary_dir>/<test>.runtime_deps file exists for each test."""
targets_file = os.path.join(binary_dir, 'targets.txt')
with open(targets_file, 'wb') as f:
f.write('//:' + '\n//:'.join(tests) + '\n')
gn_path = _FindGNFromBinaryDir(binary_dir)
subprocess.check_call([
gn_path, '--root=' + CRASHPAD_DIR, 'gen', binary_dir,
'--runtime-deps-list-file=' + targets_file
])

# Run again so that --runtime-deps-list-file isn't in the regen rule. See
# https://crbug.com/814816.
subprocess.check_call(
[gn_path, '--root=' + CRASHPAD_DIR, 'gen', binary_dir])


def _HandleOutputFromFuchsiaLogListener(process, done_message):
"""Pass through the output from |process| (which should be an instance of
Fuchsia's loglistener) until a special termination |done_message| is
encountered.
Also attempts to determine if any tests failed by inspecting the log output,
and returns False if there were failures.
"""
success = True
while True:
line = process.stdout.readline().rstrip()
if 'FAILED TEST' in line:
success = False
elif done_message in line and 'echo ' not in line:
break
print(line)
return success


def _RunOnFuchsiaTarget(binary_dir, test, device_name, extra_command_line):
"""Runs the given Fuchsia |test| executable on the given |device_name|. The
device must already be booted.
Copies the executable and its runtime dependencies as specified by GN to the
target in /tmp using `netcp`, runs the binary on the target, and logs output
back to stdout on this machine via `loglistener`.
"""
sdk_root = _GetFuchsiaSDKRoot()

# Run loglistener and filter the output to know when the test is done.
loglistener_process = subprocess.Popen(
[os.path.join(sdk_root, 'tools', 'loglistener'), device_name],
stdout=subprocess.PIPE,
stdin=open(os.devnull),
stderr=open(os.devnull))

runtime_deps_file = os.path.join(binary_dir, test + '.runtime_deps')
with open(runtime_deps_file, 'rb') as f:
runtime_deps = f.read().splitlines()

def netruncmd(*args):
"""Runs a list of commands on the target device. Each command is escaped
by using pipes.quote(), and then each command is chained by shell ';'.
"""
netruncmd_path = os.path.join(sdk_root, 'tools', 'netruncmd')
final_args = ' ; '.join(
' '.join(pipes.quote(x) for x in command) for command in args)
subprocess.check_call([netruncmd_path, device_name, final_args])

try:
unique_id = uuid.uuid4().hex
test_root = '/tmp/%s_%s' % (test, unique_id)
tmp_root = test_root + '/tmp'
staging_root = test_root + '/pkg'

# Make a staging directory tree on the target.
directories_to_create = [
tmp_root,
'%s/bin' % staging_root,
'%s/assets' % staging_root
]
netruncmd(['mkdir', '-p'] + directories_to_create)

def netcp(local_path):
"""Uses `netcp` to copy a file or directory to the device. Files
located inside the build dir are stored to /pkg/bin, otherwise to
/pkg/assets. .so files are stored somewhere completely different,
into /boot/lib (!). This is because the loader service does not yet
correctly handle the namespace in which the caller is being run, and
so can only load .so files from a couple hardcoded locations, the
only writable one of which is /boot/lib, so we copy all .so files
there. This bug is filed upstream as ZX-1619.
"""
in_binary_dir = local_path.startswith(binary_dir + '/')
if in_binary_dir:
if local_path.endswith('.so'):
target_path = os.path.join('/boot/lib',
local_path[len(binary_dir) + 1:])
else:
target_path = os.path.join(staging_root, 'bin',
local_path[len(binary_dir) + 1:])
else:
relative_path = os.path.relpath(local_path, CRASHPAD_DIR)
target_path = os.path.join(staging_root, 'assets',
relative_path)
netcp_path = os.path.join(sdk_root, 'tools', 'netcp')
subprocess.check_call(
[netcp_path, local_path, device_name + ':' + target_path],
stderr=open(os.devnull))

# Copy runtime deps into the staging tree.
for dep in runtime_deps:
local_path = os.path.normpath(os.path.join(binary_dir, dep))
if os.path.isdir(local_path):
for root, dirs, files in os.walk(local_path):
for f in files:
netcp(os.path.join(root, f))
else:
netcp(local_path)

done_message = 'TERMINATED: ' + unique_id
namespace_command = [
'namespace', '/pkg=' + staging_root, '/tmp=' + tmp_root,
'/svc=/svc', '--replace-child-argv0=/pkg/bin/' + test, '--',
staging_root + '/bin/' + test
] + extra_command_line
netruncmd(namespace_command, ['echo', done_message])

success = _HandleOutputFromFuchsiaLogListener(loglistener_process,
done_message)
if not success:
raise subprocess.CalledProcessError(1, test)
finally:
netruncmd(['rm', '-rf', test_root])


def _RunOnIOSTarget(binary_dir, test, is_xcuitest=False):
"""Runs the given iOS |test| app on iPhone 8 with the default OS version."""

Expand Down Expand Up @@ -544,7 +406,6 @@ def main(args):

target_os = _BinaryDirTargetOS(args.binary_dir)
is_android = target_os == 'android'
is_fuchsia = target_os == 'fuchsia'
is_ios = target_os == 'ios'

tests = [
Expand Down Expand Up @@ -575,21 +436,6 @@ def main(args):
return 2
android_device = devices[0]
print('Using autodetected Android device:', android_device)
elif is_fuchsia:
zircon_nodename = os.environ.get('ZIRCON_NODENAME')
if not zircon_nodename:
netls = os.path.join(_GetFuchsiaSDKRoot(), 'tools', 'netls')
popen = subprocess.Popen([netls, '--nowait'],
stdout=subprocess.PIPE)
devices = popen.communicate()[0].splitlines()
if popen.returncode != 0 or len(devices) != 1:
print("Please set ZIRCON_NODENAME to your device's hostname",
file=sys.stderr)
return 2
zircon_nodename = devices[0].strip().split()[1]
print('Using autodetected Fuchsia device:', zircon_nodename)
_GenerateFuchsiaRuntimeDepsFiles(
args.binary_dir, [t for t in tests if not t.endswith('.py')])
elif is_ios:
tests.append('ios_crash_xcuitests')
elif IS_WINDOWS_HOST:
Expand Down Expand Up @@ -618,9 +464,6 @@ def main(args):
if is_android:
_RunOnAndroidTarget(args.binary_dir, test, android_device,
extra_command_line)
elif is_fuchsia:
_RunOnFuchsiaTarget(args.binary_dir, test, zircon_nodename,
extra_command_line)
elif is_ios:
_RunOnIOSTarget(args.binary_dir,
test,
Expand Down
1 change: 1 addition & 0 deletions client/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static_library("client") {
deps += [ "../third_party/fuchsia" ]
if (crashpad_is_in_fuchsia) {
deps += [ "//sdk/lib/fdio" ]
configs += [ "//build/config:Wno-conversion" ]
}
}
}
Expand Down
Loading

0 comments on commit 85812bd

Please sign in to comment.