Skip to content

Commit 1bd22c4

Browse files
committed
target: tests: Add support for testing ChromeOS targets
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 <metin.kaya@arm.com>
1 parent 24a084e commit 1bd22c4

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

tests/target_configs.yaml.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ AndroidTarget:
33
connection_settings:
44
device: 'emulator-5554'
55

6+
ChromeOsTarget:
7+
entry-0:
8+
connection_settings:
9+
device: 'emulator-5556'
10+
host: 'example.com'
11+
username: 'username'
12+
password: 'password'
13+
614
LinuxTarget:
715
entry-0:
816
connection_settings:

tests/test_target.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from pprint import pp
2121
import pytest
2222

23-
from devlib import AndroidTarget, LinuxTarget, LocalLinuxTarget, QEMUTargetRunner
23+
from devlib import AndroidTarget, ChromeOsTarget, LinuxTarget, LocalLinuxTarget, QEMUTargetRunner
2424
from devlib.utils.android import AdbConnection
2525
from devlib.utils.misc import load_struct_from_yaml
2626

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

56+
if target_configs.get('ChromeOsTarget') is not None:
57+
print('> ChromeOS targets:')
58+
for entry in target_configs['ChromeOsTarget'].values():
59+
pp(entry)
60+
c_target = ChromeOsTarget(
61+
connection_settings=entry['connection_settings'],
62+
working_directory='/tmp/devlib-target',
63+
)
64+
targets.append((c_target, None))
65+
5666
if target_configs.get('LocalLinuxTarget') is not None:
5767
print('> LocalLinux targets:')
5868
for entry in target_configs['LocalLinuxTarget'].values():
@@ -72,7 +82,24 @@ def build_targets():
7282
qemu_settings=qemu_settings,
7383
connection_settings=connection_settings,
7484
)
75-
targets.append((qemu_runner.target, qemu_runner))
85+
86+
if entry.get('ChromeOsTarget') is None:
87+
targets.append((qemu_runner.target, qemu_runner))
88+
continue
89+
90+
# Leave termination of QEMU runner to ChromeOS target.
91+
targets.append((qemu_runner.target, None))
92+
93+
print('> ChromeOS targets:')
94+
pp(entry['ChromeOsTarget'])
95+
c_target = ChromeOsTarget(
96+
connection_settings={
97+
**entry['ChromeOsTarget']['connection_settings'],
98+
**qemu_runner.target.connection_settings,
99+
},
100+
working_directory='/tmp/devlib-target',
101+
)
102+
targets.append((c_target, qemu_runner))
76103

77104
return targets
78105

0 commit comments

Comments
 (0)