blob: 84af4b29adbe208a5e0c172c5837f9f73a33b68d [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 Frysinger166fea02021-02-12 05:30:33 -050010from unittest import mock
Mike Frysingeref94e4c2020-02-10 23:59:54 -050011
Alex Klein231d2da2019-07-22 16:44:45 -060012from chromite.api import api_config
Alex Klein8cb365a2019-05-15 16:24:53 -060013from chromite.api import controller
Lizzy Presland4feb2372022-01-20 05:16:30 +000014from chromite.api.controller import controller_util
Alex Kleina2e42c42019-04-17 16:13:19 -060015from chromite.api.controller import test as test_controller
Evan Hernandez4e388a52019-05-01 12:16:33 -060016from chromite.api.gen.chromiumos import common_pb2
Alex Kleina2e42c42019-04-17 16:13:19 -060017from chromite.api.gen.chromite.api import test_pb2
Sean McAllister3834fef2021-10-08 15:45:18 -060018from chromite.api.gen.chromiumos.build.api import container_metadata_pb2
Jack Neusc9707c32021-07-23 21:48:54 +000019from chromite.lib import build_target_lib
Evan Hernandeze1e05d32019-07-19 12:32:18 -060020from chromite.lib import chroot_lib
Alex Kleina2e42c42019-04-17 16:13:19 -060021from chromite.lib import cros_build_lib
22from chromite.lib import cros_test_lib
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -060023from chromite.lib import image_lib
Alex Kleina2e42c42019-04-17 16:13:19 -060024from chromite.lib import osutils
David Wellingc1433c22021-06-25 16:29:48 +000025from chromite.lib import sysroot_lib
Alex Klein18a60af2020-06-11 12:08:47 -060026from chromite.lib.parser import package_info
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -060027from chromite.scripts import cros_set_lsb_release
28from chromite.service import test as test_service
Andrew Lamb763e3be2021-07-27 17:22:02 -060029from chromite.third_party.google.protobuf import json_format
Mike Frysingere652ba12019-09-08 00:57:43 -040030from chromite.utils import key_value_store
Alex Kleina2e42c42019-04-17 16:13:19 -060031
32
Michael Mortensen8ca4d3b2019-11-27 09:35:22 -070033class DebugInfoTestTest(cros_test_lib.MockTempDirTestCase,
34 api_config.ApiConfigMixin):
35 """Tests for the DebugInfoTest function."""
36
37 def setUp(self):
38 self.board = 'board'
39 self.chroot_path = os.path.join(self.tempdir, 'chroot')
40 self.sysroot_path = '/build/board'
41 self.full_sysroot_path = os.path.join(self.chroot_path,
42 self.sysroot_path.lstrip(os.sep))
43 osutils.SafeMakedirs(self.full_sysroot_path)
44
45 def _GetInput(self, sysroot_path=None, build_target=None):
46 """Helper to build an input message instance."""
47 proto = test_pb2.DebugInfoTestRequest()
48 if sysroot_path:
49 proto.sysroot.path = sysroot_path
50 if build_target:
51 proto.sysroot.build_target.name = build_target
52 return proto
53
54 def _GetOutput(self):
55 """Helper to get an empty output message instance."""
56 return test_pb2.DebugInfoTestResponse()
57
58 def testValidateOnly(self):
59 """Sanity check that a validate only call does not execute any logic."""
60 patch = self.PatchObject(test_service, 'DebugInfoTest')
61 input_msg = self._GetInput(sysroot_path=self.full_sysroot_path)
62 test_controller.DebugInfoTest(input_msg, self._GetOutput(),
63 self.validate_only_config)
64 patch.assert_not_called()
65
Michael Mortensen85d38402019-12-12 09:50:29 -070066 def testMockError(self):
67 """Test mock error call does not execute any logic, returns error."""
68 patch = self.PatchObject(test_service, 'DebugInfoTest')
69
70 input_msg = self._GetInput(sysroot_path=self.full_sysroot_path)
71 rc = test_controller.DebugInfoTest(input_msg, self._GetOutput(),
72 self.mock_error_config)
73 patch.assert_not_called()
74 self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
75
76 def testMockCall(self):
77 """Test mock call does not execute any logic, returns success."""
78 patch = self.PatchObject(test_service, 'DebugInfoTest')
79
80 input_msg = self._GetInput(sysroot_path=self.full_sysroot_path)
81 rc = test_controller.DebugInfoTest(input_msg, self._GetOutput(),
82 self.mock_call_config)
83 patch.assert_not_called()
84 self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
85
Michael Mortensen8ca4d3b2019-11-27 09:35:22 -070086 def testNoBuildTargetNoSysrootFails(self):
87 """Test missing build target name and sysroot path fails."""
88 input_msg = self._GetInput()
89 output_msg = self._GetOutput()
90 with self.assertRaises(cros_build_lib.DieSystemExit):
91 test_controller.DebugInfoTest(input_msg, output_msg, self.api_config)
92
93 def testDebugInfoTest(self):
94 """Call DebugInfoTest with valid sysroot_path."""
95 request = self._GetInput(sysroot_path=self.full_sysroot_path)
96
97 test_controller.DebugInfoTest(request, self._GetOutput(), self.api_config)
98
99
Alex Klein231d2da2019-07-22 16:44:45 -0600100class BuildTargetUnitTestTest(cros_test_lib.MockTempDirTestCase,
101 api_config.ApiConfigMixin):
Alex Kleina2e42c42019-04-17 16:13:19 -0600102 """Tests for the UnitTest function."""
103
Lizzy Presland4feb2372022-01-20 05:16:30 +0000104 def setUp(self):
105 # Set up portage log directory.
106 self.sysroot = os.path.join(self.tempdir, 'build', 'board')
107 osutils.SafeMakedirs(self.sysroot)
108 self.target_sysroot = sysroot_lib.Sysroot(self.sysroot)
109 self.portage_dir = os.path.join(self.tempdir, 'portage_logdir')
110 self.PatchObject(
111 sysroot_lib.Sysroot, 'portage_logdir', new=self.portage_dir)
112 osutils.SafeMakedirs(self.portage_dir)
113
Navil Perezc0b29a82020-07-07 14:17:48 +0000114 def _GetInput(self,
115 board=None,
116 result_path=None,
117 chroot_path=None,
118 cache_dir=None,
119 empty_sysroot=None,
120 packages=None,
Alex Kleinb64e5f82020-09-23 10:55:31 -0600121 blocklist=None):
Alex Kleina2e42c42019-04-17 16:13:19 -0600122 """Helper to build an input message instance."""
Navil Perezc0b29a82020-07-07 14:17:48 +0000123 formatted_packages = []
124 for pkg in packages or []:
125 formatted_packages.append({
126 'category': pkg.category,
127 'package_name': pkg.package
128 })
Alex Kleinb64e5f82020-09-23 10:55:31 -0600129 formatted_blocklist = []
130 for pkg in blocklist or []:
131 formatted_blocklist.append({'category': pkg.category,
Alex Kleinf2674462019-05-16 16:47:24 -0600132 'package_name': pkg.package})
133
Alex Kleina2e42c42019-04-17 16:13:19 -0600134 return test_pb2.BuildTargetUnitTestRequest(
135 build_target={'name': board}, result_path=result_path,
Alex Kleinfa6ebdc2019-05-10 10:57:31 -0600136 chroot={'path': chroot_path, 'cache_dir': cache_dir},
Alex Kleinf2674462019-05-16 16:47:24 -0600137 flags={'empty_sysroot': empty_sysroot},
Alex Klein64ac34c2020-09-23 10:21:33 -0600138 packages=formatted_packages,
Alex Klein157caf42021-07-01 14:36:43 -0600139 package_blocklist=formatted_blocklist,
Alex Kleina2e42c42019-04-17 16:13:19 -0600140 )
141
142 def _GetOutput(self):
143 """Helper to get an empty output message instance."""
144 return test_pb2.BuildTargetUnitTestResponse()
145
Lizzy Presland4feb2372022-01-20 05:16:30 +0000146 def _CreatePortageLogFile(self, log_path, pkg_info, timestamp):
147 """Creates a log file for testing for individual packages built by Portage.
148
149 Args:
150 log_path (pathlike): the PORTAGE_LOGDIR path
151 pkg_info (PackageInfo): name components for log file.
152 timestamp (datetime): timestamp used to name the file.
153 """
154 path = os.path.join(log_path,
155 f'{pkg_info.category}:{pkg_info.pvr}:' \
156 f'{timestamp.strftime("%Y%m%d-%H%M%S")}.log')
157 osutils.WriteFile(path,
158 f'Test log file for package {pkg_info.category}/'
159 f'{pkg_info.package} written to {path}')
160 return path
161
Alex Klein231d2da2019-07-22 16:44:45 -0600162 def testValidateOnly(self):
163 """Sanity check that a validate only call does not execute any logic."""
164 patch = self.PatchObject(test_service, 'BuildTargetUnitTest')
165
166 input_msg = self._GetInput(board='board', result_path=self.tempdir)
167 test_controller.BuildTargetUnitTest(input_msg, self._GetOutput(),
168 self.validate_only_config)
169 patch.assert_not_called()
170
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700171 def testMockCall(self):
172 """Test that a mock call does not execute logic, returns mocked value."""
173 patch = self.PatchObject(test_service, 'BuildTargetUnitTest')
174
175 input_msg = self._GetInput(board='board', result_path=self.tempdir)
176 response = self._GetOutput()
177 test_controller.BuildTargetUnitTest(input_msg, response,
178 self.mock_call_config)
179 patch.assert_not_called()
180 self.assertEqual(response.tarball_path,
181 os.path.join(input_msg.result_path, 'unit_tests.tar'))
182
183 def testMockError(self):
Michael Mortensen85d38402019-12-12 09:50:29 -0700184 """Test that a mock error does not execute logic, returns error."""
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700185 patch = self.PatchObject(test_service, 'BuildTargetUnitTest')
186
187 input_msg = self._GetInput(board='board', result_path=self.tempdir)
188 response = self._GetOutput()
189 rc = test_controller.BuildTargetUnitTest(input_msg, response,
190 self.mock_error_config)
191 patch.assert_not_called()
192 self.assertEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc)
193 self.assertTrue(response.failed_packages)
194 self.assertEqual(response.failed_packages[0].category, 'foo')
195 self.assertEqual(response.failed_packages[0].package_name, 'bar')
196 self.assertEqual(response.failed_packages[1].category, 'cat')
197 self.assertEqual(response.failed_packages[1].package_name, 'pkg')
198
Alex Klein64ac34c2020-09-23 10:21:33 -0600199 def testInvalidPackageFails(self):
200 """Test missing result path fails."""
201 # Missing result_path.
202 pkg = package_info.PackageInfo(package='bar')
203 input_msg = self._GetInput(board='board', result_path=self.tempdir,
204 packages=[pkg])
205 output_msg = self._GetOutput()
206 with self.assertRaises(cros_build_lib.DieSystemExit):
207 test_controller.BuildTargetUnitTest(input_msg, output_msg,
208 self.api_config)
209
Alex Kleina2e42c42019-04-17 16:13:19 -0600210 def testPackageBuildFailure(self):
211 """Test handling of raised BuildPackageFailure."""
212 tempdir = osutils.TempDir(base_dir=self.tempdir)
213 self.PatchObject(osutils, 'TempDir', return_value=tempdir)
214
Lizzy Presland4feb2372022-01-20 05:16:30 +0000215 pkgs = ['cat/pkg-1.0-r1', 'foo/bar-2.0-r1']
216 cpvrs = [package_info.parse(pkg) for pkg in pkgs]
Alex Kleina2e42c42019-04-17 16:13:19 -0600217 expected = [('cat', 'pkg'), ('foo', 'bar')]
Lizzy Presland4feb2372022-01-20 05:16:30 +0000218 new_logs = {}
219 for i, pkg in enumerate(pkgs):
220 self._CreatePortageLogFile(self.portage_dir, cpvrs[i],
221 datetime.datetime(2021, 6, 9, 13, 37, 0))
222 new_logs[pkg] = self._CreatePortageLogFile(self.portage_dir, cpvrs[i],
223 datetime.datetime(2021, 6, 9,
224 16, 20, 0))
Alex Kleina2e42c42019-04-17 16:13:19 -0600225
Alex Klein38c7d9e2019-05-08 09:31:19 -0600226 result = test_service.BuildTargetUnitTestResult(1, None)
Alex Kleinea0c89e2021-09-09 15:17:35 -0600227 result.failed_pkgs = [package_info.parse(p) for p in pkgs]
Alex Klein38c7d9e2019-05-08 09:31:19 -0600228 self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result)
Alex Kleina2e42c42019-04-17 16:13:19 -0600229
230 input_msg = self._GetInput(board='board', result_path=self.tempdir)
231 output_msg = self._GetOutput()
232
Alex Klein231d2da2019-07-22 16:44:45 -0600233 rc = test_controller.BuildTargetUnitTest(input_msg, output_msg,
234 self.api_config)
Alex Kleina2e42c42019-04-17 16:13:19 -0600235
Alex Klein8cb365a2019-05-15 16:24:53 -0600236 self.assertEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc)
Alex Kleina2e42c42019-04-17 16:13:19 -0600237 self.assertTrue(output_msg.failed_packages)
Lizzy Presland4feb2372022-01-20 05:16:30 +0000238 self.assertTrue(output_msg.failed_package_data)
239 # TODO(b/206514844): remove when field is deleted
Alex Kleina2e42c42019-04-17 16:13:19 -0600240 failed = []
241 for pi in output_msg.failed_packages:
242 failed.append((pi.category, pi.package_name))
Mike Frysinger678735c2019-09-28 18:23:28 -0400243 self.assertCountEqual(expected, failed)
Alex Kleina2e42c42019-04-17 16:13:19 -0600244
Lizzy Presland4feb2372022-01-20 05:16:30 +0000245 failed_with_logs = []
246 for data in output_msg.failed_package_data:
247 failed_with_logs.append((data.name.category, data.name.package_name))
248 package = controller_util.deserialize_package_info(data.name)
249 self.assertEqual(data.log_path.path, new_logs[package.cpvr])
250 self.assertCountEqual(expected, failed_with_logs)
251
252
Alex Kleina2e42c42019-04-17 16:13:19 -0600253 def testOtherBuildScriptFailure(self):
254 """Test build script failure due to non-package emerge error."""
255 tempdir = osutils.TempDir(base_dir=self.tempdir)
256 self.PatchObject(osutils, 'TempDir', return_value=tempdir)
257
Alex Klein38c7d9e2019-05-08 09:31:19 -0600258 result = test_service.BuildTargetUnitTestResult(1, None)
259 self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result)
Alex Kleina2e42c42019-04-17 16:13:19 -0600260
Alex Kleinf2674462019-05-16 16:47:24 -0600261 pkgs = ['foo/bar', 'cat/pkg']
Alex Kleinb64e5f82020-09-23 10:55:31 -0600262 blocklist = [package_info.SplitCPV(p, strict=False) for p in pkgs]
Alex Klein2e91e522022-01-14 09:22:03 -0700263 input_msg = self._GetInput(board='board', empty_sysroot=True,
264 blocklist=blocklist)
Alex Kleina2e42c42019-04-17 16:13:19 -0600265 output_msg = self._GetOutput()
266
Alex Klein231d2da2019-07-22 16:44:45 -0600267 rc = test_controller.BuildTargetUnitTest(input_msg, output_msg,
268 self.api_config)
Alex Kleina2e42c42019-04-17 16:13:19 -0600269
Alex Klein8cb365a2019-05-15 16:24:53 -0600270 self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
Alex Kleina2e42c42019-04-17 16:13:19 -0600271 self.assertFalse(output_msg.failed_packages)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600272
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700273 def testBuildTargetUnitTest(self):
274 """Test BuildTargetUnitTest successful call."""
Navil Perezc0b29a82020-07-07 14:17:48 +0000275 pkgs = ['foo/bar', 'cat/pkg']
Alex Klein18a60af2020-06-11 12:08:47 -0600276 packages = [package_info.SplitCPV(p, strict=False) for p in pkgs]
Alex Klein2e91e522022-01-14 09:22:03 -0700277 input_msg = self._GetInput(board='board', packages=packages)
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700278
279 result = test_service.BuildTargetUnitTestResult(0, None)
280 self.PatchObject(test_service, 'BuildTargetUnitTest', return_value=result)
281
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700282 response = self._GetOutput()
283 test_controller.BuildTargetUnitTest(input_msg, response,
284 self.api_config)
Alex Klein2e91e522022-01-14 09:22:03 -0700285 self.assertFalse(response.failed_packages)
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700286
Evan Hernandez4e388a52019-05-01 12:16:33 -0600287
Sean McAllister17eed8d2021-09-21 10:41:16 -0600288class DockerConstraintsTest(cros_test_lib.MockTestCase):
289 """Tests for Docker argument constraints."""
290
291 def assertValid(self, output):
292 return output is None
293
294 def assertInvalid(self, output):
295 return not self.assertValid(output)
296
297 def testValidDockerTag(self):
298 """Check logic for validating docker tag format."""
299 # pylint: disable=protected-access
300
301 invalid_tags = [
302 '.invalid-tag',
303 '-invalid-tag',
304 'invalid-tag;',
305 'invalid'*100,
306 ]
307
308 for tag in invalid_tags:
309 self.assertInvalid(test_controller._ValidDockerTag(tag))
310
311 valid_tags = [
312 'valid-tag',
313 'valid-tag-',
314 'valid.tag.',
315 ]
316
317 for tag in valid_tags:
318 self.assertValid(test_controller._ValidDockerTag(tag))
319
320
321 def testValidDockerLabelKey(self):
322 """Check logic for validating docker label key format."""
323 # pylint: disable=protected-access
324
325 invalid_keys = [
326 'Invalid-keY',
327 'Invalid-key',
328 'invalid-keY',
329 'iNVALID-KEy',
330 'invalid_key',
331 'invalid-key;',
332 ]
333
334 for key in invalid_keys:
335 self.assertInvalid(test_controller._ValidDockerLabelKey(key))
336
337 valid_keys = [
338 'chromeos.valid-key',
339 'chromeos.valid-key-2',
340 ]
341
342 for key in valid_keys:
343 self.assertValid(test_controller._ValidDockerLabelKey(key))
344
345
Sean McAllister3834fef2021-10-08 15:45:18 -0600346class BuildTestServiceContainers(cros_test_lib.RunCommandTempDirTestCase,
David Wellingc1433c22021-06-25 16:29:48 +0000347 api_config.ApiConfigMixin):
C Shapiro91af1ce2021-06-17 12:42:09 -0500348 """Tests for the BuildTestServiceContainers function."""
349
350 def setUp(self):
351 self.request = test_pb2.BuildTestServiceContainersRequest(
352 chroot={'path': '/path/to/chroot'},
353 build_target={'name': 'build_target'},
David Wellingc1433c22021-06-25 16:29:48 +0000354 version='R93-14033.0.0',
C Shapiro91af1ce2021-06-17 12:42:09 -0500355 )
356
C Shapiro91af1ce2021-06-17 12:42:09 -0500357 def testSuccess(self):
358 """Check passing case with mocked cros_build_lib.run."""
Sean McAllister3834fef2021-10-08 15:45:18 -0600359
360 def ContainerMetadata():
361 """Return mocked ContainerImageInfo proto"""
362 metadata = container_metadata_pb2.ContainerImageInfo()
363 metadata.repository.hostname = 'gcr.io'
364 metadata.repository.project = 'chromeos-bot'
365 metadata.name = 'random-container-name'
366 metadata.digest = (
367 '09b730f8b6a862f9c2705cb3acf3554563325f5fca5c784bf5c98beb2e56f6db')
368 metadata.tags[:] = [
369 'staging-cq-amd64-generic.R96-1.2.3',
370 '8834106026340379089',
371 ]
372 return metadata
373
374 def WriteContainerMetadata(path):
375 """Write json formatted metadata to the given file."""
376 osutils.WriteFile(
377 path,
378 json_format.MessageToJson(ContainerMetadata()),
379 )
380
381 # Write out mocked container metadata to a temporary file.
382 output_path = os.path.join(self.tempdir, 'metadata.jsonpb')
383 self.rc.SetDefaultCmdResult(
384 returncode=0,
385 side_effect=lambda *_, **__: WriteContainerMetadata(output_path)
386 )
387
388 # Patch TempDir so that we always use this test's directory.
389 self.PatchObject(osutils.TempDir, '__enter__', return_value=self.tempdir)
C Shapiro91af1ce2021-06-17 12:42:09 -0500390
391 response = test_pb2.BuildTestServiceContainersResponse()
392 test_controller.BuildTestServiceContainers(
393 self.request,
394 response,
395 self.api_config)
Sean McAllister3834fef2021-10-08 15:45:18 -0600396
397 self.assertTrue(self.rc.called)
C Shapiro91af1ce2021-06-17 12:42:09 -0500398 for result in response.results:
399 self.assertEqual(result.WhichOneof('result'), 'success')
Sean McAllister3834fef2021-10-08 15:45:18 -0600400 self.assertEqual(result.success.image_info, ContainerMetadata())
C Shapiro91af1ce2021-06-17 12:42:09 -0500401
C Shapiro91af1ce2021-06-17 12:42:09 -0500402 def testFailure(self):
403 """Check failure case with mocked cros_build_lib.run."""
404 patch = self.PatchObject(
405 cros_build_lib, 'run',
406 return_value=cros_build_lib.CommandResult(returncode=1))
407
408 response = test_pb2.BuildTestServiceContainersResponse()
409 test_controller.BuildTestServiceContainers(
410 self.request,
411 response,
412 self.api_config)
413 patch.assert_called()
414 for result in response.results:
Derek Beckettcca7b662022-04-22 16:59:43 -0700415 if result.name == 'cros-test':
Derek Beckettb28b5372022-04-15 13:08:32 -0700416 self.assertEqual(result.WhichOneof('result'), 'success')
417 else:
418 self.assertEqual(result.WhichOneof('result'), 'failure')
C Shapiro91af1ce2021-06-17 12:42:09 -0500419
Michael Mortensen8ca4d3b2019-11-27 09:35:22 -0700420class ChromiteUnitTestTest(cros_test_lib.MockTestCase,
421 api_config.ApiConfigMixin):
422 """Tests for the ChromiteInfoTest function."""
423
424 def setUp(self):
425 self.board = 'board'
426 self.chroot_path = '/path/to/chroot'
427
428 def _GetInput(self, chroot_path=None):
429 """Helper to build an input message instance."""
430 proto = test_pb2.ChromiteUnitTestRequest(
431 chroot={'path': chroot_path},
432 )
433 return proto
434
435 def _GetOutput(self):
436 """Helper to get an empty output message instance."""
437 return test_pb2.ChromiteUnitTestResponse()
438
439 def testValidateOnly(self):
440 """Sanity check that a validate only call does not execute any logic."""
441 patch = self.PatchObject(cros_build_lib, 'run')
442
443 input_msg = self._GetInput(chroot_path=self.chroot_path)
444 test_controller.ChromiteUnitTest(input_msg, self._GetOutput(),
445 self.validate_only_config)
446 patch.assert_not_called()
447
Michael Mortensen7a860eb2019-12-03 20:25:15 -0700448 def testMockError(self):
449 """Test mock error call does not execute any logic, returns error."""
450 patch = self.PatchObject(cros_build_lib, 'run')
451
452 input_msg = self._GetInput(chroot_path=self.chroot_path)
453 rc = test_controller.ChromiteUnitTest(input_msg, self._GetOutput(),
454 self.mock_error_config)
455 patch.assert_not_called()
456 self.assertEqual(controller.RETURN_CODE_COMPLETED_UNSUCCESSFULLY, rc)
457
458 def testMockCall(self):
459 """Test mock call does not execute any logic, returns success."""
460 patch = self.PatchObject(cros_build_lib, 'run')
461
462 input_msg = self._GetInput(chroot_path=self.chroot_path)
463 rc = test_controller.ChromiteUnitTest(input_msg, self._GetOutput(),
464 self.mock_call_config)
465 patch.assert_not_called()
466 self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
467
Michael Mortensen8ca4d3b2019-11-27 09:35:22 -0700468 def testChromiteUnitTest(self):
469 """Call ChromiteUnitTest with mocked cros_build_lib.run."""
470 request = self._GetInput(chroot_path=self.chroot_path)
471 patch = self.PatchObject(
472 cros_build_lib, 'run',
473 return_value=cros_build_lib.CommandResult(returncode=0))
474
475 test_controller.ChromiteUnitTest(request, self._GetOutput(),
476 self.api_config)
477 patch.assert_called_once()
478
479
Alex Klein4bc8f4f2019-08-16 14:53:30 -0600480class CrosSigningTestTest(cros_test_lib.RunCommandTestCase,
481 api_config.ApiConfigMixin):
482 """CrosSigningTest tests."""
483
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700484 def setUp(self):
485 self.chroot_path = '/path/to/chroot'
486
487 def _GetInput(self, chroot_path=None):
488 """Helper to build an input message instance."""
489 proto = test_pb2.CrosSigningTestRequest(
490 chroot={'path': chroot_path},
491 )
492 return proto
493
494 def _GetOutput(self):
495 """Helper to get an empty output message instance."""
496 return test_pb2.CrosSigningTestResponse()
497
Alex Klein4bc8f4f2019-08-16 14:53:30 -0600498 def testValidateOnly(self):
499 """Sanity check that a validate only call does not execute any logic."""
500 test_controller.CrosSigningTest(None, None, self.validate_only_config)
501 self.assertFalse(self.rc.call_count)
502
Michael Mortensen7a7646d2019-12-12 15:36:14 -0700503 def testMockCall(self):
504 """Test mock call does not execute any logic, returns success."""
505 rc = test_controller.CrosSigningTest(None, None, self.mock_call_config)
506 self.assertFalse(self.rc.call_count)
507 self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
508
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700509 def testCrosSigningTest(self):
510 """Call CrosSigningTest with mocked cros_build_lib.run."""
511 request = self._GetInput(chroot_path=self.chroot_path)
512 patch = self.PatchObject(
513 cros_build_lib, 'run',
514 return_value=cros_build_lib.CommandResult(returncode=0))
515
516 test_controller.CrosSigningTest(request, self._GetOutput(),
517 self.api_config)
518 patch.assert_called_once()
519
Alex Klein4bc8f4f2019-08-16 14:53:30 -0600520
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600521class SimpleChromeWorkflowTestTest(cros_test_lib.MockTestCase,
522 api_config.ApiConfigMixin):
523 """Test the SimpleChromeWorkflowTest endpoint."""
524
525 @staticmethod
526 def _Output():
527 return test_pb2.SimpleChromeWorkflowTestResponse()
528
David Wellingc1433c22021-06-25 16:29:48 +0000529 def _Input(self,
530 sysroot_path=None,
531 build_target=None,
532 chrome_root=None,
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600533 goma_config=None):
534 proto = test_pb2.SimpleChromeWorkflowTestRequest()
535 if sysroot_path:
536 proto.sysroot.path = sysroot_path
537 if build_target:
538 proto.sysroot.build_target.name = build_target
539 if chrome_root:
540 proto.chrome_root = chrome_root
541 if goma_config:
542 proto.goma_config = goma_config
543 return proto
544
545 def setUp(self):
546 self.chrome_path = 'path/to/chrome'
547 self.sysroot_dir = 'build/board'
548 self.build_target = 'amd64'
549 self.mock_simple_chrome_workflow_test = self.PatchObject(
550 test_service, 'SimpleChromeWorkflowTest')
551
552 def testMissingBuildTarget(self):
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700553 """Test SimpleChromeWorkflowTest dies when build_target not set."""
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600554 input_proto = self._Input(build_target=None, sysroot_path='/sysroot/dir',
555 chrome_root='/chrome/path')
556 with self.assertRaises(cros_build_lib.DieSystemExit):
557 test_controller.SimpleChromeWorkflowTest(input_proto, None,
558 self.api_config)
559
560 def testMissingSysrootPath(self):
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700561 """Test SimpleChromeWorkflowTest dies when build_target not set."""
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600562 input_proto = self._Input(build_target='board', sysroot_path=None,
563 chrome_root='/chrome/path')
564 with self.assertRaises(cros_build_lib.DieSystemExit):
565 test_controller.SimpleChromeWorkflowTest(input_proto, None,
566 self.api_config)
567
568 def testMissingChromeRoot(self):
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700569 """Test SimpleChromeWorkflowTest dies when build_target not set."""
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600570 input_proto = self._Input(build_target='board', sysroot_path='/sysroot/dir',
571 chrome_root=None)
572 with self.assertRaises(cros_build_lib.DieSystemExit):
573 test_controller.SimpleChromeWorkflowTest(input_proto, None,
574 self.api_config)
575
576 def testSimpleChromeWorkflowTest(self):
577 """Call SimpleChromeWorkflowTest with valid args and temp dir."""
578 request = self._Input(sysroot_path='sysroot_path', build_target='board',
579 chrome_root='/path/to/chrome')
580 response = self._Output()
581
582 test_controller.SimpleChromeWorkflowTest(request, response, self.api_config)
583 self.mock_simple_chrome_workflow_test.assert_called()
584
585 def testValidateOnly(self):
586 request = self._Input(sysroot_path='sysroot_path', build_target='board',
587 chrome_root='/path/to/chrome')
588 test_controller.SimpleChromeWorkflowTest(request, self._Output(),
589 self.validate_only_config)
590 self.mock_simple_chrome_workflow_test.assert_not_called()
591
Michael Mortensen7a7646d2019-12-12 15:36:14 -0700592 def testMockCall(self):
593 """Test mock call does not execute any logic, returns success."""
594 patch = self.mock_simple_chrome_workflow_test = self.PatchObject(
595 test_service, 'SimpleChromeWorkflowTest')
596
597 request = self._Input(sysroot_path='sysroot_path', build_target='board',
598 chrome_root='/path/to/chrome')
599 rc = test_controller.SimpleChromeWorkflowTest(request, self._Output(),
600 self.mock_call_config)
601 patch.assert_not_called()
602 self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
603
Michael Mortensenc28d6f12019-10-03 13:34:51 -0600604
Alex Klein231d2da2019-07-22 16:44:45 -0600605class VmTestTest(cros_test_lib.RunCommandTestCase, api_config.ApiConfigMixin):
Evan Hernandez4e388a52019-05-01 12:16:33 -0600606 """Test the VmTest endpoint."""
607
608 def _GetInput(self, **kwargs):
609 values = dict(
610 build_target=common_pb2.BuildTarget(name='target'),
Alex Klein311b8022019-06-05 16:00:07 -0600611 vm_path=common_pb2.Path(path='/path/to/image.bin',
612 location=common_pb2.Path.INSIDE),
Evan Hernandez4e388a52019-05-01 12:16:33 -0600613 test_harness=test_pb2.VmTestRequest.TAST,
614 vm_tests=[test_pb2.VmTestRequest.VmTest(pattern='suite')],
615 ssh_options=test_pb2.VmTestRequest.SshOptions(
Alex Klein231d2da2019-07-22 16:44:45 -0600616 port=1234, private_key_path={'path': '/path/to/id_rsa',
Alex Kleinaa705412019-06-04 15:00:30 -0600617 'location': common_pb2.Path.INSIDE}),
Evan Hernandez4e388a52019-05-01 12:16:33 -0600618 )
619 values.update(kwargs)
620 return test_pb2.VmTestRequest(**values)
621
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700622 def _Output(self):
623 return test_pb2.VmTestResponse()
624
Alex Klein231d2da2019-07-22 16:44:45 -0600625 def testValidateOnly(self):
626 """Sanity check that a validate only call does not execute any logic."""
627 test_controller.VmTest(self._GetInput(), None, self.validate_only_config)
628 self.assertEqual(0, self.rc.call_count)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600629
Michael Mortensen7a7646d2019-12-12 15:36:14 -0700630 def testMockCall(self):
631 """Test mock call does not execute any logic."""
632 patch = self.PatchObject(cros_build_lib, 'run')
633
634 request = self._GetInput()
635 response = self._Output()
636 # VmTest does not return a value, checking mocked value is flagged by lint.
637 test_controller.VmTest(request, response, self.mock_call_config)
638 patch.assert_not_called()
639
Evan Hernandez4e388a52019-05-01 12:16:33 -0600640 def testTastAllOptions(self):
641 """Test VmTest for Tast with all options set."""
Alex Klein231d2da2019-07-22 16:44:45 -0600642 test_controller.VmTest(self._GetInput(), None, self.api_config)
643 self.assertCommandContains([
Achuith Bhandarkara9e9c3d2019-05-22 13:56:11 -0700644 'cros_run_test', '--debug', '--no-display', '--copy-on-write',
Evan Hernandez4e388a52019-05-01 12:16:33 -0600645 '--board', 'target',
646 '--image-path', '/path/to/image.bin',
647 '--tast', 'suite',
648 '--ssh-port', '1234',
649 '--private-key', '/path/to/id_rsa',
650 ])
651
652 def testAutotestAllOptions(self):
653 """Test VmTest for Autotest with all options set."""
654 input_proto = self._GetInput(test_harness=test_pb2.VmTestRequest.AUTOTEST)
Alex Klein231d2da2019-07-22 16:44:45 -0600655 test_controller.VmTest(input_proto, None, self.api_config)
656 self.assertCommandContains([
Achuith Bhandarkara9e9c3d2019-05-22 13:56:11 -0700657 'cros_run_test', '--debug', '--no-display', '--copy-on-write',
Evan Hernandez4e388a52019-05-01 12:16:33 -0600658 '--board', 'target',
659 '--image-path', '/path/to/image.bin',
660 '--autotest', 'suite',
661 '--ssh-port', '1234',
662 '--private-key', '/path/to/id_rsa',
Greg Edelstondcb0e912020-08-31 11:09:40 -0600663 '--test_that-args=--allow-chrome-crashes',
Evan Hernandez4e388a52019-05-01 12:16:33 -0600664 ])
665
666 def testMissingBuildTarget(self):
667 """Test VmTest dies when build_target not set."""
668 input_proto = self._GetInput(build_target=None)
669 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600670 test_controller.VmTest(input_proto, None, self.api_config)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600671
672 def testMissingVmImage(self):
673 """Test VmTest dies when vm_image not set."""
Alex Klein311b8022019-06-05 16:00:07 -0600674 input_proto = self._GetInput(vm_path=None)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600675 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600676 test_controller.VmTest(input_proto, None, self.api_config)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600677
678 def testMissingTestHarness(self):
679 """Test VmTest dies when test_harness not specified."""
680 input_proto = self._GetInput(
681 test_harness=test_pb2.VmTestRequest.UNSPECIFIED)
682 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600683 test_controller.VmTest(input_proto, None, self.api_config)
Evan Hernandez4e388a52019-05-01 12:16:33 -0600684
685 def testMissingVmTests(self):
686 """Test VmTest dies when vm_tests not set."""
687 input_proto = self._GetInput(vm_tests=[])
688 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600689 test_controller.VmTest(input_proto, None, self.api_config)
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600690
Michael Mortensen82cd62d2019-12-01 14:58:54 -0700691 def testVmTest(self):
692 """Call VmTest with valid args and temp dir."""
693 request = self._GetInput()
694 response = self._Output()
695 patch = self.PatchObject(
696 cros_build_lib, 'run',
697 return_value=cros_build_lib.CommandResult(returncode=0))
698
699 test_controller.VmTest(request, response, self.api_config)
700 patch.assert_called()
701
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600702
Alex Klein231d2da2019-07-22 16:44:45 -0600703class MoblabVmTestTest(cros_test_lib.MockTestCase, api_config.ApiConfigMixin):
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600704 """Test the MoblabVmTest endpoint."""
705
706 @staticmethod
707 def _Payload(path):
708 return test_pb2.MoblabVmTestRequest.Payload(
709 path=common_pb2.Path(path=path))
710
711 @staticmethod
712 def _Output():
713 return test_pb2.MoblabVmTestResponse()
714
715 def _Input(self):
716 return test_pb2.MoblabVmTestRequest(
Evan Hernandeze1e05d32019-07-19 12:32:18 -0600717 chroot=common_pb2.Chroot(path=self.chroot_dir),
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600718 image_payload=self._Payload(self.image_payload_dir),
719 cache_payloads=[self._Payload(self.autotest_payload_dir)])
720
721 def setUp(self):
Evan Hernandeze1e05d32019-07-19 12:32:18 -0600722 self.chroot_dir = '/chroot'
723 self.chroot_tmp_dir = '/chroot/tmp'
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600724 self.image_payload_dir = '/payloads/image'
725 self.autotest_payload_dir = '/payloads/autotest'
726 self.builder = 'moblab-generic-vm/R12-3.4.5-67.890'
727 self.image_cache_dir = '/mnt/moblab/cache'
728 self.image_mount_dir = '/mnt/image'
729
Evan Hernandeze1e05d32019-07-19 12:32:18 -0600730 self.PatchObject(chroot_lib.Chroot, 'tempdir', osutils.TempDir)
Evan Hernandez655e8042019-06-13 12:50:44 -0600731
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600732 self.mock_create_moblab_vms = self.PatchObject(
733 test_service, 'CreateMoblabVm')
734 self.mock_prepare_moblab_vm_image_cache = self.PatchObject(
735 test_service, 'PrepareMoblabVmImageCache',
736 return_value=self.image_cache_dir)
737 self.mock_run_moblab_vm_tests = self.PatchObject(
738 test_service, 'RunMoblabVmTest')
739 self.mock_validate_moblab_vm_tests = self.PatchObject(
740 test_service, 'ValidateMoblabVmTest')
741
742 @contextlib.contextmanager
Alex Klein38c7d9e2019-05-08 09:31:19 -0600743 def MockLoopbackPartitions(*_args, **_kwargs):
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600744 mount = mock.MagicMock()
Evan Hernandez40ee7452019-06-13 12:51:43 -0600745 mount.Mount.return_value = [self.image_mount_dir]
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600746 yield mount
Alex Klein231d2da2019-07-22 16:44:45 -0600747
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600748 self.PatchObject(image_lib, 'LoopbackPartitions', MockLoopbackPartitions)
749
Alex Klein231d2da2019-07-22 16:44:45 -0600750 def testValidateOnly(self):
751 """Sanity check that a validate only call does not execute any logic."""
752 test_controller.MoblabVmTest(self._Input(), self._Output(),
753 self.validate_only_config)
754 self.mock_create_moblab_vms.assert_not_called()
755
Michael Mortensen7a7646d2019-12-12 15:36:14 -0700756 def testMockCall(self):
757 """Test mock call does not execute any logic."""
758 patch = self.PatchObject(key_value_store, 'LoadFile')
759
760 # MoblabVmTest does not return a value, checking mocked value is flagged by
761 # lint.
762 test_controller.MoblabVmTest(self._Input(), self._Output(),
763 self.mock_call_config)
764 patch.assert_not_called()
765
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600766 def testImageContainsBuilder(self):
767 """MoblabVmTest calls service with correct args."""
768 request = self._Input()
769 response = self._Output()
770
771 self.PatchObject(
Mike Frysingere652ba12019-09-08 00:57:43 -0400772 key_value_store, 'LoadFile',
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600773 return_value={cros_set_lsb_release.LSB_KEY_BUILDER_PATH: self.builder})
774
Alex Klein231d2da2019-07-22 16:44:45 -0600775 test_controller.MoblabVmTest(request, response, self.api_config)
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600776
777 self.assertEqual(
778 self.mock_create_moblab_vms.call_args_list,
Evan Hernandeze1e05d32019-07-19 12:32:18 -0600779 [mock.call(mock.ANY, self.chroot_dir, self.image_payload_dir)])
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600780 self.assertEqual(
781 self.mock_prepare_moblab_vm_image_cache.call_args_list,
782 [mock.call(mock.ANY, self.builder, [self.autotest_payload_dir])])
783 self.assertEqual(
784 self.mock_run_moblab_vm_tests.call_args_list,
Evan Hernandez655e8042019-06-13 12:50:44 -0600785 [mock.call(mock.ANY, mock.ANY, self.builder, self.image_cache_dir,
786 mock.ANY)])
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600787 self.assertEqual(
788 self.mock_validate_moblab_vm_tests.call_args_list,
789 [mock.call(mock.ANY)])
790
791 def testImageMissingBuilder(self):
792 """MoblabVmTest dies when builder path not found in lsb-release."""
793 request = self._Input()
794 response = self._Output()
795
Mike Frysingere652ba12019-09-08 00:57:43 -0400796 self.PatchObject(key_value_store, 'LoadFile', return_value={})
Evan Hernandezdc3f0bb2019-06-06 12:46:52 -0600797
798 with self.assertRaises(cros_build_lib.DieSystemExit):
Alex Klein231d2da2019-07-22 16:44:45 -0600799 test_controller.MoblabVmTest(request, response, self.api_config)
David Wellingc1433c22021-06-25 16:29:48 +0000800
801
802class GetArtifactsTest(cros_test_lib.MockTempDirTestCase):
803 """Test GetArtifacts."""
804
805 CODE_COVERAGE_LLVM_ARTIFACT_TYPE = (
806 common_pb2.ArtifactsByService.Test.ArtifactType.CODE_COVERAGE_LLVM_JSON
807 )
George Engelbrecht764b1cd2021-06-18 17:01:07 -0600808 UNIT_TEST_ARTIFACT_TYPE = (
809 common_pb2.ArtifactsByService.Test.ArtifactType.UNIT_TESTS
810 )
David Wellingc1433c22021-06-25 16:29:48 +0000811
812 def setUp(self):
813 """Set up the class for tests."""
814 chroot_dir = os.path.join(self.tempdir, 'chroot')
815 osutils.SafeMakedirs(chroot_dir)
816 osutils.SafeMakedirs(os.path.join(chroot_dir, 'tmp'))
817 self.chroot = chroot_lib.Chroot(chroot_dir)
818
819 sysroot_path = os.path.join(chroot_dir, 'build', 'board')
820 osutils.SafeMakedirs(sysroot_path)
821 self.sysroot = sysroot_lib.Sysroot(sysroot_path)
822
Jack Neusc9707c32021-07-23 21:48:54 +0000823 self.build_target = build_target_lib.BuildTarget('board')
824
David Wellingc1433c22021-06-25 16:29:48 +0000825 def testReturnsEmptyListWhenNoOutputArtifactsProvided(self):
826 """Test empty list is returned when there are no output_artifacts."""
827 result = test_controller.GetArtifacts(
828 common_pb2.ArtifactsByService.Test(output_artifacts=[]),
Jack Neusc9707c32021-07-23 21:48:54 +0000829 self.chroot, self.sysroot, self.build_target, self.tempdir)
David Wellingc1433c22021-06-25 16:29:48 +0000830
831 self.assertEqual(len(result), 0)
832
833 def testShouldCallBundleCodeCoverageLlvmJsonForEachValidArtifact(self):
834 """Test BundleCodeCoverageLlvmJson is called on each valid artifact."""
Sean McAllister17eed8d2021-09-21 10:41:16 -0600835 BundleCodeCoverageLlvmJson_mock = (
836 self.PatchObject(
837 test_service,
838 'BundleCodeCoverageLlvmJson',
839 return_value='test'))
David Wellingc1433c22021-06-25 16:29:48 +0000840
841 test_controller.GetArtifacts(
842 common_pb2.ArtifactsByService.Test(output_artifacts=[
843 # Valid
844 common_pb2.ArtifactsByService.Test.ArtifactInfo(
845 artifact_types=[
846 self.CODE_COVERAGE_LLVM_ARTIFACT_TYPE
847 ]
848 ),
849
850 # Invalid
851 common_pb2.ArtifactsByService.Test.ArtifactInfo(
852 artifact_types=[
853 common_pb2.ArtifactsByService.Test.ArtifactType.UNIT_TESTS
854 ]
855 ),
856 ]),
Jack Neusc9707c32021-07-23 21:48:54 +0000857 self.chroot, self.sysroot, self.build_target, self.tempdir)
David Wellingc1433c22021-06-25 16:29:48 +0000858
859 BundleCodeCoverageLlvmJson_mock.assert_called_once()
860
861 def testShouldReturnValidResult(self):
862 """Test result contains paths and code_coverage_llvm_json type."""
863 self.PatchObject(test_service, 'BundleCodeCoverageLlvmJson',
Sean McAllister17eed8d2021-09-21 10:41:16 -0600864 return_value='test')
George Engelbrecht764b1cd2021-06-18 17:01:07 -0600865 self.PatchObject(test_service, 'BuildTargetUnitTestTarball',
Sean McAllister17eed8d2021-09-21 10:41:16 -0600866 return_value='unit_tests.tar')
David Wellingc1433c22021-06-25 16:29:48 +0000867
868 result = test_controller.GetArtifacts(
869 common_pb2.ArtifactsByService.Test(output_artifacts=[
870 # Valid
871 common_pb2.ArtifactsByService.Test.ArtifactInfo(
872 artifact_types=[
George Engelbrecht764b1cd2021-06-18 17:01:07 -0600873 self.UNIT_TEST_ARTIFACT_TYPE
874 ]
875 ),
876 common_pb2.ArtifactsByService.Test.ArtifactInfo(
877 artifact_types=[
David Wellingc1433c22021-06-25 16:29:48 +0000878 self.CODE_COVERAGE_LLVM_ARTIFACT_TYPE
879 ]
880 ),
881 ]),
Jack Neusc9707c32021-07-23 21:48:54 +0000882 self.chroot, self.sysroot, self.build_target, self.tempdir)
David Wellingc1433c22021-06-25 16:29:48 +0000883
George Engelbrecht764b1cd2021-06-18 17:01:07 -0600884 self.assertEqual(result[0]['paths'], ['unit_tests.tar'])
885 self.assertEqual(result[0]['type'], self.UNIT_TEST_ARTIFACT_TYPE)
886 self.assertEqual(result[1]['paths'], ['test'])
887 self.assertEqual(result[1]['type'], self.CODE_COVERAGE_LLVM_ARTIFACT_TYPE)