create: add cheeps-feature arg for cheeps AVD am: 68ff738735
Original change: https://android-review.googlesource.com/c/platform/tools/acloud/+/2050875
Change-Id: I7fa889231be111af57d2bf89fbb07136bd9205e4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/create/avd_spec.py b/create/avd_spec.py
index 20a3134..71d0ccc 100644
--- a/create/avd_spec.py
+++ b/create/avd_spec.py
@@ -604,6 +604,8 @@
self._remote_image[constants.CHEEPS_BETTY_IMAGE] = (
args.cheeps_betty_image or self._cfg.betty_image)
+ self._remote_image[constants.CHEEPS_FEATURES] = ','.join(
+ args.cheeps_features)
# Process system image, kernel image, bootloader, and otatools.
self._system_build_info = {constants.BUILD_ID: args.system_build_id,
diff --git a/create/avd_spec_test.py b/create/avd_spec_test.py
index 89497bc..ad41336 100644
--- a/create/avd_spec_test.py
+++ b/create/avd_spec_test.py
@@ -430,6 +430,12 @@
self.AvdSpec.remote_image[constants.CHEEPS_BETTY_IMAGE],
cfg.betty_image)
+ # Verify cheeps_features is assigned from args.
+ self.args.cheeps_features = ['a', 'b', 'c']
+ self.AvdSpec._ProcessRemoteBuildArgs(self.args)
+ self.assertEqual(
+ self.AvdSpec.remote_image[constants.CHEEPS_FEATURES],
+ 'a,b,c')
def testEscapeAnsi(self):
"""Test EscapeAnsi."""
diff --git a/create/create_args.py b/create/create_args.py
index 490ce6a..aa3292d 100644
--- a/create/create_args.py
+++ b/create/create_args.py
@@ -658,6 +658,14 @@
help=("'cheeps only' The L1 betty version to use. Only makes sense "
"when launching a controller image with "
"stable-cheeps-host-image"))
+ create_parser.add_argument(
+ "--cheeps-feature",
+ type=str,
+ dest="cheeps_features",
+ required=False,
+ action="append",
+ default=[],
+ help=("'cheeps only' Cheeps feature to enable. Can be repeated."))
AddCommonCreateArgs(create_parser)
return create_parser
@@ -852,11 +860,13 @@
args.stable_cheeps_host_image_project,
args.username,
args.password,
- args.cheeps_betty_image]
+ args.cheeps_betty_image,
+ args.cheeps_features]
if args.avd_type != constants.TYPE_CHEEPS and any(cheeps_only_flags):
raise errors.UnsupportedCreateArgs(
- "--stable-cheeps-*, --betty-image, --username and --password are "
- "only valid with avd_type == %s" % constants.TYPE_CHEEPS)
+ "--stable-cheeps-*, --betty-image, --cheeps-feature, --username "
+ "and --password are only valid with avd_type == %s"
+ % constants.TYPE_CHEEPS)
if (args.username or args.password) and not (args.username and args.password):
raise ValueError("--username and --password must both be set")
if not args.autoconnect and args.unlock_screen:
diff --git a/create/create_args_test.py b/create/create_args_test.py
index c8a5bb0..788955f 100644
--- a/create/create_args_test.py
+++ b/create/create_args_test.py
@@ -36,6 +36,7 @@
username=None,
password=None,
cheeps_betty_image=None,
+ cheeps_features=[],
local_image=None,
local_kernel_image=None,
local_system_image=None,
diff --git a/internal/constants.py b/internal/constants.py
index ad53c77..ae81865 100755
--- a/internal/constants.py
+++ b/internal/constants.py
@@ -211,6 +211,7 @@
# Cheeps specific stuff.
CHEEPS_BETTY_IMAGE = "betty_image"
+CHEEPS_FEATURES = "cheeps_features"
# Key name in report
ERROR_LOG_FOLDER = "error_log_folder"
diff --git a/internal/lib/cheeps_compute_client.py b/internal/lib/cheeps_compute_client.py
index 31f7dfb..c1d9c4b 100644
--- a/internal/lib/cheeps_compute_client.py
+++ b/internal/lib/cheeps_compute_client.py
@@ -91,6 +91,7 @@
metadata["android_build_id"] = avd_spec.remote_image[constants.BUILD_ID]
metadata["android_build_target"] = avd_spec.remote_image[constants.BUILD_TARGET]
metadata["betty_image"] = avd_spec.remote_image[constants.CHEEPS_BETTY_IMAGE]
+ metadata["cheeps_features"] = avd_spec.remote_image[constants.CHEEPS_FEATURES]
gcompute_client.ComputeClient.CreateInstance(
self,
diff --git a/internal/lib/cheeps_compute_client_test.py b/internal/lib/cheeps_compute_client_test.py
index 8f46f44..4c66695 100644
--- a/internal/lib/cheeps_compute_client_test.py
+++ b/internal/lib/cheeps_compute_client_test.py
@@ -45,6 +45,7 @@
USER = "test_user"
PASSWORD = "test_password"
CHEEPS_BETTY_IMAGE = 'abcasdf'
+ CHEEPS_FEATURES = 'a,b,c'
def _GetFakeConfig(self):
"""Create a fake configuration object.
@@ -88,6 +89,7 @@
'android_build_target': self.ANDROID_BUILD_TARGET,
'avd_type': "cheeps",
'betty_image': self.CHEEPS_BETTY_IMAGE,
+ 'cheeps_features': self.CHEEPS_FEATURES,
'cvd_01_dpi': str(self.DPI),
'cvd_01_x_res': str(self.X_RES),
'cvd_01_y_res': str(self.Y_RES),
@@ -110,6 +112,7 @@
constants.BUILD_ID: self.ANDROID_BUILD_ID,
constants.BUILD_TARGET: self.ANDROID_BUILD_TARGET,
constants.CHEEPS_BETTY_IMAGE: self.CHEEPS_BETTY_IMAGE,
+ constants.CHEEPS_FEATURES: self.CHEEPS_FEATURES,
}
self.cheeps_compute_client.CreateInstance(
@@ -136,6 +139,7 @@
'android_build_target': self.ANDROID_BUILD_TARGET,
'avd_type': "cheeps",
'betty_image': None,
+ 'cheeps_features': None,
'cvd_01_dpi': str(self.DPI),
'cvd_01_x_res': str(self.X_RES),
'cvd_01_y_res': str(self.Y_RES),
@@ -157,6 +161,7 @@
constants.BUILD_ID: self.ANDROID_BUILD_ID,
constants.BUILD_TARGET: self.ANDROID_BUILD_TARGET,
constants.CHEEPS_BETTY_IMAGE: None,
+ constants.CHEEPS_FEATURES: None,
}
self.cheeps_compute_client.CreateInstance(