sysroot.py & image.py: Add no specific packages failed condition.
Handling for when there was a failure but nothing to report.
BUG=chromium:983279
TEST=run_tests
Change-Id: I2b82492ae2b2f534f587d7f45df86fbc2ddd4ce5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1697376
Commit-Queue: Alex Klein <saklein@chromium.org>
Commit-Queue: Evan Hernandez <evanhernandez@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Evan Hernandez <evanhernandez@chromium.org>
Auto-Submit: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/sysroot_unittest.py b/api/controller/sysroot_unittest.py
index 6e9e4c4..d722936 100644
--- a/api/controller/sysroot_unittest.py
+++ b/api/controller/sysroot_unittest.py
@@ -288,7 +288,31 @@
self.PatchObject(sysroot_service, 'BuildPackages', side_effect=error)
rc = sysroot_controller.InstallPackages(in_proto, out_proto)
- self.assertTrue(rc)
+ # This needs to return 2 to indicate the available error response.
+ self.assertEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc)
for package in out_proto.failed_packages:
cat_pkg = (package.category, package.package_name)
self.assertIn(cat_pkg, expected)
+
+ def testNoPackageFailureOutputHandling(self):
+ """Test failure handling without packages to report."""
+ # Prevent argument validation error.
+ self.PatchObject(sysroot_lib.Sysroot, 'IsToolchainInstalled',
+ return_value=True)
+
+ in_proto = self._InputProto(build_target=self.build_target,
+ sysroot_path=self.sysroot)
+ out_proto = self._OutputProto()
+
+ # Force error to be raised with no packages.
+ error = sysroot_lib.PackageInstallError('Error',
+ cros_build_lib.CommandResult(),
+ packages=[])
+ self.PatchObject(sysroot_service, 'BuildPackages', side_effect=error)
+
+ rc = sysroot_controller.InstallPackages(in_proto, out_proto)
+ # All we really care about is it's not 0 or 2 (response available), so
+ # test for that rather than a specific return code.
+ self.assertTrue(rc)
+ self.assertNotEqual(controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE,
+ rc)