blob: 07691b96408a8d15d6a76c64cb171db6fc501018 [file] [log] [blame]
Tiancong Wangaf050172019-07-10 11:52:03 -07001# -*- 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
8from __future__ import print_function
9
Mike Frysingeref94e4c2020-02-10 23:59:54 -050010import sys
11
Alex Klein231d2da2019-07-22 16:44:45 -060012from chromite.api import api_config
LaMont Jones5d2edcb2019-12-23 11:32:03 -070013from chromite.api import controller
Tiancong Wangaf050172019-07-10 11:52:03 -070014from chromite.api.controller import toolchain
LaMont Jones5d2edcb2019-12-23 11:32:03 -070015from chromite.api.gen.chromite.api import artifacts_pb2
LaMont Jones4579e8c2019-12-06 14:20:37 -070016from chromite.api.gen.chromite.api import sysroot_pb2
Tiancong Wangaf050172019-07-10 11:52:03 -070017from chromite.api.gen.chromite.api import toolchain_pb2
LaMont Jonesb20b3d92019-11-23 11:47:48 -070018from chromite.api.gen.chromiumos.builder_config_pb2 import BuilderConfig
LaMont Jones4579e8c2019-12-06 14:20:37 -070019from chromite.api.gen.chromiumos import common_pb2
Tiancong Wangaf050172019-07-10 11:52:03 -070020
Tiancong Wang24a3df72019-08-20 15:48:51 -070021from chromite.lib import cros_build_lib
Tiancong Wangaf050172019-07-10 11:52:03 -070022from chromite.lib import cros_test_lib
Tiancong Wangaf050172019-07-10 11:52:03 -070023from chromite.lib import toolchain_util
24
Mike Frysingeref94e4c2020-02-10 23:59:54 -050025
26assert sys.version_info >= (3, 6), 'This module requires Python 3.6+'
27
28
LaMont Jones5d2edcb2019-12-23 11:32:03 -070029# pylint: disable=protected-access
Tiancong Wangaf050172019-07-10 11:52:03 -070030
Tiancong Wang24a3df72019-08-20 15:48:51 -070031class UpdateEbuildWithAFDOArtifactsTest(cros_test_lib.MockTestCase,
32 api_config.ApiConfigMixin):
33 """Unittests for UpdateEbuildWithAFDOArtifacts."""
34
35 @staticmethod
36 def mock_die(message, *args):
37 raise cros_build_lib.DieSystemExit(message % args)
Tiancong Wangaf050172019-07-10 11:52:03 -070038
39 def setUp(self):
Tiancong Wangaf050172019-07-10 11:52:03 -070040 self.board = 'board'
Tiancong Wang24a3df72019-08-20 15:48:51 -070041 self.response = toolchain_pb2.VerifyAFDOArtifactsResponse()
42 self.invalid_artifact_type = toolchain_pb2.BENCHMARK_AFDO
43 self.orderfile_command = self.PatchObject(
44 toolchain_util, 'OrderfileUpdateChromeEbuild', return_value=True)
45 self.kernel_command = self.PatchObject(
46 toolchain_util, 'AFDOUpdateKernelEbuild', return_value=True)
Tiancong Wangf9c736c2019-08-26 13:54:38 -070047 self.chrome_command = self.PatchObject(
48 toolchain_util, 'AFDOUpdateChromeEbuild', return_value=True)
Tiancong Wang24a3df72019-08-20 15:48:51 -070049 self.PatchObject(cros_build_lib, 'Die', new=self.mock_die)
50
51 def _GetRequest(self, build_target=None, artifact_type=None):
52 return toolchain_pb2.VerifyAFDOArtifactsRequest(
53 build_target={'name': build_target},
54 artifact_type=artifact_type,
55 )
Tiancong Wangaf050172019-07-10 11:52:03 -070056
Alex Klein231d2da2019-07-22 16:44:45 -060057 def testValidateOnly(self):
58 """Sanity check that a validate only call does not execute any logic."""
59 patch = self.PatchObject(toolchain_util, 'OrderfileUpdateChromeEbuild')
Tiancong Wang24a3df72019-08-20 15:48:51 -070060 request = self._GetRequest(
61 build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE)
62 toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response,
63 self.validate_only_config)
Alex Klein231d2da2019-07-22 16:44:45 -060064 patch.assert_not_called()
65
Michael Mortensen54bd70a2019-11-21 14:45:38 -070066 def testMockCall(self):
67 """Test that a mock call does not execute logic, returns mock value."""
68 patch = self.PatchObject(toolchain_util, 'OrderfileUpdateChromeEbuild')
69 request = self._GetRequest(
70 build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE)
71 toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response,
72 self.mock_call_config)
73 patch.assert_not_called()
74 self.assertEqual(self.response.status, True)
75
Tiancong Wang24a3df72019-08-20 15:48:51 -070076 def testWrongArtifactType(self):
77 """Test passing wrong artifact type."""
78 request = self._GetRequest(
79 build_target=self.board, artifact_type=self.invalid_artifact_type)
80 with self.assertRaises(cros_build_lib.DieSystemExit) as context:
81 toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response,
82 self.api_config)
83 self.assertIn('artifact_type (%d) must be in' % self.invalid_artifact_type,
84 str(context.exception))
85
86 def testOrderfileSuccess(self):
87 """Test the command is called correctly with orderfile."""
88 request = self._GetRequest(
89 build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE)
90 toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response,
91 self.api_config)
92 self.orderfile_command.assert_called_once_with(self.board)
93 self.kernel_command.assert_not_called()
Tiancong Wangf9c736c2019-08-26 13:54:38 -070094 self.chrome_command.assert_not_called()
Tiancong Wang24a3df72019-08-20 15:48:51 -070095
96 def testKernelAFDOSuccess(self):
97 """Test the command is called correctly with kernel afdo."""
98 request = self._GetRequest(
99 build_target=self.board, artifact_type=toolchain_pb2.KERNEL_AFDO)
100 toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response,
101 self.api_config)
102 self.kernel_command.assert_called_once_with(self.board)
103 self.orderfile_command.assert_not_called()
Tiancong Wangf9c736c2019-08-26 13:54:38 -0700104 self.chrome_command.assert_not_called()
105
106 def testChromeAFDOSuccess(self):
107 """Test the command is called correctly with Chrome afdo."""
108 request = self._GetRequest(
109 build_target=self.board, artifact_type=toolchain_pb2.CHROME_AFDO)
110 toolchain.UpdateEbuildWithAFDOArtifacts(request, self.response,
111 self.api_config)
112 self.chrome_command.assert_called_once_with(self.board)
113 self.orderfile_command.assert_not_called()
114 self.kernel_command.assert_not_called()
Tiancong Wangaf050172019-07-10 11:52:03 -0700115
116
Tiancong Wangf9c736c2019-08-26 13:54:38 -0700117class UploadVettedFDOArtifactsTest(UpdateEbuildWithAFDOArtifactsTest):
Tiancong Wang24a3df72019-08-20 15:48:51 -0700118 """Unittests for UploadVettedAFDOArtifacts."""
119
120 @staticmethod
121 def mock_die(message, *args):
122 raise cros_build_lib.DieSystemExit(message % args)
Tiancong Wangaf050172019-07-10 11:52:03 -0700123
124 def setUp(self):
Tiancong Wang24a3df72019-08-20 15:48:51 -0700125 self.board = 'board'
126 self.response = toolchain_pb2.VerifyAFDOArtifactsResponse()
127 self.invalid_artifact_type = toolchain_pb2.BENCHMARK_AFDO
128 self.command = self.PatchObject(
Tiancong Wangaf050172019-07-10 11:52:03 -0700129 toolchain_util,
Tiancong Wang24a3df72019-08-20 15:48:51 -0700130 'UploadAndPublishVettedAFDOArtifacts',
131 return_value=True)
132 self.PatchObject(cros_build_lib, 'Die', new=self.mock_die)
Tiancong Wangaf050172019-07-10 11:52:03 -0700133
Alex Klein231d2da2019-07-22 16:44:45 -0600134 def testValidateOnly(self):
135 """Sanity check that a validate only call does not execute any logic."""
Tiancong Wang24a3df72019-08-20 15:48:51 -0700136 request = self._GetRequest(
137 build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE)
Michael Mortensen54bd70a2019-11-21 14:45:38 -0700138 toolchain.UploadVettedAFDOArtifacts(request, self.response,
139 self.validate_only_config)
Tiancong Wang24a3df72019-08-20 15:48:51 -0700140 self.command.assert_not_called()
Alex Klein231d2da2019-07-22 16:44:45 -0600141
Michael Mortensen54bd70a2019-11-21 14:45:38 -0700142 def testMockCall(self):
143 """Test that a mock call does not execute logic, returns mock value."""
144 request = self._GetRequest(
145 build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE)
146 toolchain.UploadVettedAFDOArtifacts(request, self.response,
147 self.mock_call_config)
148 self.command.assert_not_called()
149 self.assertEqual(self.response.status, True)
150
Tiancong Wang24a3df72019-08-20 15:48:51 -0700151 def testWrongArtifactType(self):
152 """Test passing wrong artifact type."""
153 request = self._GetRequest(
154 build_target=self.board, artifact_type=self.invalid_artifact_type)
155 with self.assertRaises(cros_build_lib.DieSystemExit) as context:
Michael Mortensen54bd70a2019-11-21 14:45:38 -0700156 toolchain.UploadVettedAFDOArtifacts(request, self.response,
157 self.api_config)
Tiancong Wang24a3df72019-08-20 15:48:51 -0700158 self.assertIn('artifact_type (%d) must be in' % self.invalid_artifact_type,
159 str(context.exception))
Alex Klein231d2da2019-07-22 16:44:45 -0600160
Tiancong Wang24a3df72019-08-20 15:48:51 -0700161 def testOrderfileSuccess(self):
162 """Test the command is called correctly with orderfile."""
163 request = self._GetRequest(
164 build_target=self.board, artifact_type=toolchain_pb2.ORDERFILE)
165 toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config)
166 self.command.assert_called_once_with('orderfile', self.board)
Tiancong Wangaf050172019-07-10 11:52:03 -0700167
Tiancong Wang24a3df72019-08-20 15:48:51 -0700168 def testKernelAFDOSuccess(self):
169 """Test the command is called correctly with kernel afdo."""
170 request = self._GetRequest(
171 build_target=self.board, artifact_type=toolchain_pb2.KERNEL_AFDO)
172 toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config)
173 self.command.assert_called_once_with('kernel_afdo', self.board)
Tiancong Wangf9c736c2019-08-26 13:54:38 -0700174
175 def testChromeAFDOSuccess(self):
176 """Test the command is called correctly with Chrome afdo."""
177 request = self._GetRequest(
178 build_target=self.board, artifact_type=toolchain_pb2.CHROME_AFDO)
179 toolchain.UploadVettedAFDOArtifacts(request, self.response, self.api_config)
180 self.command.assert_called_once_with('chrome_afdo', self.board)
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700181
182
LaMont Jones4579e8c2019-12-06 14:20:37 -0700183class PrepareForBuildTest(cros_test_lib.MockTempDirTestCase,
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700184 api_config.ApiConfigMixin):
185 """Unittests for PrepareForBuild."""
186
187 def setUp(self):
188 self.response = toolchain_pb2.PrepareForToolchainBuildResponse()
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700189 self.prep = self.PatchObject(
190 toolchain_util, 'PrepareForBuild',
191 return_value=toolchain_util.PrepareForBuildReturn.NEEDED)
192 self.bundle = self.PatchObject(
193 toolchain_util, 'BundleArtifacts', return_value=[])
194 self.PatchObject(toolchain, '_TOOLCHAIN_ARTIFACT_HANDLERS', {
LaMont Jonescd1503d2020-03-04 09:09:59 -0700195 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE:
LaMont Jonesd3944582020-03-04 10:37:05 -0700196 toolchain._Handlers('UnverifiedChromeLlvmOrderfile',
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700197 self.prep, self.bundle),
198 })
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700199
LaMont Jones45ca6c42020-02-05 09:39:09 -0700200 def _GetRequest(
201 self, artifact_types=None, input_artifacts=None, additional_args=None):
LaMont Jones4579e8c2019-12-06 14:20:37 -0700202 chroot = common_pb2.Chroot(path=self.tempdir)
203 sysroot = sysroot_pb2.Sysroot(
204 path='/build/board', build_target=common_pb2.BuildTarget(name='board'))
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700205 return toolchain_pb2.PrepareForToolchainBuildRequest(
LaMont Jones45ca6c42020-02-05 09:39:09 -0700206 artifact_types=artifact_types, chroot=chroot, sysroot=sysroot,
207 input_artifacts=input_artifacts, additional_args=additional_args)
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700208
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700209 def testRaisesForUnknown(self):
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700210 request = self._GetRequest([BuilderConfig.Artifacts.IMAGE_ARCHIVES])
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700211 self.assertRaises(
212 KeyError,
213 toolchain.PrepareForBuild, request, self.response, self.api_config)
214
215 def testAcceptsNone(self):
216 request = toolchain_pb2.PrepareForToolchainBuildRequest(
LaMont Jonescd1503d2020-03-04 09:09:59 -0700217 artifact_types=[
218 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE],
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700219 chroot=None, sysroot=None)
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700220 toolchain.PrepareForBuild(request, self.response, self.api_config)
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700221 self.prep.assert_called_once_with(
LaMont Jonesd3944582020-03-04 10:37:05 -0700222 'UnverifiedChromeLlvmOrderfile', None, '', '', {}, {})
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700223
224 def testHandlesUnknownInputArtifacts(self):
225 request = toolchain_pb2.PrepareForToolchainBuildRequest(
LaMont Jonescd1503d2020-03-04 09:09:59 -0700226 artifact_types=[
227 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE],
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700228 chroot=None, sysroot=None, input_artifacts=[
229 BuilderConfig.Artifacts.InputArtifactInfo(
230 input_artifact_type=BuilderConfig.Artifacts.IMAGE_ZIP,
231 input_artifact_gs_locations=['path1']),
232 ])
233 toolchain.PrepareForBuild(request, self.response, self.api_config)
234 self.prep.assert_called_once_with(
LaMont Jonesd3944582020-03-04 10:37:05 -0700235 'UnverifiedChromeLlvmOrderfile', None, '', '', {}, {})
LaMont Jones45ca6c42020-02-05 09:39:09 -0700236
LaMont Jonese7821672020-04-09 08:56:26 -0600237 def testPassesProfileInfo(self):
LaMont Jones45ca6c42020-02-05 09:39:09 -0700238 request = toolchain_pb2.PrepareForToolchainBuildRequest(
LaMont Jonescd1503d2020-03-04 09:09:59 -0700239 artifact_types=[
240 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE],
LaMont Jones45ca6c42020-02-05 09:39:09 -0700241 chroot=None, sysroot=None, input_artifacts=[
242 BuilderConfig.Artifacts.InputArtifactInfo(
243 input_artifact_type=\
LaMont Jonescd1503d2020-03-04 09:09:59 -0700244 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE,
LaMont Jones45ca6c42020-02-05 09:39:09 -0700245 input_artifact_gs_locations=['path1', 'path2']),
246 BuilderConfig.Artifacts.InputArtifactInfo(
247 input_artifact_type=\
LaMont Jonescd1503d2020-03-04 09:09:59 -0700248 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE,
LaMont Jones45ca6c42020-02-05 09:39:09 -0700249 input_artifact_gs_locations=['path3']),
250 ],
LaMont Jonese7821672020-04-09 08:56:26 -0600251 profile_info=common_pb2.ArtifactProfileInfo(
LaMont Jones45ca6c42020-02-05 09:39:09 -0700252 chrome_cwp_profile='CWPVERSION'),
253 )
254 toolchain.PrepareForBuild(request, self.response, self.api_config)
255 self.prep.assert_called_once_with(
LaMont Jonesd3944582020-03-04 10:37:05 -0700256 'UnverifiedChromeLlvmOrderfile', None, '', '', {
257 'UnverifiedChromeLlvmOrderfile': [
258 'gs://path1', 'gs://path2', 'gs://path3'],
259 },
LaMont Jones45ca6c42020-02-05 09:39:09 -0700260 {'chrome_cwp_profile': 'CWPVERSION'})
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700261
LaMont Jonese7821672020-04-09 08:56:26 -0600262 def testPassesProfileInfoAfdoRelease(self):
263 request = toolchain_pb2.PrepareForToolchainBuildRequest(
264 artifact_types=[
265 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE],
266 chroot=None, sysroot=None, input_artifacts=[
267 BuilderConfig.Artifacts.InputArtifactInfo(
268 input_artifact_type=\
269 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE,
270 input_artifact_gs_locations=['path1', 'path2']),
271 BuilderConfig.Artifacts.InputArtifactInfo(
272 input_artifact_type=\
273 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE,
274 input_artifact_gs_locations=['path3']),
275 ],
276 profile_info=common_pb2.ArtifactProfileInfo(
277 afdo_release=common_pb2.AfdoRelease(
278 chrome_cwp_profile='CWPVERSION',
279 image_build_id=1234)),
280 )
281 toolchain.PrepareForBuild(request, self.response, self.api_config)
282 self.prep.assert_called_once_with(
283 'UnverifiedChromeLlvmOrderfile', None, '', '', {
284 'UnverifiedChromeLlvmOrderfile': [
285 'gs://path1', 'gs://path2', 'gs://path3'],
286 },
287 {'chrome_cwp_profile': 'CWPVERSION', 'image_build_id': 1234})
288
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700289 def testHandlesDuplicateInputArtifacts(self):
290 request = toolchain_pb2.PrepareForToolchainBuildRequest(
LaMont Jonescd1503d2020-03-04 09:09:59 -0700291 artifact_types=[
292 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE],
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700293 chroot=None, sysroot=None, input_artifacts=[
294 BuilderConfig.Artifacts.InputArtifactInfo(
295 input_artifact_type=\
LaMont Jonescd1503d2020-03-04 09:09:59 -0700296 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE,
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700297 input_artifact_gs_locations=['path1', 'path2']),
298 BuilderConfig.Artifacts.InputArtifactInfo(
299 input_artifact_type=\
LaMont Jonescd1503d2020-03-04 09:09:59 -0700300 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE,
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700301 input_artifact_gs_locations=['path3']),
302 ])
303 toolchain.PrepareForBuild(request, self.response, self.api_config)
304 self.prep.assert_called_once_with(
LaMont Jonesd3944582020-03-04 10:37:05 -0700305 'UnverifiedChromeLlvmOrderfile', None, '', '', {
306 'UnverifiedChromeLlvmOrderfile': [
307 'gs://path1', 'gs://path2', 'gs://path3'],
308 }, {})
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700309
310
311class BundleToolchainTest(cros_test_lib.MockTempDirTestCase,
312 api_config.ApiConfigMixin):
313 """Unittests for BundleToolchain."""
314
315 def setUp(self):
316 self.response = toolchain_pb2.BundleToolchainResponse()
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700317 self.prep = self.PatchObject(
318 toolchain_util, 'PrepareForBuild',
319 return_value=toolchain_util.PrepareForBuildReturn.NEEDED)
320 self.bundle = self.PatchObject(
321 toolchain_util, 'BundleArtifacts', return_value=[])
322 self.PatchObject(toolchain, '_TOOLCHAIN_ARTIFACT_HANDLERS', {
LaMont Jonescd1503d2020-03-04 09:09:59 -0700323 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE:
LaMont Jonesd3944582020-03-04 10:37:05 -0700324 toolchain._Handlers('UnverifiedChromeLlvmOrderfile',
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700325 self.prep, self.bundle),
326 })
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700327
328 def _GetRequest(self, artifact_types=None):
LaMont Jones4579e8c2019-12-06 14:20:37 -0700329 chroot = common_pb2.Chroot(path=self.tempdir)
330 sysroot = sysroot_pb2.Sysroot(
331 path='/build/board', build_target=common_pb2.BuildTarget(name='board'))
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700332 return toolchain_pb2.BundleToolchainRequest(
LaMont Jones4579e8c2019-12-06 14:20:37 -0700333 chroot=chroot, sysroot=sysroot,
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700334 output_dir=self.tempdir,
LaMont Jones4579e8c2019-12-06 14:20:37 -0700335 artifact_types=artifact_types,
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700336 )
337
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700338 def testRaisesForUnknown(self):
LaMont Jonesb20b3d92019-11-23 11:47:48 -0700339 request = self._GetRequest([BuilderConfig.Artifacts.IMAGE_ARCHIVES])
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700340 self.assertEqual(
341 controller.RETURN_CODE_UNRECOVERABLE,
342 toolchain.BundleArtifacts(request, self.response, self.api_config))
Michael Mortensen3232ab32020-01-05 19:14:36 -0700343
344 def testValidateOnly(self):
345 """Sanity check that a validate only call does not execute any logic."""
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700346 request = self._GetRequest(
LaMont Jonescd1503d2020-03-04 09:09:59 -0700347 [BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE])
Michael Mortensen3232ab32020-01-05 19:14:36 -0700348 toolchain.BundleArtifacts(request, self.response,
349 self.validate_only_config)
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700350 self.bundle.assert_not_called()
351
352 def testSetsArtifactsInfo(self):
353 request = self._GetRequest(
LaMont Jonescd1503d2020-03-04 09:09:59 -0700354 [BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE])
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700355 self.bundle.return_value = ['artifact.xz']
356 toolchain.BundleArtifacts(request, self.response, self.api_config)
357 self.assertEqual(1, len(self.response.artifacts_info))
358 self.assertEqual(
359 self.response.artifacts_info[0],
360 toolchain_pb2.ArtifactInfo(
LaMont Jonescd1503d2020-03-04 09:09:59 -0700361 artifact_type=(
362 BuilderConfig.Artifacts.UNVERIFIED_CHROME_LLVM_ORDERFILE),
LaMont Jones5d2edcb2019-12-23 11:32:03 -0700363 artifacts=[
364 artifacts_pb2.Artifact(path=self.bundle.return_value[0])]))