blob: b99021cec272102a8b8aa1878629145fb3ce78c5 [file] [log] [blame]
Alex Kleina2e42c42019-04-17 16:13:19 -06001# Copyright 2019 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""The test controller tests."""
6
Alex Klein9f915782020-02-14 23:15:09 +00007import contextlib
Lizzy Presland4feb2372022-01-20 05:16:30 +00008import datetime
Mike Frysingeref94e4c2020-02-10 23:59:54 -05009import os
Mike Frysinger3bb61cb2022-04-14 16:07:44 -040010from pathlib import Path
Mike Frysinger40443592022-05-05 13:03:40 -040011from typing import Union
Mike Frysinger166fea02021-02-12 05:30:33 -050012from unittest import mock
Mike Frysingeref94e4c2020-02-10 23:59:54 -050013
Mike Frysinger1cc8f1f2022-04-28 22:40:40 -040014from chromite.third_party.google.protobuf import json_format
15
Alex Klein231d2da2019-07-22 16:44:45 -060016from chromite.api import api_config
Alex Klein8cb365a2019-05-15 16:24:53 -060017from chromite.api import controller
Lizzy Presland4feb2372022-01-20 05:16:30 +000018from chromite.api.controller import controller_util
Alex Kleina2e42c42019-04-17 16:13:19 -060019from chromite.api.controller import test as test_controller
20from chromite.api.gen.chromite.api import test_pb2
Mike Frysinger1cc8f1f2022-04-28 22:40:40 -040021from chromite.api.gen.chromiumos import common_pb2
Sean McAllister3834fef2021-10-08 15:45:18 -060022from chromite.api.gen.chromiumos.build.api import container_metadata_pb2
Jack Neusc9707c32021-07-23 21:48:54 +000023from chromite.lib import build_target_lib
Evan Hernandeze1e05d32019-07-19 12:32:18 -060024from chromite.lib import chroot_lib
Alex Kleina2e42c42019-04-17 16:13:19 -060025from chromite.lib import cros_build_lib
26from chromite.lib import cros_test_lib
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -060027from chromite.lib import image_lib
Alex Kleina2e42c42019-04-17 16:13:19 -060028from chromite.lib import osutils
David Wellingc1433c22021-06-25 16:29:48 +000029from chromite.lib import sysroot_lib
Alex Klein18a60af2020-06-11 12:08:47 -060030from chromite.lib.parser import package_info
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -060031from chromite.scripts import cros_set_lsb_release
32from chromite.service import test as test_service
Mike Frysingere652ba12019-09-08 00:57:43 -040033from chromite.utils import key_value_store
Alex Kleina2e42c42019-04-17 16:13:19 -060034
35
Michael Mortensen8ca4d3b2019-11-27 09:35:22 -070036class DebugInfoTestTest(cros_test_lib.MockTempDirTestCase,
37 api_config.ApiConfigMixin):
38 """Tests for the DebugInfoTest function."""
39
40 def setUp(self):
41 self.board = 'board'
42 self.chroot_path = os.path.join(self.tempdir, 'chroot')
43 self.sysroot_path = '/build/board'
44 self.full_sysroot_path = os.path.join(self.chroot_path,
45 self.sysroot_path.lstrip(os.sep))
46 osutils.SafeMakedirs(self.full_sysroot_path)
47
48 def _GetInput(self, sysroot_path=None, build_target=None):
49 """Helper to build an input message instance."""
50 proto = test_pb2.DebugInfoTestRequest()
51 if sysroot_path:
52 proto.sysroot.path = sysroot_path
53 if build_target:
54 proto.sysroot.build_target.name = build_target
55 return proto
56
57 def _GetOutput(self):
58 """Helper to get an empty output message instance."""
59 return test_pb2.DebugInfoTestResponse()
60
61 def testValidateOnly(self):
62 """Sanity check that a validate only call does not execute any logic."""
63 patch = self.PatchObject(test_service, 'DebugInfoTest')
64 input_msg = self._GetInput(sysroot_path=self.full_sysroot_path)
65 test_controller.DebugInfoTest(input_msg, self._GetOutput(),
66 self.validate_only_config)
67 patch.assert_not_called()
68
Michael Mortensen85d38402019-12-12 09:50:29 -070069 def testMockError(self):
70 """Test mock error call does not execute any logic, returns error."""
71 patch = self.PatchObject(test_service, 'DebugInfoTest')
72
73 input_msg = self._GetInput(sysroot_path=self.full_sysroot_path)
74 rc = test_controller.DebugInfoTest(input_msg, self._GetOutput(),
75 self.mock_error_config)
76 patch.assert_not_called()
77 self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
78
79 def testMockCall(self):
80 """Test mock call does not execute any logic, returns success."""
81 patch = self.PatchObject(test_service, 'DebugInfoTest')
82
83 input_msg = self._GetInput(sysroot_path=self.full_sysroot_path)
84 rc = test_controller.DebugInfoTest(input_msg, self._GetOutput(),
85 self.mock_call_config)
86 patch.assert_not_called()
87 self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
88
Michael Mortensen8ca4d3b2019-11-27 09:35:22 -070089 def testNoBuildTargetNoSysrootFails(self):
90 """Test missing build target name and sysroot path fails."""
91 input_msg = self._GetInput()
92 output_msg = self._GetOutput()
93 with self.assertRaises(cros_build_lib.DieSystemExit):
94 test_controller.DebugInfoTest(input_msg, output_msg, self.api_config)
95
96 def testDebugInfoTest(self):
97 """Call DebugInfoTest with valid sysroot_path."""
98 request = self._GetInput(sysroot_path=self.full_sysroot_path)
99
100 test_controller.DebugInfoTest(request, self._GetOutput(), self.api_config)
101
102
Alex Klein231d2da2019-07-22 16:44:45 -0600103class BuildTargetUnitTestTest(cros_test_lib.MockTempDirTestCase,
104 api_config.ApiConfigMixin):
Alex Kleina2e42c42019-04-17 16:13:19 -0600105 """Tests for the UnitTest function."""
106
Lizzy Presland4feb2372022-01-20 05:16:30 +0000107 def setUp(self):
108 # Set up portage log directory.
109 self.sysroot = os.path.join(self.tempdir, 'build', 'board')
110 osutils.SafeMakedirs(self.sysroot)
111 self.target_sysroot = sysroot_lib.Sysroot(self.sysroot)
112 self.portage_dir = os.path.join(self.tempdir, 'portage_logdir')
113 self.PatchObject(
114 sysroot_lib.Sysroot, 'portage_logdir', new=self.portage_dir)
115 osutils.SafeMakedirs(self.portage_dir)
116
Navil Perezc0b29a82020-07-07 14:17:48 +0000117 def _GetInput(self,
118 board=None,
119 result_path=None,
120 chroot_path=None,
121 cache_dir=None,
122 empty_sysroot=None,
123 packages=None,
Alex Kleinb64e5f82020-09-23 10:55:31 -0600124 blocklist=None):
Alex Kleina2e42c42019-04-17 16:13:19 -0600125 """Helper to build an input message instance."""
Navil Perezc0b29a82020-07-07 14:17:48 +0000126 formatted_packages = []
127 for pkg in packages or []:
128 formatted_packages.append({
129 'category': pkg.category,
130 'package_name': pkg.package
131 })
Alex Kleinb64e5f82020-09-23 10:55:31 -0600132 formatted_blocklist = []
133 for pkg in blocklist or []:
134 formatted_blocklist.append({'category': pkg.category,
Alex Kleinf2674462019-05-16 16:47:24 -0600135 'package_name': pkg.package})
136
Mike Frysinger3bb61cb2022-04-14 16:07:44 -0400137 # Protobufs can't handle Path objects.
138 if isinstance(result_path, Path):
139 result_path = str(result_path)
140
Alex Kleina2e42c42019-04-17 16:13:19 -0600141 return test_pb2.BuildTargetUnitTestRequest(
142 build_target={'name': board}, result_path=result_path,
Alex Kleinfa6ebdc2019-05-10 10:57:31 -0600143 chroot={'path': chroot_path, 'cache_dir': cache_dir},
Alex Kleinf2674462019-05-16 16:47:24 -0600144 flags={'empty_sysroot': empty_sysroot},
Alex Klein64ac34c2020-09-23 10:21:33 -0600145 packages=formatted_packages,
Alex Klein157caf42021-07-01 14:36:43 -0600146 package_blocklist=formatted_blocklist,
Alex Kleina2e42c42019-04-17 16:13:19 -0600147 )
148
149 def _GetOutput(self):
150 """Helper to get an empty output message instance."""
151 return test_pb2.BuildTargetUnitTestResponse()
152
Mike Frysinger40443592022-05-05 13:03:40 -0400153 def _CreatePortageLogFile(self,
154 log_path: Union[str, os.PathLike],
155 pkg_info: package_info.PackageInfo,
156 timestamp: datetime.datetime) -> str:
Lizzy Presland4feb2372022-01-20 05:16:30 +0000157 """Creates a log file for testing for individual packages built by Portage.
158
159 Args:
Mike Frysinger40443592022-05-05 13:03:40 -0400160 log_path: The PORTAGE_LOGDIR path.
161 pkg_info: name components for log file.
162 timestamp: Timestamp used to name the file.
Lizzy Presland4feb2372022-01-20 05:16:30 +0000163 """
164 path = os.path.join(log_path,
165 f'{pkg_info.category}:{pkg_info.pvr}:' \
166 f'{timestamp.strftime("%Y%m%d-%H%M%S")}.log')
167 osutils.WriteFile(path,
168 f'Test log file for package {pkg_info.category}/'
169 f'{pkg_info.package} written to {path}')
170 return path
171
Alex Klein231d2da2019-07-22 16:44:45 -0600172 def testValidateOnly(self):
173 """Sanity check that a validate only call does not execute any logic."""
174 patch = self.PatchObject(test_service, 'BuildTargetUnitTest')
175
176 input_msg = self._GetInput(board='board', result_path=self.tempdir)
177 test_controller.BuildTargetUnitTest(input_msg, self._GetOutput(),
178 self.validate_only_config)
179 patch.assert_not_called()
180
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700181 def testMockCall(self):
182 """Test that a mock call does not execute logic, returns mocked value."""
183 patch = self.PatchObject(test_service, 'BuildTargetUnitTest')
184
185 input_msg = self._GetInput(board='board', result_path=self.tempdir)
186 response = self._GetOutput()
187 test_controller.BuildTargetUnitTest(input_msg, response,
188 self.mock_call_config)
189 patch.assert_not_called()
190 self.assertEqual(response.tarball_path,
191 os.path.join(input_msg.result_path, 'unit_tests.tar'))
192
193 def testMockError(self):
Michael Mortensen85d38402019-12-12 09:50:29 -0700194 """Test that a mock error does not execute logic, returns error."""
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700195 patch = self.PatchObject(test_service, 'BuildTargetUnitTest')
196
197 input_msg = self._GetInput(board='board', result_path=self.tempdir)
198 response = self._GetOutput()
199 rc = test_controller.BuildTargetUnitTest(input_msg, response,
200 self.mock_error_config)
201 patch.assert_not_called()
202 self.assertEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc)
Lizzy Presland239459a2022-05-05 22:03:19 +0000203 self.assertTrue(response.failed_package_data)
204 self.assertEqual(response.failed_package_data[0].name.category, 'foo')
205 self.assertEqual(response.failed_package_data[0].name.package_name, 'bar')
206 self.assertEqual(response.failed_package_data[1].name.category, 'cat')
207 self.assertEqual(response.failed_package_data[1].name.package_name, 'pkg')
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700208
Alex Klein64ac34c2020-09-23 10:21:33 -0600209 def testInvalidPackageFails(self):
210 """Test missing result path fails."""
211 # Missing result_path.
212 pkg = package_info.PackageInfo(package='bar')
213 input_msg = self._GetInput(board='board', result_path=self.tempdir,
214 packages=[pkg])
215 output_msg = self._GetOutput()
216 with self.assertRaises(cros_build_lib.DieSystemExit):
217 test_controller.BuildTargetUnitTest(input_msg, output_msg,
218 self.api_config)
219
Alex Kleina2e42c42019-04-17 16:13:19 -0600220 def testPackageBuildFailure(self):
221 """Test handling of raised BuildPackageFailure."""
222 tempdir = osutils.TempDir(base_dir=self.tempdir)
223 self.PatchObject(osutils, 'TempDir', return_value=tempdir)
224
Lizzy Presland4feb2372022-01-20 05:16:30 +0000225 pkgs = ['cat/pkg-1.0-r1', 'foo/bar-2.0-r1']
226 cpvrs = [package_info.parse(pkg) for pkg in pkgs]
Alex Kleina2e42c42019-04-17 16:13:19 -0600227 expected = [('cat', 'pkg'), ('foo', 'bar')]
Lizzy Presland4feb2372022-01-20 05:16:30 +0000228 new_logs = {}
229 for i, pkg in enumerate(pkgs):
230 self._CreatePortageLogFile(self.portage_dir, cpvrs[i],
231 datetime.datetime(2021, 6, 9, 13, 37, 0))
232 new_logs[pkg] = self._CreatePortageLogFile(self.portage_dir, cpvrs[i],
233 datetime.datetime(2021, 6, 9,
234 16, 20, 0))
Alex Kleina2e42c42019-04-17 16:13:19 -0600235
Alex Klein38c7d9e2019-05-08 09:31:19 -0600236 result = test_service.BuildTargetUnitTestResult(1, None)
Alex Kleinea0c89e2021-09-09 15:17:35 -0600237 result.failed_pkgs = [package_info.parse(p) for p in pkgs]
Alex Klein38c7d9e2019-05-08 09:31:19 -0600238 self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result)
Alex Kleina2e42c42019-04-17 16:13:19 -0600239
240 input_msg = self._GetInput(board='board', result_path=self.tempdir)
241 output_msg = self._GetOutput()
242
Alex Klein231d2da2019-07-22 16:44:45 -0600243 rc = test_controller.BuildTargetUnitTest(input_msg, output_msg,
244 self.api_config)
Alex Kleina2e42c42019-04-17 16:13:19 -0600245
Alex Klein8cb365a2019-05-15 16:24:53 -0600246 self.assertEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc)
Lizzy Presland4feb2372022-01-20 05:16:30 +0000247 self.assertTrue(output_msg.failed_package_data)
Alex Kleina2e42c42019-04-17 16:13:19 -0600248
Lizzy Presland4feb2372022-01-20 05:16:30 +0000249 failed_with_logs = []
250 for data in output_msg.failed_package_data:
251 failed_with_logs.append((data.name.category, data.name.package_name))
252 package = controller_util.deserialize_package_info(data.name)
253 self.assertEqual(data.log_path.path, new_logs[package.cpvr])
254 self.assertCountEqual(expected, failed_with_logs)
255
256
Alex Kleina2e42c42019-04-17 16:13:19 -0600257 def testOtherBuildScriptFailure(self):
258 """Test build script failure due to non-package emerge error."""
259 tempdir = osutils.TempDir(base_dir=self.tempdir)
260 self.PatchObject(osutils, 'TempDir', return_value=tempdir)
261
Alex Klein38c7d9e2019-05-08 09:31:19 -0600262 result = test_service.BuildTargetUnitTestResult(1, None)
263 self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result)
Alex Kleina2e42c42019-04-17 16:13:19 -0600264
Alex Kleinf2674462019-05-16 16:47:24 -0600265 pkgs = ['foo/bar', 'cat/pkg']
Alex Kleinb64e5f82020-09-23 10:55:31 -0600266 blocklist = [package_info.SplitCPV(p, strict=False) for p in pkgs]
Alex Klein2e91e522022-01-14 09:22:03 -0700267 input_msg = self._GetInput(board='board', empty_sysroot=True,
268 blocklist=blocklist)
Alex Kleina2e42c42019-04-17 16:13:19 -0600269 output_msg = self._GetOutput()
270
Alex Klein231d2da2019-07-22 16:44:45 -0600271 rc = test_controller.BuildTargetUnitTest(input_msg, output_msg,
272 self.api_config)
Alex Kleina2e42c42019-04-17 16:13:19 -0600273
Alex Klein8cb365a2019-05-15 16:24:53 -0600274 self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
Lizzy Presland239459a2022-05-05 22:03:19 +0000275 self.assertFalse(output_msg.failed_package_data)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600276
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700277 def testBuildTargetUnitTest(self):
278 """Test BuildTargetUnitTest successful call."""
Navil Perezc0b29a82020-07-07 14:17:48 +0000279 pkgs = ['foo/bar', 'cat/pkg']
Alex Klein18a60af2020-06-11 12:08:47 -0600280 packages = [package_info.SplitCPV(p, strict=False) for p in pkgs]
Alex Klein2e91e522022-01-14 09:22:03 -0700281 input_msg = self._GetInput(board='board', packages=packages)
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700282
283 result = test_service.BuildTargetUnitTestResult(0, None)
284 self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result)
285
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700286 response = self._GetOutput()
287 test_controller.BuildTargetUnitTest(input_msg, response,
288 self.api_config)
Lizzy Presland239459a2022-05-05 22:03:19 +0000289 self.assertFalse(response.failed_package_data)
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700290
Evan Hernandez4e388a52019-05-01 12:16:33 -0600291
Sean McAllister17eed8d2021-09-21 10:41:16 -0600292class DockerConstraintsTest(cros_test_lib.MockTestCase):
293 """Tests for Docker argument constraints."""
294
295 def assertValid(self, output):
296 return output is None
297
298 def assertInvalid(self, output):
299 return not self.assertValid(output)
300
301 def testValidDockerTag(self):
302 """Check logic for validating docker tag format."""
303 # pylint: disable=protected-access
304
305 invalid_tags = [
306 '.invalid-tag',
307 '-invalid-tag',
308 'invalid-tag;',
309 'invalid'*100,
310 ]
311
312 for tag in invalid_tags:
313 self.assertInvalid(test_controller._ValidDockerTag(tag))
314
315 valid_tags = [
316 'valid-tag',
317 'valid-tag-',
318 'valid.tag.',
319 ]
320
321 for tag in valid_tags:
322 self.assertValid(test_controller._ValidDockerTag(tag))
323
324
325 def testValidDockerLabelKey(self):
326 """Check logic for validating docker label key format."""
327 # pylint: disable=protected-access
328
329 invalid_keys = [
330 'Invalid-keY',
331 'Invalid-key',
332 'invalid-keY',
333 'iNVALID-KEy',
334 'invalid_key',
335 'invalid-key;',
336 ]
337
338 for key in invalid_keys:
339 self.assertInvalid(test_controller._ValidDockerLabelKey(key))
340
341 valid_keys = [
342 'chromeos.valid-key',
343 'chromeos.valid-key-2',
344 ]
345
346 for key in valid_keys:
347 self.assertValid(test_controller._ValidDockerLabelKey(key))
348
349
Sean McAllister3834fef2021-10-08 15:45:18 -0600350class BuildTestServiceContainers(cros_test_lib.RunCommandTempDirTestCase,
David Wellingc1433c22021-06-25 16:29:48 +0000351 api_config.ApiConfigMixin):
C Shapiro91af1ce2021-06-17 12:42:09 -0500352 """Tests for the BuildTestServiceContainers function."""
353
354 def setUp(self):
355 self.request = test_pb2.BuildTestServiceContainersRequest(
356 chroot={'path': '/path/to/chroot'},
357 build_target={'name': 'build_target'},
David Wellingc1433c22021-06-25 16:29:48 +0000358 version='R93-14033.0.0',
C Shapiro91af1ce2021-06-17 12:42:09 -0500359 )
360
C Shapiro91af1ce2021-06-17 12:42:09 -0500361 def testSuccess(self):
362 """Check passing case with mocked cros_build_lib.run."""
Sean McAllister3834fef2021-10-08 15:45:18 -0600363
364 def ContainerMetadata():
365 """Return mocked ContainerImageInfo proto"""
366 metadata = container_metadata_pb2.ContainerImageInfo()
367 metadata.repository.hostname = 'gcr.io'
368 metadata.repository.project = 'chromeos-bot'
369 metadata.name = 'random-container-name'
370 metadata.digest = (
371 '09b730f8b6a862f9c2705cb3acf3554563325f5fca5c784bf5c98beb2e56f6db')
372 metadata.tags[:] = [
373 'staging-cq-amd64-generic.R96-1.2.3',
374 '8834106026340379089',
375 ]
376 return metadata
377
378 def WriteContainerMetadata(path):
379 """Write json formatted metadata to the given file."""
380 osutils.WriteFile(
381 path,
382 json_format.MessageToJson(ContainerMetadata()),
383 )
384
385 # Write out mocked container metadata to a temporary file.
386 output_path = os.path.join(self.tempdir, 'metadata.jsonpb')
387 self.rc.SetDefaultCmdResult(
388 returncode=0,
389 side_effect=lambda *_, **__: WriteContainerMetadata(output_path)
390 )
391
392 # Patch TempDir so that we always use this test's directory.
393 self.PatchObject(osutils.TempDir, '__enter__', return_value=self.tempdir)
C Shapiro91af1ce2021-06-17 12:42:09 -0500394
395 response = test_pb2.BuildTestServiceContainersResponse()
396 test_controller.BuildTestServiceContainers(
397 self.request,
398 response,
399 self.api_config)
Sean McAllister3834fef2021-10-08 15:45:18 -0600400
401 self.assertTrue(self.rc.called)
C Shapiro91af1ce2021-06-17 12:42:09 -0500402 for result in response.results:
403 self.assertEqual(result.WhichOneof('result'), 'success')
Sean McAllister3834fef2021-10-08 15:45:18 -0600404 self.assertEqual(result.success.image_info, ContainerMetadata())
C Shapiro91af1ce2021-06-17 12:42:09 -0500405
C Shapiro91af1ce2021-06-17 12:42:09 -0500406 def testFailure(self):
407 """Check failure case with mocked cros_build_lib.run."""
408 patch = self.PatchObject(
409 cros_build_lib, 'run',
410 return_value=cros_build_lib.CommandResult(returncode=1))
411
412 response = test_pb2.BuildTestServiceContainersResponse()
413 test_controller.BuildTestServiceContainers(
414 self.request,
415 response,
416 self.api_config)
417 patch.assert_called()
418 for result in response.results:
Derek Beckett27eaa162022-05-09 10:42:53 -0700419 self.assertEqual(result.WhichOneof('result'), 'failure')
Derek Beckett344b5a82022-05-09 17:21:45 -0700420 self.assertEqual(result.name, 'Service Builder')
C Shapiro91af1ce2021-06-17 12:42:09 -0500421
Michael Mortensen8ca4d3b2019-11-27 09:35:22 -0700422class ChromiteUnitTestTest(cros_test_lib.MockTestCase,
423 api_config.ApiConfigMixin):
424 """Tests for the ChromiteInfoTest function."""
425
426 def setUp(self):
427 self.board = 'board'
428 self.chroot_path = '/path/to/chroot'
429
430 def _GetInput(self, chroot_path=None):
431 """Helper to build an input message instance."""
432 proto = test_pb2.ChromiteUnitTestRequest(
433 chroot={'path': chroot_path},
434 )
435 return proto
436
437 def _GetOutput(self):
438 """Helper to get an empty output message instance."""
439 return test_pb2.ChromiteUnitTestResponse()
440
441 def testValidateOnly(self):
442 """Sanity check that a validate only call does not execute any logic."""
443 patch = self.PatchObject(cros_build_lib, 'run')
444
445 input_msg = self._GetInput(chroot_path=self.chroot_path)
446 test_controller.ChromiteUnitTest(input_msg, self._GetOutput(),
447 self.validate_only_config)
448 patch.assert_not_called()
449
Michael Mortensen7a860eb2019-12-03 20:25:15 -0700450 def testMockError(self):
451 """Test mock error call does not execute any logic, returns error."""
452 patch = self.PatchObject(cros_build_lib, 'run')
453
454 input_msg = self._GetInput(chroot_path=self.chroot_path)
455 rc = test_controller.ChromiteUnitTest(input_msg, self._GetOutput(),
456 self.mock_error_config)
457 patch.assert_not_called()
458 self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
459
460 def testMockCall(self):
461 """Test mock call does not execute any logic, returns success."""
462 patch = self.PatchObject(cros_build_lib, 'run')
463
464 input_msg = self._GetInput(chroot_path=self.chroot_path)
465 rc = test_controller.ChromiteUnitTest(input_msg, self._GetOutput(),
466 self.mock_call_config)
467 patch.assert_not_called()
468 self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
469
Michael Mortensen8ca4d3b2019-11-27 09:35:22 -0700470 def testChromiteUnitTest(self):
471 """Call ChromiteUnitTest with mocked cros_build_lib.run."""
472 request = self._GetInput(chroot_path=self.chroot_path)
473 patch = self.PatchObject(
474 cros_build_lib, 'run',
475 return_value=cros_build_lib.CommandResult(returncode=0))
476
477 test_controller.ChromiteUnitTest(request, self._GetOutput(),
478 self.api_config)
479 patch.assert_called_once()
480
481
Alex Klein4bc8f4f2019-08-16 14:53:30 -0600482class CrosSigningTestTest(cros_test_lib.RunCommandTestCase,
483 api_config.ApiConfigMixin):
484 """CrosSigningTest tests."""
485
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700486 def setUp(self):
487 self.chroot_path = '/path/to/chroot'
488
489 def _GetInput(self, chroot_path=None):
490 """Helper to build an input message instance."""
491 proto = test_pb2.CrosSigningTestRequest(
492 chroot={'path': chroot_path},
493 )
494 return proto
495
496 def _GetOutput(self):
497 """Helper to get an empty output message instance."""
498 return test_pb2.CrosSigningTestResponse()
499
Alex Klein4bc8f4f2019-08-16 14:53:30 -0600500 def testValidateOnly(self):
501 """Sanity check that a validate only call does not execute any logic."""
502 test_controller.CrosSigningTest(None, None, self.validate_only_config)
503 self.assertFalse(self.rc.call_count)
504
Michael Mortensen7a7646d2019-12-12 15:36:14 -0700505 def testMockCall(self):
506 """Test mock call does not execute any logic, returns success."""
507 rc = test_controller.CrosSigningTest(None, None, self.mock_call_config)
508 self.assertFalse(self.rc.call_count)
509 self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
510
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700511 def testCrosSigningTest(self):
512 """Call CrosSigningTest with mocked cros_build_lib.run."""
513 request = self._GetInput(chroot_path=self.chroot_path)
514 patch = self.PatchObject(
515 cros_build_lib, 'run',
516 return_value=cros_build_lib.CommandResult(returncode=0))
517
518 test_controller.CrosSigningTest(request, self._GetOutput(),
519 self.api_config)
520 patch.assert_called_once()
521
Alex Klein4bc8f4f2019-08-16 14:53:30 -0600522
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600523class SimpleChromeWorkflowTestTest(cros_test_lib.MockTestCase,
524 api_config.ApiConfigMixin):
525 """Test the SimpleChromeWorkflowTest endpoint."""
526
527 @staticmethod
528 def _Output():
529 return test_pb2.SimpleChromeWorkflowTestResponse()
530
David Wellingc1433c22021-06-25 16:29:48 +0000531 def _Input(self,
532 sysroot_path=None,
533 build_target=None,
534 chrome_root=None,
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600535 goma_config=None):
536 proto = test_pb2.SimpleChromeWorkflowTestRequest()
537 if sysroot_path:
538 proto.sysroot.path = sysroot_path
539 if build_target:
540 proto.sysroot.build_target.name = build_target
541 if chrome_root:
542 proto.chrome_root = chrome_root
543 if goma_config:
544 proto.goma_config = goma_config
545 return proto
546
547 def setUp(self):
548 self.chrome_path = 'path/to/chrome'
549 self.sysroot_dir = 'build/board'
550 self.build_target = 'amd64'
551 self.mock_simple_chrome_workflow_test = self.PatchObject(
552 test_service, 'SimpleChromeWorkflowTest')
553
554 def testMissingBuildTarget(self):
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700555 """Test SimpleChromeWorkflowTest dies when build_target not set."""
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600556 input_proto = self._Input(build_target=None, sysroot_path='/sysroot/dir',
557 chrome_root='/chrome/path')
558 with self.assertRaises(cros_build_lib.DieSystemExit):
559 test_controller.SimpleChromeWorkflowTest(input_proto, None,
560 self.api_config)
561
562 def testMissingSysrootPath(self):
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700563 """Test SimpleChromeWorkflowTest dies when build_target not set."""
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600564 input_proto = self._Input(build_target='board', sysroot_path=None,
565 chrome_root='/chrome/path')
566 with self.assertRaises(cros_build_lib.DieSystemExit):
567 test_controller.SimpleChromeWorkflowTest(input_proto, None,
568 self.api_config)
569
570 def testMissingChromeRoot(self):
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700571 """Test SimpleChromeWorkflowTest dies when build_target not set."""
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600572 input_proto = self._Input(build_target='board', sysroot_path='/sysroot/dir',
573 chrome_root=None)
574 with self.assertRaises(cros_build_lib.DieSystemExit):
575 test_controller.SimpleChromeWorkflowTest(input_proto, None,
576 self.api_config)
577
578 def testSimpleChromeWorkflowTest(self):
579 """Call SimpleChromeWorkflowTest with valid args and temp dir."""
580 request = self._Input(sysroot_path='sysroot_path', build_target='board',
581 chrome_root='/path/to/chrome')
582 response = self._Output()
583
584 test_controller.SimpleChromeWorkflowTest(request, response, self.api_config)
585 self.mock_simple_chrome_workflow_test.assert_called()
586
587 def testValidateOnly(self):
588 request = self._Input(sysroot_path='sysroot_path', build_target='board',
589 chrome_root='/path/to/chrome')
590 test_controller.SimpleChromeWorkflowTest(request, self._Output(),
591 self.validate_only_config)
592 self.mock_simple_chrome_workflow_test.assert_not_called()
593
Michael Mortensen7a7646d2019-12-12 15:36:14 -0700594 def testMockCall(self):
595 """Test mock call does not execute any logic, returns success."""
596 patch = self.mock_simple_chrome_workflow_test = self.PatchObject(
597 test_service, 'SimpleChromeWorkflowTest')
598
599 request = self._Input(sysroot_path='sysroot_path', build_target='board',
600 chrome_root='/path/to/chrome')
601 rc = test_controller.SimpleChromeWorkflowTest(request, self._Output(),
602 self.mock_call_config)
603 patch.assert_not_called()
604 self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
605
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600606
Alex Klein231d2da2019-07-22 16:44:45 -0600607class VmTestTest(cros_test_lib.RunCommandTestCase, api_config.ApiConfigMixin):
Evan Hernandez4e388a52019-05-01 12:16:33 -0600608 """Test the VmTest endpoint."""
609
610 def _GetInput(self, **kwargs):
611 values = dict(
612 build_target=common_pb2.BuildTarget(name='target'),
Alex Klein311b8022019-06-05 16:00:07 -0600613 vm_path=common_pb2.Path(path='/path/to/image.bin',
614 location=common_pb2.Path.INSIDE),
Evan Hernandez4e388a52019-05-01 12:16:33 -0600615 test_harness=test_pb2.VmTestRequest.TAST,
616 vm_tests=[test_pb2.VmTestRequest.VmTest(pattern='suite')],
617 ssh_options=test_pb2.VmTestRequest.SshOptions(
Alex Klein231d2da2019-07-22 16:44:45 -0600618 port=1234, private_key_path={'path': '/path/to/id_rsa',
Alex Kleinaa705412019-06-04 15:00:30 -0600619 'location': common_pb2.Path.INSIDE}),
Evan Hernandez4e388a52019-05-01 12:16:33 -0600620 )
621 values.update(kwargs)
622 return test_pb2.VmTestRequest(**values)
623
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700624 def _Output(self):
625 return test_pb2.VmTestResponse()
626
Alex Klein231d2da2019-07-22 16:44:45 -0600627 def testValidateOnly(self):
628 """Sanity check that a validate only call does not execute any logic."""
629 test_controller.VmTest(self._GetInput(), None, self.validate_only_config)
630 self.assertEqual(0, self.rc.call_count)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600631
Michael Mortensen7a7646d2019-12-12 15:36:14 -0700632 def testMockCall(self):
633 """Test mock call does not execute any logic."""
634 patch = self.PatchObject(cros_build_lib, 'run')
635
636 request = self._GetInput()
637 response = self._Output()
638 # VmTest does not return a value, checking mocked value is flagged by lint.
639 test_controller.VmTest(request, response, self.mock_call_config)
640 patch.assert_not_called()
641
Evan Hernandez4e388a52019-05-01 12:16:33 -0600642 def testTastAllOptions(self):
643 """Test VmTest for Tast with all options set."""
Alex Klein231d2da2019-07-22 16:44:45 -0600644 test_controller.VmTest(self._GetInput(), None, self.api_config)
645 self.assertCommandContains([
Achuith Bhandarkara9e9c3d2019-05-22 13:56:11 -0700646 'cros_run_test', '--debug', '--no-display', '--copy-on-write',
Evan Hernandez4e388a52019-05-01 12:16:33 -0600647 '--board', 'target',
648 '--image-path', '/path/to/image.bin',
649 '--tast', 'suite',
650 '--ssh-port', '1234',
651 '--private-key', '/path/to/id_rsa',
652 ])
653
654 def testAutotestAllOptions(self):
655 """Test VmTest for Autotest with all options set."""
656 input_proto = self._GetInput(test_harness=test_pb2.VmTestRequest.AUTOTEST)
Alex Klein231d2da2019-07-22 16:44:45 -0600657 test_controller.VmTest(input_proto, None, self.api_config)
658 self.assertCommandContains([
Achuith Bhandarkara9e9c3d2019-05-22 13:56:11 -0700659 'cros_run_test', '--debug', '--no-display', '--copy-on-write',
Evan Hernandez4e388a52019-05-01 12:16:33 -0600660 '--board', 'target',
661 '--image-path', '/path/to/image.bin',
662 '--autotest', 'suite',
663 '--ssh-port', '1234',
664 '--private-key', '/path/to/id_rsa',
Greg Edelstondcb0e912020-08-31 11:09:40 -0600665 '--test_that-args=--allow-chrome-crashes',
Evan Hernandez4e388a52019-05-01 12:16:33 -0600666 ])
667
668 def testMissingBuildTarget(self):
669 """Test VmTest dies when build_target not set."""
670 input_proto = self._GetInput(build_target=None)
671 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600672 test_controller.VmTest(input_proto, None, self.api_config)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600673
674 def testMissingVmImage(self):
675 """Test VmTest dies when vm_image not set."""
Alex Klein311b8022019-06-05 16:00:07 -0600676 input_proto = self._GetInput(vm_path=None)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600677 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600678 test_controller.VmTest(input_proto, None, self.api_config)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600679
680 def testMissingTestHarness(self):
681 """Test VmTest dies when test_harness not specified."""
682 input_proto = self._GetInput(
683 test_harness=test_pb2.VmTestRequest.UNSPECIFIED)
684 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600685 test_controller.VmTest(input_proto, None, self.api_config)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600686
687 def testMissingVmTests(self):
688 """Test VmTest dies when vm_tests not set."""
689 input_proto = self._GetInput(vm_tests=[])
690 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600691 test_controller.VmTest(input_proto, None, self.api_config)
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600692
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700693 def testVmTest(self):
694 """Call VmTest with valid args and temp dir."""
695 request = self._GetInput()
696 response = self._Output()
697 patch = self.PatchObject(
698 cros_build_lib, 'run',
699 return_value=cros_build_lib.CommandResult(returncode=0))
700
701 test_controller.VmTest(request, response, self.api_config)
702 patch.assert_called()
703
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600704
Alex Klein231d2da2019-07-22 16:44:45 -0600705class MoblabVmTestTest(cros_test_lib.MockTestCase, api_config.ApiConfigMixin):
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600706 """Test the MoblabVmTest endpoint."""
707
708 @staticmethod
709 def _Payload(path):
710 return test_pb2.MoblabVmTestRequest.Payload(
711 path=common_pb2.Path(path=path))
712
713 @staticmethod
714 def _Output():
715 return test_pb2.MoblabVmTestResponse()
716
717 def _Input(self):
718 return test_pb2.MoblabVmTestRequest(
Evan Hernandeze1e05d32019-07-19 12:32:18 -0600719 chroot=common_pb2.Chroot(path=self.chroot_dir),
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600720 image_payload=self._Payload(self.image_payload_dir),
721 cache_payloads=[self._Payload(self.autotest_payload_dir)])
722
723 def setUp(self):
Evan Hernandeze1e05d32019-07-19 12:32:18 -0600724 self.chroot_dir = '/chroot'
725 self.chroot_tmp_dir = '/chroot/tmp'
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600726 self.image_payload_dir = '/payloads/image'
727 self.autotest_payload_dir = '/payloads/autotest'
728 self.builder = 'moblab-generic-vm/R12-3.4.5-67.890'
729 self.image_cache_dir = '/mnt/moblab/cache'
730 self.image_mount_dir = '/mnt/image'
731
Evan Hernandeze1e05d32019-07-19 12:32:18 -0600732 self.PatchObject(chroot_lib.Chroot, 'tempdir', osutils.TempDir)
Evan Hernandez655e8042019-06-13 12:50:44 -0600733
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600734 self.mock_create_moblab_vms = self.PatchObject(
735 test_service, 'CreateMoblabVm')
736 self.mock_prepare_moblab_vm_image_cache = self.PatchObject(
737 test_service, 'PrepareMoblabVmImageCache',
738 return_value=self.image_cache_dir)
739 self.mock_run_moblab_vm_tests = self.PatchObject(
740 test_service, 'RunMoblabVmTest')
741 self.mock_validate_moblab_vm_tests = self.PatchObject(
742 test_service, 'ValidateMoblabVmTest')
743
744 @contextlib.contextmanager
Alex Klein38c7d9e2019-05-08 09:31:19 -0600745 def MockLoopbackPartitions(*_args, **_kwargs):
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600746 mount = mock.MagicMock()
Evan Hernandez40ee7452019-06-13 12:51:43 -0600747 mount.Mount.return_value = [self.image_mount_dir]
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600748 yield mount
Alex Klein231d2da2019-07-22 16:44:45 -0600749
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600750 self.PatchObject(image_lib, 'LoopbackPartitions', MockLoopbackPartitions)
751
Alex Klein231d2da2019-07-22 16:44:45 -0600752 def testValidateOnly(self):
753 """Sanity check that a validate only call does not execute any logic."""
754 test_controller.MoblabVmTest(self._Input(), self._Output(),
755 self.validate_only_config)
756 self.mock_create_moblab_vms.assert_not_called()
757
Michael Mortensen7a7646d2019-12-12 15:36:14 -0700758 def testMockCall(self):
759 """Test mock call does not execute any logic."""
760 patch = self.PatchObject(key_value_store, 'LoadFile')
761
762 # MoblabVmTest does not return a value, checking mocked value is flagged by
763 # lint.
764 test_controller.MoblabVmTest(self._Input(), self._Output(),
765 self.mock_call_config)
766 patch.assert_not_called()
767
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600768 def testImageContainsBuilder(self):
769 """MoblabVmTest calls service with correct args."""
770 request = self._Input()
771 response = self._Output()
772
773 self.PatchObject(
Mike Frysingere652ba12019-09-08 00:57:43 -0400774 key_value_store, 'LoadFile',
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600775 return_value={cros_set_lsb_release.LSB_KEY_BUILDER_PATH: self.builder})
776
Alex Klein231d2da2019-07-22 16:44:45 -0600777 test_controller.MoblabVmTest(request, response, self.api_config)
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600778
779 self.assertEqual(
780 self.mock_create_moblab_vms.call_args_list,
Evan Hernandeze1e05d32019-07-19 12:32:18 -0600781 [mock.call(mock.ANY, self.chroot_dir, self.image_payload_dir)])
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600782 self.assertEqual(
783 self.mock_prepare_moblab_vm_image_cache.call_args_list,
784 [mock.call(mock.ANY, self.builder, [self.autotest_payload_dir])])
785 self.assertEqual(
786 self.mock_run_moblab_vm_tests.call_args_list,
Evan Hernandez655e8042019-06-13 12:50:44 -0600787 [mock.call(mock.ANY, mock.ANY, self.builder, self.image_cache_dir,
788 mock.ANY)])
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600789 self.assertEqual(
790 self.mock_validate_moblab_vm_tests.call_args_list,
791 [mock.call(mock.ANY)])
792
793 def testImageMissingBuilder(self):
794 """MoblabVmTest dies when builder path not found in lsb-release."""
795 request = self._Input()
796 response = self._Output()
797
Mike Frysingere652ba12019-09-08 00:57:43 -0400798 self.PatchObject(key_value_store, 'LoadFile', return_value={})
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600799
800 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600801 test_controller.MoblabVmTest(request, response, self.api_config)
David Wellingc1433c22021-06-25 16:29:48 +0000802
803
804class GetArtifactsTest(cros_test_lib.MockTempDirTestCase):
805 """Test GetArtifacts."""
806
807 CODE_COVERAGE_LLVM_ARTIFACT_TYPE = (
808 common_pb2.ArtifactsByService.Test.ArtifactType.CODE_COVERAGE_LLVM_JSON
809 )
George Engelbrecht764b1cd2021-06-18 17:01:07 -0600810 UNIT_TEST_ARTIFACT_TYPE = (
811 common_pb2.ArtifactsByService.Test.ArtifactType.UNIT_TESTS
812 )
David Wellingc1433c22021-06-25 16:29:48 +0000813
814 def setUp(self):
815 """Set up the class for tests."""
816 chroot_dir = os.path.join(self.tempdir, 'chroot')
817 osutils.SafeMakedirs(chroot_dir)
818 osutils.SafeMakedirs(os.path.join(chroot_dir, 'tmp'))
819 self.chroot = chroot_lib.Chroot(chroot_dir)
820
821 sysroot_path = os.path.join(chroot_dir, 'build', 'board')
822 osutils.SafeMakedirs(sysroot_path)
823 self.sysroot = sysroot_lib.Sysroot(sysroot_path)
824
Jack Neusc9707c32021-07-23 21:48:54 +0000825 self.build_target = build_target_lib.BuildTarget('board')
826
David Wellingc1433c22021-06-25 16:29:48 +0000827 def testReturnsEmptyListWhenNoOutputArtifactsProvided(self):
828 """Test empty list is returned when there are no output_artifacts."""
829 result = test_controller.GetArtifacts(
830 common_pb2.ArtifactsByService.Test(output_artifacts=[]),
Jack Neusc9707c32021-07-23 21:48:54 +0000831 self.chroot, self.sysroot, self.build_target, self.tempdir)
David Wellingc1433c22021-06-25 16:29:48 +0000832
833 self.assertEqual(len(result), 0)
834
835 def testShouldCallBundleCodeCoverageLlvmJsonForEachValidArtifact(self):
836 """Test BundleCodeCoverageLlvmJson is called on each valid artifact."""
Sean McAllister17eed8d2021-09-21 10:41:16 -0600837 BundleCodeCoverageLlvmJson_mock = (
838 self.PatchObject(
839 test_service,
840 'BundleCodeCoverageLlvmJson',
841 return_value='test'))
David Wellingc1433c22021-06-25 16:29:48 +0000842
843 test_controller.GetArtifacts(
844 common_pb2.ArtifactsByService.Test(output_artifacts=[
845 # Valid
846 common_pb2.ArtifactsByService.Test.ArtifactInfo(
847 artifact_types=[
848 self.CODE_COVERAGE_LLVM_ARTIFACT_TYPE
849 ]
850 ),
851
852 # Invalid
853 common_pb2.ArtifactsByService.Test.ArtifactInfo(
854 artifact_types=[
855 common_pb2.ArtifactsByService.Test.ArtifactType.UNIT_TESTS
856 ]
857 ),
858 ]),
Jack Neusc9707c32021-07-23 21:48:54 +0000859 self.chroot, self.sysroot, self.build_target, self.tempdir)
David Wellingc1433c22021-06-25 16:29:48 +0000860
861 BundleCodeCoverageLlvmJson_mock.assert_called_once()
862
863 def testShouldReturnValidResult(self):
864 """Test result contains paths and code_coverage_llvm_json type."""
865 self.PatchObject(test_service, 'BundleCodeCoverageLlvmJson',
Sean McAllister17eed8d2021-09-21 10:41:16 -0600866 return_value='test')
George Engelbrecht764b1cd2021-06-18 17:01:07 -0600867 self.PatchObject(test_service, 'BuildTargetUnitTestTarball',
Sean McAllister17eed8d2021-09-21 10:41:16 -0600868 return_value='unit_tests.tar')
David Wellingc1433c22021-06-25 16:29:48 +0000869
870 result = test_controller.GetArtifacts(
871 common_pb2.ArtifactsByService.Test(output_artifacts=[
872 # Valid
873 common_pb2.ArtifactsByService.Test.ArtifactInfo(
874 artifact_types=[
George Engelbrecht764b1cd2021-06-18 17:01:07 -0600875 self.UNIT_TEST_ARTIFACT_TYPE
876 ]
877 ),
878 common_pb2.ArtifactsByService.Test.ArtifactInfo(
879 artifact_types=[
David Wellingc1433c22021-06-25 16:29:48 +0000880 self.CODE_COVERAGE_LLVM_ARTIFACT_TYPE
881 ]
882 ),
883 ]),
Jack Neusc9707c32021-07-23 21:48:54 +0000884 self.chroot, self.sysroot, self.build_target, self.tempdir)
David Wellingc1433c22021-06-25 16:29:48 +0000885
George Engelbrecht764b1cd2021-06-18 17:01:07 -0600886 self.assertEqual(result[0]['paths'], ['unit_tests.tar'])
887 self.assertEqual(result[0]['type'], self.UNIT_TEST_ARTIFACT_TYPE)
888 self.assertEqual(result[1]['paths'], ['test'])
889 self.assertEqual(result[1]['type'], self.CODE_COVERAGE_LLVM_ARTIFACT_TYPE)