コード例 #1
0
    def testArgumentValidation(self):
        """Test the argument validation."""
        # Test errors on missing inputs.
        out_proto = self._OutputProto()
        # Both missing.
        in_proto = self._InputProto()
        with self.assertRaises(cros_build_lib.DieSystemExit):
            sysroot_controller.InstallToolchain(in_proto, out_proto,
                                                self.api_config)

        # Sysroot path missing.
        in_proto = self._InputProto(build_target=self.board)
        with self.assertRaises(cros_build_lib.DieSystemExit):
            sysroot_controller.InstallToolchain(in_proto, out_proto,
                                                self.api_config)

        # Build target name missing.
        in_proto = self._InputProto(sysroot_path=self.sysroot)
        with self.assertRaises(cros_build_lib.DieSystemExit):
            sysroot_controller.InstallToolchain(in_proto, out_proto,
                                                self.api_config)

        # Both provided, but invalid sysroot path.
        in_proto = self._InputProto(build_target=self.board,
                                    sysroot_path=self.invalid_sysroot)
        with self.assertRaises(cros_build_lib.DieSystemExit):
            sysroot_controller.InstallToolchain(in_proto, out_proto,
                                                self.api_config)
コード例 #2
0
    def testValidateOnly(self):
        """Sanity check that a validate only call does not execute any logic."""
        patch = self.PatchObject(sysroot_service, 'InstallToolchain')

        in_proto = self._InputProto(build_target=self.board,
                                    sysroot_path=self.sysroot)
        sysroot_controller.InstallToolchain(in_proto, self._OutputProto(),
                                            self.validate_only_config)
        patch.assert_not_called()
コード例 #3
0
    def testSuccessOutputHandling(self):
        """Test the output is processed and recorded correctly."""
        self.PatchObject(sysroot_service, 'InstallToolchain')
        out_proto = self._OutputProto()
        in_proto = self._InputProto(build_target=self.board,
                                    sysroot_path=self.sysroot)

        rc = sysroot_controller.InstallToolchain(in_proto, out_proto,
                                                 self.api_config)
        self.assertFalse(rc)
        self.assertFalse(out_proto.failed_packages)
コード例 #4
0
    def testMockCall(self):
        """Sanity check that a mock call does not execute any logic."""
        patch = self.PatchObject(sysroot_service, 'InstallToolchain')
        request = self._InputProto()
        response = self._OutputProto()

        rc = sysroot_controller.InstallToolchain(request, response,
                                                 self.mock_call_config)

        patch.assert_not_called()
        self.assertEqual(controller.RETURN_CODE_SUCCESS, rc)
コード例 #5
0
    def testMockError(self):
        """Sanity check that a mock error does not execute any logic."""
        patch = self.PatchObject(sysroot_service, 'InstallToolchain')
        request = self._InputProto()
        response = self._OutputProto()

        rc = sysroot_controller.InstallToolchain(request, response,
                                                 self.mock_error_config)

        patch.assert_not_called()
        self.assertEqual(
            controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc)
        self.assertTrue(response.failed_packages)
コード例 #6
0
    def testErrorOutputHandling(self):
        """Test the error output is processed and recorded correctly."""
        out_proto = self._OutputProto()
        in_proto = self._InputProto(build_target=self.board,
                                    sysroot_path=self.sysroot)

        err_pkgs = ['cat/pkg', 'cat2/pkg2']
        err_cpvs = [
            portage_util.SplitCPV(pkg, strict=False) for pkg in err_pkgs
        ]
        expected = [('cat', 'pkg'), ('cat2', 'pkg2')]
        err = sysroot_lib.ToolchainInstallError('Error',
                                                cros_build_lib.CommandResult(),
                                                tc_info=err_cpvs)
        self.PatchObject(sysroot_service, 'InstallToolchain', side_effect=err)

        rc = sysroot_controller.InstallToolchain(in_proto, out_proto,
                                                 self.api_config)
        self.assertEqual(
            controller.RETURN_CODE_UNSUCCESSFUL_RESPONSE_AVAILABLE, rc)
        self.assertTrue(out_proto.failed_packages)
        for package in out_proto.failed_packages:
            cat_pkg = (package.category, package.package_name)
            self.assertIn(cat_pkg, expected)