Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | # Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Unittests for Toolchain-related operations.""" |
| 7 | |
| 8 | from __future__ import print_function |
| 9 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 10 | from chromite.api import api_config |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 11 | from chromite.api import controller |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 12 | from chromite.api.controller import toolchain |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 13 | from chromite.api.gen.chromite.api import artifacts_pb2 |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 14 | from chromite.api.gen.chromite.api import sysroot_pb2 |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 15 | from chromite.api.gen.chromite.api import toolchain_pb2 |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 16 | from chromite.api.gen.chromiumos.builder_config_pb2 import BuilderConfig |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 17 | from chromite.api.gen.chromiumos import common_pb2 |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 18 | |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 19 | from chromite.lib import cros_build_lib |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 20 | from chromite.lib import cros_test_lib |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 21 | from chromite.lib import toolchain_util |
| 22 | |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 23 | # pylint: disable=protected-access |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 24 | |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 25 | class UpdateEbuildWithAFDOArtifactsTest(cros_test_lib.MockTestCase, |
| 26 | api_config.ApiConfigMixin): |
| 27 | """Unittests for UpdateEbuildWithAFDOArtifacts.""" |
| 28 | |
| 29 | @staticmethod |
| 30 | def mock_die(message, *args): |
| 31 | raise cros_build_lib.DieSystemExit(message % args) |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 32 | |
| 33 | def setUp(self): |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 34 | self.board = 'board' |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 35 | self.response = toolchain_pb2.VerifyAFDOArtifactsResponse() |
| 36 | self.invalid_artifact_type = toolchain_pb2.BENCHMARK_AFDO |
| 37 | self.orderfile_command = self.PatchObject( |
| 38 | toolchain_util, 'OrderfileUpdateChromeEbuild', return_value=True) |
| 39 | self.kernel_command = self.PatchObject( |
| 40 | toolchain_util, 'AFDOUpdateKernelEbuild', return_value=True) |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 41 | self.chrome_command = self.PatchObject( |
| 42 | toolchain_util, 'AFDOUpdateChromeEbuild', return_value=True) |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 43 | self.PatchObject(cros_build_lib, 'Die', new=self.mock_die) |
| 44 | |
| 45 | def _GetRequest(self, build_target=None, artifact_type=None): |
| 46 | return toolchain_pb2.VerifyAFDOArtifactsRequest( |
| 47 | build_target={'name': build_target}, |
| 48 | artifact_type=artifact_type, |
| 49 | ) |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 50 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 51 | def testValidateOnly(self): |
| 52 | """Sanity check that a validate only call does not execute any logic.""" |
| 53 | patch = self.PatchObject(toolchain_util, 'OrderfileUpdateChromeEbuild') |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 54 | request = self._GetRequest( |
| 55 | build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) |
| 56 | toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response, |
| 57 | self.validate_only_config) |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 58 | patch.assert_not_called() |
| 59 | |
Michael Mortensen | 54bd70a | 2019-11-21 14:45:38 -0700 | [diff] [blame] | 60 | def testMockCall(self): |
| 61 | """Test that a mock call does not execute logic, returns mock value.""" |
| 62 | patch = self.PatchObject(toolchain_util, 'OrderfileUpdateChromeEbuild') |
| 63 | request = self._GetRequest( |
| 64 | build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) |
| 65 | toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response, |
| 66 | self.mock_call_config) |
| 67 | patch.assert_not_called() |
| 68 | self.assertEqual(self.response.status, True) |
| 69 | |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 70 | def testWrongArtifactType(self): |
| 71 | """Test passing wrong artifact type.""" |
| 72 | request = self._GetRequest( |
| 73 | build_target=self.board, artifact_type=self.invalid_artifact_type) |
| 74 | with self.assertRaises(cros_build_lib.DieSystemExit) as context: |
| 75 | toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response, |
| 76 | self.api_config) |
| 77 | self.assertIn('artifact_type (%d) must be in' % self.invalid_artifact_type, |
| 78 | str(context.exception)) |
| 79 | |
| 80 | def testOrderfileSuccess(self): |
| 81 | """Test the command is called correctly with orderfile.""" |
| 82 | request = self._GetRequest( |
| 83 | build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) |
| 84 | toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response, |
| 85 | self.api_config) |
| 86 | self.orderfile_command.assert_called_once_with(self.board) |
| 87 | self.kernel_command.assert_not_called() |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 88 | self.chrome_command.assert_not_called() |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 89 | |
| 90 | def testKernelAFDOSuccess(self): |
| 91 | """Test the command is called correctly with kernel afdo.""" |
| 92 | request = self._GetRequest( |
| 93 | build_target=self.board, artifact_type=toolchain_pb2.KERNEL_AFDO) |
| 94 | toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response, |
| 95 | self.api_config) |
| 96 | self.kernel_command.assert_called_once_with(self.board) |
| 97 | self.orderfile_command.assert_not_called() |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 98 | self.chrome_command.assert_not_called() |
| 99 | |
| 100 | def testChromeAFDOSuccess(self): |
| 101 | """Test the command is called correctly with Chrome afdo.""" |
| 102 | request = self._GetRequest( |
| 103 | build_target=self.board, artifact_type=toolchain_pb2.CHROME_AFDO) |
| 104 | toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response, |
| 105 | self.api_config) |
| 106 | self.chrome_command.assert_called_once_with(self.board) |
| 107 | self.orderfile_command.assert_not_called() |
| 108 | self.kernel_command.assert_not_called() |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 109 | |
| 110 | |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 111 | class UploadVettedFDOArtifactsTest(UpdateEbuildWithAFDOArtifactsTest): |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 112 | """Unittests for UploadVettedAFDOArtifacts.""" |
| 113 | |
| 114 | @staticmethod |
| 115 | def mock_die(message, *args): |
| 116 | raise cros_build_lib.DieSystemExit(message % args) |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 117 | |
| 118 | def setUp(self): |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 119 | self.board = 'board' |
| 120 | self.response = toolchain_pb2.VerifyAFDOArtifactsResponse() |
| 121 | self.invalid_artifact_type = toolchain_pb2.BENCHMARK_AFDO |
| 122 | self.command = self.PatchObject( |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 123 | toolchain_util, |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 124 | 'UploadAndPublishVettedAFDOArtifacts', |
| 125 | return_value=True) |
| 126 | self.PatchObject(cros_build_lib, 'Die', new=self.mock_die) |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 127 | |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 128 | def testValidateOnly(self): |
| 129 | """Sanity check that a validate only call does not execute any logic.""" |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 130 | request = self._GetRequest( |
| 131 | build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) |
Michael Mortensen | 54bd70a | 2019-11-21 14:45:38 -0700 | [diff] [blame] | 132 | toolchain.UploadVettedAFDOArtifacts(request, self.response, |
| 133 | self.validate_only_config) |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 134 | self.command.assert_not_called() |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 135 | |
Michael Mortensen | 54bd70a | 2019-11-21 14:45:38 -0700 | [diff] [blame] | 136 | def testMockCall(self): |
| 137 | """Test that a mock call does not execute logic, returns mock value.""" |
| 138 | request = self._GetRequest( |
| 139 | build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) |
| 140 | toolchain.UploadVettedAFDOArtifacts(request, self.response, |
| 141 | self.mock_call_config) |
| 142 | self.command.assert_not_called() |
| 143 | self.assertEqual(self.response.status, True) |
| 144 | |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 145 | def testWrongArtifactType(self): |
| 146 | """Test passing wrong artifact type.""" |
| 147 | request = self._GetRequest( |
| 148 | build_target=self.board, artifact_type=self.invalid_artifact_type) |
| 149 | with self.assertRaises(cros_build_lib.DieSystemExit) as context: |
Michael Mortensen | 54bd70a | 2019-11-21 14:45:38 -0700 | [diff] [blame] | 150 | toolchain.UploadVettedAFDOArtifacts(request, self.response, |
| 151 | self.api_config) |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 152 | self.assertIn('artifact_type (%d) must be in' % self.invalid_artifact_type, |
| 153 | str(context.exception)) |
Alex Klein | 231d2da | 2019-07-22 16:44:45 -0600 | [diff] [blame] | 154 | |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 155 | def testOrderfileSuccess(self): |
| 156 | """Test the command is called correctly with orderfile.""" |
| 157 | request = self._GetRequest( |
| 158 | build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE) |
| 159 | toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config) |
| 160 | self.command.assert_called_once_with('orderfile', self.board) |
Tiancong Wang | af05017 | 2019-07-10 11:52:03 -0700 | [diff] [blame] | 161 | |
Tiancong Wang | 24a3df7 | 2019-08-20 15:48:51 -0700 | [diff] [blame] | 162 | def testKernelAFDOSuccess(self): |
| 163 | """Test the command is called correctly with kernel afdo.""" |
| 164 | request = self._GetRequest( |
| 165 | build_target=self.board, artifact_type=toolchain_pb2.KERNEL_AFDO) |
| 166 | toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config) |
| 167 | self.command.assert_called_once_with('kernel_afdo', self.board) |
Tiancong Wang | f9c736c | 2019-08-26 13:54:38 -0700 | [diff] [blame] | 168 | |
| 169 | def testChromeAFDOSuccess(self): |
| 170 | """Test the command is called correctly with Chrome afdo.""" |
| 171 | request = self._GetRequest( |
| 172 | build_target=self.board, artifact_type=toolchain_pb2.CHROME_AFDO) |
| 173 | toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config) |
| 174 | self.command.assert_called_once_with('chrome_afdo', self.board) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 175 | |
| 176 | |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 177 | class PrepareForBuildTest(cros_test_lib.MockTempDirTestCase, |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 178 | api_config.ApiConfigMixin): |
| 179 | """Unittests for PrepareForBuild.""" |
| 180 | |
| 181 | def setUp(self): |
| 182 | self.response = toolchain_pb2.PrepareForToolchainBuildResponse() |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 183 | self.prep = self.PatchObject( |
| 184 | toolchain_util, 'PrepareForBuild', |
| 185 | return_value=toolchain_util.PrepareForBuildReturn.NEEDED) |
| 186 | self.bundle = self.PatchObject( |
| 187 | toolchain_util, 'BundleArtifacts', return_value=[]) |
| 188 | self.PatchObject(toolchain, '_TOOLCHAIN_ARTIFACT_HANDLERS', { |
| 189 | BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE: |
| 190 | toolchain._Handlers('UnverifiedOrderingFile', |
| 191 | self.prep, self.bundle), |
| 192 | }) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 193 | |
| 194 | def _GetRequest(self, artifact_types=None): |
| 195 | if artifact_types is None: |
| 196 | artifact_types = [] |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 197 | chroot = common_pb2.Chroot(path=self.tempdir) |
| 198 | sysroot = sysroot_pb2.Sysroot( |
| 199 | path='/build/board', build_target=common_pb2.BuildTarget(name='board')) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 200 | return toolchain_pb2.PrepareForToolchainBuildRequest( |
| 201 | artifact_types=artifact_types, |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 202 | chroot=chroot, sysroot=sysroot, |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 203 | ) |
| 204 | |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 205 | def testRaisesForUnknown(self): |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 206 | request = self._GetRequest([BuilderConfig.Artifacts.IMAGE_ARCHIVES]) |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 207 | self.assertRaises( |
| 208 | KeyError, |
| 209 | toolchain.PrepareForBuild, request, self.response, self.api_config) |
| 210 | |
| 211 | def testAcceptsNone(self): |
| 212 | request = toolchain_pb2.PrepareForToolchainBuildRequest( |
| 213 | artifact_types=[BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE], |
| 214 | chroot=None, sysroot=None) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 215 | toolchain.PrepareForBuild(request, self.response, self.api_config) |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 216 | self.prep.assert_called_once_with( |
| 217 | 'UnverifiedOrderingFile', None, '', '', {}) |
| 218 | |
| 219 | def testHandlesUnknownInputArtifacts(self): |
| 220 | request = toolchain_pb2.PrepareForToolchainBuildRequest( |
| 221 | artifact_types=[BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE], |
| 222 | chroot=None, sysroot=None, input_artifacts=[ |
| 223 | BuilderConfig.Artifacts.InputArtifactInfo( |
| 224 | input_artifact_type=BuilderConfig.Artifacts.IMAGE_ZIP, |
| 225 | input_artifact_gs_locations=['path1']), |
| 226 | ]) |
| 227 | toolchain.PrepareForBuild(request, self.response, self.api_config) |
| 228 | self.prep.assert_called_once_with( |
| 229 | 'UnverifiedOrderingFile', None, '', '', {}) |
| 230 | |
| 231 | def testHandlesDuplicateInputArtifacts(self): |
| 232 | request = toolchain_pb2.PrepareForToolchainBuildRequest( |
| 233 | artifact_types=[BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE], |
| 234 | chroot=None, sysroot=None, input_artifacts=[ |
| 235 | BuilderConfig.Artifacts.InputArtifactInfo( |
| 236 | input_artifact_type=\ |
| 237 | BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE, |
| 238 | input_artifact_gs_locations=['path1', 'path2']), |
| 239 | BuilderConfig.Artifacts.InputArtifactInfo( |
| 240 | input_artifact_type=\ |
| 241 | BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE, |
| 242 | input_artifact_gs_locations=['path3']), |
| 243 | ]) |
| 244 | toolchain.PrepareForBuild(request, self.response, self.api_config) |
| 245 | self.prep.assert_called_once_with( |
| 246 | 'UnverifiedOrderingFile', None, '', '', { |
| 247 | 'UnverifiedOrderingFile': [ |
| 248 | 'gs://path1', 'gs://path2', 'gs://path3']}) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 249 | |
| 250 | |
| 251 | class BundleToolchainTest(cros_test_lib.MockTempDirTestCase, |
| 252 | api_config.ApiConfigMixin): |
| 253 | """Unittests for BundleToolchain.""" |
| 254 | |
| 255 | def setUp(self): |
| 256 | self.response = toolchain_pb2.BundleToolchainResponse() |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 257 | self.prep = self.PatchObject( |
| 258 | toolchain_util, 'PrepareForBuild', |
| 259 | return_value=toolchain_util.PrepareForBuildReturn.NEEDED) |
| 260 | self.bundle = self.PatchObject( |
| 261 | toolchain_util, 'BundleArtifacts', return_value=[]) |
| 262 | self.PatchObject(toolchain, '_TOOLCHAIN_ARTIFACT_HANDLERS', { |
| 263 | BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE: |
| 264 | toolchain._Handlers('UnverifiedOrderingFile', |
| 265 | self.prep, self.bundle), |
| 266 | }) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 267 | |
| 268 | def _GetRequest(self, artifact_types=None): |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 269 | chroot = common_pb2.Chroot(path=self.tempdir) |
| 270 | sysroot = sysroot_pb2.Sysroot( |
| 271 | path='/build/board', build_target=common_pb2.BuildTarget(name='board')) |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 272 | return toolchain_pb2.BundleToolchainRequest( |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 273 | chroot=chroot, sysroot=sysroot, |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 274 | output_dir=self.tempdir, |
LaMont Jones | 4579e8c | 2019-12-06 14:20:37 -0700 | [diff] [blame] | 275 | artifact_types=artifact_types, |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 276 | ) |
| 277 | |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 278 | def testRaisesForUnknown(self): |
LaMont Jones | b20b3d9 | 2019-11-23 11:47:48 -0700 | [diff] [blame] | 279 | request = self._GetRequest([BuilderConfig.Artifacts.IMAGE_ARCHIVES]) |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 280 | self.assertEqual( |
| 281 | controller.RETURN_CODE_UNRECOVERABLE, |
| 282 | toolchain.BundleArtifacts(request, self.response, self.api_config)) |
Michael Mortensen | 3232ab3 | 2020-01-05 19:14:36 -0700 | [diff] [blame] | 283 | |
| 284 | def testValidateOnly(self): |
| 285 | """Sanity check that a validate only call does not execute any logic.""" |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 286 | request = self._GetRequest( |
| 287 | [BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE]) |
Michael Mortensen | 3232ab3 | 2020-01-05 19:14:36 -0700 | [diff] [blame] | 288 | toolchain.BundleArtifacts(request, self.response, |
| 289 | self.validate_only_config) |
LaMont Jones | 5d2edcb | 2019-12-23 11:32:03 -0700 | [diff] [blame] | 290 | self.bundle.assert_not_called() |
| 291 | |
| 292 | def testSetsArtifactsInfo(self): |
| 293 | request = self._GetRequest( |
| 294 | [BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE]) |
| 295 | self.bundle.return_value = ['artifact.xz'] |
| 296 | toolchain.BundleArtifacts(request, self.response, self.api_config) |
| 297 | self.assertEqual(1, len(self.response.artifacts_info)) |
| 298 | self.assertEqual( |
| 299 | self.response.artifacts_info[0], |
| 300 | toolchain_pb2.ArtifactInfo( |
| 301 | artifact_type=BuilderConfig.Artifacts.UNVERIFIED_ORDERING_FILE, |
| 302 | artifacts=[ |
| 303 | artifacts_pb2.Artifact(path=self.bundle.return_value[0])])) |