Skip to content

Commit

Permalink
target: tests: Add support for testing ChromeOS targets
Browse files Browse the repository at this point in the history
We can mimic ChromeOS target by combining a QEMU guest (for Linux
bindings of ``ChromeOsTarget`` class) with a Android virtual desktop
(for Android bits of ``ChromeOsTarget``).

Note that Android bindings of ``ChromeOsTarget`` class also requires
existence of ``/opt/google/containers/android`` folder on the Linux
guest.

Signed-off-by: Metin Kaya <[email protected]>
  • Loading branch information
metin-arm committed Mar 27, 2024
1 parent 24a084e commit 1bd22c4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/target_configs.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ AndroidTarget:
connection_settings:
device: 'emulator-5554'

ChromeOsTarget:
entry-0:
connection_settings:
device: 'emulator-5556'
host: 'example.com'
username: 'username'
password: 'password'

LinuxTarget:
entry-0:
connection_settings:
Expand Down
31 changes: 29 additions & 2 deletions tests/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pprint import pp
import pytest

from devlib import AndroidTarget, LinuxTarget, LocalLinuxTarget, QEMUTargetRunner
from devlib import AndroidTarget, ChromeOsTarget, LinuxTarget, LocalLinuxTarget, QEMUTargetRunner
from devlib.utils.android import AdbConnection
from devlib.utils.misc import load_struct_from_yaml

Expand Down Expand Up @@ -53,6 +53,16 @@ def build_targets():
l_target = LinuxTarget(connection_settings=entry['connection_settings'])
targets.append((l_target, None))

if target_configs.get('ChromeOsTarget') is not None:
print('> ChromeOS targets:')
for entry in target_configs['ChromeOsTarget'].values():
pp(entry)
c_target = ChromeOsTarget(
connection_settings=entry['connection_settings'],
working_directory='/tmp/devlib-target',
)
targets.append((c_target, None))

if target_configs.get('LocalLinuxTarget') is not None:
print('> LocalLinux targets:')
for entry in target_configs['LocalLinuxTarget'].values():
Expand All @@ -72,7 +82,24 @@ def build_targets():
qemu_settings=qemu_settings,
connection_settings=connection_settings,
)
targets.append((qemu_runner.target, qemu_runner))

if entry.get('ChromeOsTarget') is None:
targets.append((qemu_runner.target, qemu_runner))
continue

# Leave termination of QEMU runner to ChromeOS target.
targets.append((qemu_runner.target, None))

print('> ChromeOS targets:')
pp(entry['ChromeOsTarget'])
c_target = ChromeOsTarget(
connection_settings={
**entry['ChromeOsTarget']['connection_settings'],
**qemu_runner.target.connection_settings,
},
working_directory='/tmp/devlib-target',
)
targets.append((c_target, qemu_runner))

return targets

Expand Down

0 comments on commit 1bd22c4

Please sign in to comment.