api/sysroot: add simple chrome sysroot artifact
Update the existing CreateSimpleChromeSysroot function and use this
version for the Get() function for the newly defined enum value.
BUG=b:181879769
TEST=modded units, cq
Change-Id: I185a935a4cf012e5fc9319906dcc79961a0d578b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3018566
Reviewed-by: Jack Neus <jackneus@google.com>
Reviewed-by: Alex Klein <saklein@chromium.org>
Tested-by: George Engelbrecht <engeg@google.com>
Commit-Queue: George Engelbrecht <engeg@google.com>
diff --git a/api/controller/sysroot.py b/api/controller/sysroot.py
index 602037a..c13bceb 100644
--- a/api/controller/sysroot.py
+++ b/api/controller/sysroot.py
@@ -32,6 +32,14 @@
uabs = common_pb2.UploadedArtifactsByService
cabs = common_pb2.ArtifactsByService
return uabs.Sysroot(artifacts=[
+ uabs.Sysroot.ArtifactPaths(
+ artifact_type=cabs.Sysroot.ArtifactType.SIMPLE_CHROME_SYSROOT,
+ paths=[
+ common_pb2.Path(
+ path='/tmp/sysroot_chromeos-base_chromeos-chrome.tar.xz',
+ location=common_pb2.Path.OUTSIDE)
+ ],
+ ),
uabs.Sysroot.ArtifactPaths(
artifact_type=cabs.Sysroot.ArtifactType.DEBUG_SYMBOLS,
paths=[
@@ -69,8 +77,10 @@
"""
generated = []
artifact_types = {
+ in_proto.ArtifactType.SIMPLE_CHROME_SYSROOT:
+ sysroot.CreateSimpleChromeSysroot,
in_proto.ArtifactType.BREAKPAD_DEBUG_SYMBOLS: sysroot.BundleBreakpadSymbols,
- in_proto.ArtifactType.DEBUG_SYMBOLS: sysroot.BundleDebugSymbols
+ in_proto.ArtifactType.DEBUG_SYMBOLS: sysroot.BundleDebugSymbols,
}
for output_artifact in in_proto.output_artifacts:
@@ -86,7 +96,6 @@
return generated
-
@faux.all_empty
@validate.require('build_target.name')
@validate.validation_complete
@@ -118,24 +127,6 @@
@faux.all_empty
-@validate.require('build_target.name')
-@validate.validation_complete
-def CreateSimpleChromeSysroot(input_proto, output_proto, _config):
- """Create a sysroot for SimpleChrome to use."""
- build_target_name = input_proto.build_target.name
- use_flags = input_proto.use_flags
-
- sysroot_tar_path = sysroot.CreateSimpleChromeSysroot(build_target_name,
- use_flags)
- # By assigning this Path variable to the tar path, the tar file will be
- # copied out to the input_proto's ResultPath location.
- output_proto.sysroot_archive.path = sysroot_tar_path
- output_proto.sysroot_archive.location = common_pb2.Path.INSIDE
-
- return controller.RETURN_CODE_SUCCESS
-
-
-@faux.all_empty
@validate.require('build_target.name', 'packages')
@validate.require_each('packages', ['category', 'package_name'])
@validate.validation_complete
diff --git a/api/controller/sysroot_unittest.py b/api/controller/sysroot_unittest.py
index f28fc0d..21669b7 100644
--- a/api/controller/sysroot_unittest.py
+++ b/api/controller/sysroot_unittest.py
@@ -155,64 +155,6 @@
self.assertEqual(sysroot_path, out_proto.sysroot.path)
-class CreateSimpleChromeSysrootTest(cros_test_lib.MockTempDirTestCase,
- api_config.ApiConfigMixin):
- """CreateSimpleChromeSysroot function tests."""
-
- def _InputProto(self, build_target=None, use_flags=None):
- """Helper to build and input proto instance."""
- proto = sysroot_pb2.CreateSimpleChromeSysrootRequest()
- if build_target:
- proto.build_target.name = build_target
- if use_flags:
- proto.use_flags = use_flags
- return proto
-
- def _OutputProto(self):
- """Helper to build output proto instance."""
- return sysroot_pb2.CreateSimpleChromeSysrootResponse()
-
- def testValidateOnly(self):
- """Sanity check that a validate only call does not execute any logic."""
- patch = self.PatchObject(sysroot_service, 'CreateSimpleChromeSysroot')
-
- board = 'board'
- in_proto = self._InputProto(build_target=board, use_flags=[])
- sysroot_controller.CreateSimpleChromeSysroot(in_proto, self._OutputProto(),
- self.validate_only_config)
- patch.assert_not_called()
-
- def testMockCall(self):
- """Sanity check that a mock call does not execute any logic."""
- patch = self.PatchObject(sysroot_service, 'CreateSimpleChromeSysroot')
-
- board = 'board'
- in_proto = self._InputProto(build_target=board, use_flags=[])
- rc = sysroot_controller.CreateSimpleChromeSysroot(in_proto,
- self._OutputProto(),
- self.mock_call_config)
- self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
- patch.assert_not_called()
-
- def testArgumentValidation(self):
- """Test the input argument validation."""
- # Error when no build target provided.
- in_proto = self._InputProto()
- out_proto = self._OutputProto()
- with self.assertRaises(cros_build_lib.DieSystemExit):
- sysroot_controller.CreateSimpleChromeSysroot(in_proto, out_proto,
- self.api_config)
-
- # Valid when board is specified.
- patch = self.PatchObject(sysroot_service, 'CreateSimpleChromeSysroot',
- return_value='/path/to/sysroot/tar.bz')
- in_proto = self._InputProto(build_target='board')
- out_proto = self._OutputProto()
- sysroot_controller.CreateSimpleChromeSysroot(in_proto, out_proto,
- self.api_config)
- patch.assert_called_once()
-
-
class GenerateArchiveTest(cros_test_lib.MockTempDirTestCase,
api_config.ApiConfigMixin):
"""GenerateArchive function tests."""