[fuchsia] - migrate devicer discovery workflows to use ffx (#76241)

This commit is contained in:
omerlevran46
2021-03-01 13:16:13 -08:00
committed by GitHub
parent 54455c706d
commit f996033fcc
12 changed files with 483 additions and 54 deletions

View File

@@ -13,7 +13,7 @@
# The first and only parameter should be the path to the Fuchsia system image
# tarball, e.g. `./run_fuchsia_tests.sh generic-x64.tgz`.
#
# This script expects `pm`, `device-finder`, and `fuchsia_ctl` to all be in the
# This script expects `pm`, `ffx`, and `fuchsia_ctl` to all be in the
# same directory as the script.
#
# This script also expects a private key available at:
@@ -44,7 +44,7 @@ fi
# Wrapper function to pass common args to fuchsia_ctl.
fuchsia_ctl() {
$script_dir/fuchsia_ctl -d $device_name \
--device-finder-path $script_dir/device-finder "$@"
--ffx-path $script_dir/ffx "$@"
}
reboot() {
@@ -115,6 +115,8 @@ EOF
export FUCHSIA_SSH_CONFIG=$script_dir/fuchsia_ssh_config
export FUCHSIA_ANALYTICS_DISABLED="1"
# Run the driver test
echo "$(date) START:DRIVER_TEST -------------------------------------"
flutter_dir=$script_dir/flutter

View File

@@ -327,12 +327,12 @@ class FuchsiaDeviceDiscovery implements DeviceDiscovery {
FuchsiaDevice _workingDevice;
String get _devFinder {
final String devFinder = path.join(getArtifactPath(), 'fuchsia', 'tools', 'device-finder');
if (!File(devFinder).existsSync()) {
throw FileSystemException("Couldn't find device-finder at location $devFinder");
String get _ffx {
final String ffx = path.join(getArtifactPath(), 'fuchsia', 'tools','x64', 'ffx');
if (!File(ffx).existsSync()) {
throw FileSystemException("Couldn't find ffx at location $ffx");
}
return devFinder;
return ffx;
}
@override
@@ -378,7 +378,7 @@ class FuchsiaDeviceDiscovery implements DeviceDiscovery {
@override
Future<List<String>> discoverDevices() async {
final List<String> output = (await eval(_devFinder, <String>['list', '-full']))
final List<String> output = (await eval(_ffx, <String>['target', 'list', '--format', 's']))
.trim()
.split('\n');
@@ -396,16 +396,20 @@ class FuchsiaDeviceDiscovery implements DeviceDiscovery {
final Map<String, HealthCheckResult> results = <String, HealthCheckResult>{};
for (final String deviceId in await discoverDevices()) {
try {
StringBuffer stderr;
final int resolveResult = await exec(
_devFinder,
_ffx,
<String>[
'resolve',
'-device-limit',
'1',
'target',
'list',
'--format',
'a',
deviceId,
]
],
stderr: stderr
);
if (resolveResult == 0) {
final String stderrOutput = stderr.toString().trim();
if (resolveResult == 0 && ! stderrOutput.contains('No devices found')) {
results['fuchsia-device-$deviceId'] = HealthCheckResult.success();
} else {
results['fuchsia-device-$deviceId'] = HealthCheckResult.failure('Cannot resolve device $deviceId');

View File

@@ -322,6 +322,7 @@ Future<int> exec(
List<String> arguments, {
Map<String, String> environment,
bool canFail = false, // as in, whether failures are ok. False means that they are fatal.
StringBuffer stderr, // if not null, the stderr will be written here
String workingDirectory,
}) async {
return _execute(
@@ -329,6 +330,7 @@ Future<int> exec(
arguments,
environment: environment,
canFail : canFail,
stderr: stderr,
workingDirectory: workingDirectory,
);
}