[Fuchsia][CFv2 Scripts] Support gpu tests
This adds support for running gpu integration tests with the new test scripts, which can be invoked via ./build/fuchsia/test/run_test.py gpu --browser=web-engine-shell \ screenshot_sync --out-dir [OUT_DIR] Change-Id: I8118d99d98b00ff01072cc07afa9fea517a15ca9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3692144 Commit-Queue: Fabrice de Gans <fdegans@chromium.org> Reviewed-by: Zijie He <zijiehe@google.com> Auto-Submit: Chong Gu <chonggu@google.com> Reviewed-by: Fabrice de Gans <fdegans@chromium.org> Cr-Commit-Position: refs/heads/main@{#1024480}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a81a10dfe2
commit
a9db4f3a6b
build/fuchsia
@ -23,6 +23,10 @@ import tempfile
|
||||
import common
|
||||
import log_manager
|
||||
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'test')))
|
||||
from compatible_utils import parse_host_port
|
||||
|
||||
|
||||
def get_ffx_path():
|
||||
"""Returns the full path to `ffx`."""
|
||||
@ -30,27 +34,6 @@ def get_ffx_path():
|
||||
common.GetHostArchFromPlatform(), 'ffx')
|
||||
|
||||
|
||||
def parse_host_port(host_port_pair):
|
||||
"""Parses a host name or IP address and a port number from a string of any of
|
||||
the following forms:
|
||||
- hostname:port
|
||||
- IPv4addy:port
|
||||
- [IPv6addy]:port
|
||||
|
||||
Returns:
|
||||
A tuple of the string host name/address and integer port number.
|
||||
|
||||
Raises:
|
||||
ValueError if `host_port_pair` does not contain a colon or if the substring
|
||||
following the last colon cannot be converted to an int.
|
||||
"""
|
||||
host, port = host_port_pair.rsplit(':', 1)
|
||||
# Strip the brackets if the host looks like an IPv6 address.
|
||||
if len(host) > 2 and host[0] == '[' and host[-1] == ']':
|
||||
host = host[1:-1]
|
||||
return (host, int(port))
|
||||
|
||||
|
||||
def format_host_port(host, port):
|
||||
"""Formats a host name or IP address and port number into a host:port string.
|
||||
"""
|
||||
|
@ -12,6 +12,8 @@ import subprocess
|
||||
from argparse import ArgumentParser
|
||||
from typing import Iterable, List, Optional
|
||||
|
||||
from compatible_utils import parse_host_port
|
||||
|
||||
DIR_SRC_ROOT = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir))
|
||||
REPO_ALIAS = 'fuchsia.com'
|
||||
@ -168,8 +170,27 @@ def resolve_packages(packages: List[str], target_id: Optional[str]) -> None:
|
||||
|
||||
run_ffx_command([
|
||||
'component', 'create', f'/core/ffx-laboratory:{package}',
|
||||
f'fuchsia-pkg://{REPO_ALIAS}/{package}#meta/{package}.cm'
|
||||
f'fuchsia-pkg://{REPO_ALIAS}/{package}#meta/{package}.cmx'
|
||||
], target_id)
|
||||
run_ffx_command(
|
||||
['component', 'resolve', f'/core/ffx-laboratory:{package}'],
|
||||
target_id)
|
||||
|
||||
|
||||
# TODO(crbug.com/1342460): Remove when Telemetry tests are using CFv2 packages.
|
||||
def resolve_v1_packages(packages: List[str], target_id: Optional[str]) -> None:
|
||||
"""Ensure that all cfv1 packages are installed on a device."""
|
||||
|
||||
ssh_address = run_ffx_command(('target', 'get-ssh-address'),
|
||||
target_id,
|
||||
capture_output=True).stdout.strip()
|
||||
address, port = parse_host_port(ssh_address)
|
||||
|
||||
for package in packages:
|
||||
subprocess.run([
|
||||
'ssh', '-F',
|
||||
os.path.expanduser('~/.fuchsia/sshconfig'), address, '-p',
|
||||
str(port), '--', 'pkgctl', 'resolve',
|
||||
'fuchsia-pkg://%s/%s' % (REPO_ALIAS, package)
|
||||
],
|
||||
check=True)
|
||||
|
@ -3,9 +3,34 @@
|
||||
# found in the LICENSE file.
|
||||
"""Functions used in both v1 and v2 scripts."""
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
_FILTER_DIR = 'testing/buildbot/filters'
|
||||
|
||||
|
||||
def parse_host_port(host_port_pair: str) -> Tuple[str, int]:
|
||||
"""Parses a host name or IP address and a port number from a string of
|
||||
any of the following forms:
|
||||
- hostname:port
|
||||
- IPv4addy:port
|
||||
- [IPv6addy]:port
|
||||
|
||||
Returns:
|
||||
A tuple of the string host name/address and integer port number.
|
||||
|
||||
Raises:
|
||||
ValueError if `host_port_pair` does not contain a colon or if the
|
||||
substring following the last colon cannot be converted to an int.
|
||||
"""
|
||||
|
||||
host, port = host_port_pair.rsplit(':', 1)
|
||||
|
||||
# Strip the brackets if the host looks like an IPv6 address.
|
||||
if len(host) >= 4 and host[0] == '[' and host[-1] == ']':
|
||||
host = host[1:-1]
|
||||
return (host, int(port))
|
||||
|
||||
|
||||
# TODO(crbug.com/1279803): Until one can send files to the device when running
|
||||
# a test, filter files must be read from the test package.
|
||||
def map_filter_file_to_package_file(filter_file: str) -> str:
|
||||
|
42
build/fuchsia/test/run_gpu_test.py
Normal file
42
build/fuchsia/test/run_gpu_test.py
Normal file
@ -0,0 +1,42 @@
|
||||
# Copyright 2022 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.
|
||||
"""Implements commands for running GPU tests."""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
from common import DIR_SRC_ROOT
|
||||
from test_runner import TestRunner
|
||||
|
||||
_GPU_TEST_SCRIPT = os.path.join(DIR_SRC_ROOT, 'content', 'test', 'gpu',
|
||||
'run_gpu_integration_test.py')
|
||||
|
||||
|
||||
class GPUTestRunner(TestRunner):
|
||||
"""Test runner for running GPU tests."""
|
||||
|
||||
def __init__(self, out_dir: str, test_args: List[str],
|
||||
target_id: Optional[str]) -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'--browser', help='The browser to use for Telemetry based tests.')
|
||||
args, _ = parser.parse_known_args(test_args)
|
||||
if args.browser == 'web-engine-shell':
|
||||
packages = ['web_engine_with_webui', 'web_engine_shell']
|
||||
elif args.browser == 'fuchsia-chrome':
|
||||
packages = ['chrome']
|
||||
else:
|
||||
raise Exception('Unknown browser %s' % args.browser)
|
||||
super().__init__(out_dir, test_args, packages, target_id)
|
||||
|
||||
def run_test(self):
|
||||
test_cmd = [_GPU_TEST_SCRIPT]
|
||||
if self._test_args:
|
||||
test_cmd.extend(self._test_args)
|
||||
test_cmd.extend(['--chromium-output-directory', self._out_dir])
|
||||
test_cmd.extend(['--fuchsia-target-id', self._target_id])
|
||||
return subprocess.run(test_cmd, check=True)
|
@ -12,12 +12,13 @@ from contextlib import ExitStack
|
||||
from typing import List
|
||||
|
||||
from common import register_common_args, register_device_args, \
|
||||
register_log_args, resolve_packages
|
||||
register_log_args, resolve_packages, resolve_v1_packages
|
||||
from ffx_integration import test_connection
|
||||
from log_manager import LogManager, start_system_log
|
||||
from publish_package import publish_packages, register_package_args
|
||||
from run_blink_test import BlinkTestRunner
|
||||
from run_executable_test import create_executable_test_runner
|
||||
from run_gpu_test import GPUTestRunner
|
||||
from serve_repo import register_serve_args, serve_repository
|
||||
from start_emulator import create_emulator_from_args, register_emulator_args
|
||||
from test_runner import TestRunner
|
||||
@ -26,9 +27,13 @@ from test_runner import TestRunner
|
||||
def _get_test_runner(runner_args: argparse.Namespace,
|
||||
test_args: List[str]) -> TestRunner:
|
||||
"""Initialize a suitable TestRunner class."""
|
||||
|
||||
if runner_args.test_type == 'blink':
|
||||
return BlinkTestRunner(runner_args.out_dir, test_args,
|
||||
runner_args.target_id)
|
||||
if runner_args.test_type == 'gpu':
|
||||
return GPUTestRunner(runner_args.out_dir, test_args,
|
||||
runner_args.target_id)
|
||||
return create_executable_test_runner(runner_args, test_args)
|
||||
|
||||
|
||||
@ -37,7 +42,7 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'test_type',
|
||||
help='The type of test to run. Options include \'blink\''
|
||||
help='The type of test to run. Options include \'blink\', \'gpu\''
|
||||
'or in the case of gtests, the gtest name.')
|
||||
parser.add_argument('--device',
|
||||
'-d',
|
||||
@ -87,7 +92,14 @@ def main():
|
||||
not runner_args.no_repo_init)
|
||||
|
||||
with serve_repository(runner_args):
|
||||
resolve_packages(test_runner.packages, runner_args.target_id)
|
||||
|
||||
# TODO(crbug.com/1342460): Remove when Telemetry and blink_web_tests
|
||||
# are using CFv2 packages.
|
||||
if runner_args.test_type in ['blink', 'gpu']:
|
||||
resolve_v1_packages(test_runner.packages,
|
||||
runner_args.target_id)
|
||||
else:
|
||||
resolve_packages(test_runner.packages, runner_args.target_id)
|
||||
return test_runner.run_test().returncode
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user