def test_get_firmware_versions_on_unibuild(self, mock_read_gs):
        """Test get_firmware_version on uni-build."""
        metadata_json = """
{
    "unibuild": true,
    "board-metadata":{
        "coral":{
            "kernel-version":"4.4.114-r1354",
            "models":{
                "blue":{
                    "main-readonly-firmware-version":"Google_Coral.10068.37.0",
                    "main-readwrite-firmware-version":"Google_Coral.10068.39.0"
                },
                "robo360":{
                    "main-readonly-firmware-version":"Google_Coral.10068.34.0",
                    "main-readwrite-firmware-version":null
                },
                "porbeagle":{
                    "main-readonly-firmware-version":null,
                    "main-readwrite-firmware-version":null
                }
            }
        }
    }
}
"""
        mock_read_gs.return_value = json.loads(metadata_json)
        fw_version = build_data.get_firmware_versions('coral',
                                                      self.cros_version)
        expected_version = {
            'blue': 'Google_Coral.10068.39.0',
            'robo360': 'Google_Coral.10068.34.0',
            'porbeagle': None
        }
        self.assertEqual(fw_version, expected_version)
Beispiel #2
0
    def delete_mapping(self, board):
        """Delete the Chrome OS mapping for the given board.

        This function handles deletes the Chrome OS version mapping for the
        given board.  Additionally, any R/W firmware mapping that existed
        because of the OS mapping will be deleted as well.

        @param board    Chrome OS board to be deleted from the mapping.
        """
        version = self.get_mapping(board)
        super(_CrOSVersionMapHandler, self).delete_mapping(board)
        fw_versions = build_data.get_firmware_versions(board, version)
        fw_handler = _FirmwareVersionMapHandler(self._afe, self._dry_run)
        for model in fw_versions.iterkeys():
            fw_handler.delete_mapping(model)
Beispiel #3
0
def _get_firmware_upgrades(cros_versions):
    """
    Get the new firmware versions to which we should update.

    @param cros_versions    Current board->cros version mappings in the
                            AFE.
    @return A dictionary mapping boards/models to firmware upgrade versions.
            If the build is unibuild, the key is a model name; else, the key
            is a board name.
    """
    firmware_upgrades = {}
    for board, version in cros_versions.iteritems():
        firmware_upgrades.update(
            build_data.get_firmware_versions(board, version))
    return firmware_upgrades
    def test_get_firmware_versions_on_unibuild_no_models(self, mock_read_gs):
        """Test get_firmware_versions on uni-build without models dict."""
        metadata_json = """
{
    "unibuild": true,
    "board-metadata":{
        "coral":{
            "kernel-version":"4.4.114-r1354"
        }
    }
}
"""
        mock_read_gs.return_value = json.loads(metadata_json)
        fw_version = build_data.get_firmware_versions('coral',
                                                      self.cros_version)
        self.assertEqual(fw_version, {'coral': None})
    def test_get_firmware_versions_on_normal_build(self, mock_read_gs):
        """Test get_firmware_versions on normal build."""
        metadata_json = """
{
    "unibuild": false,
    "board-metadata":{
        "auron_paine":{
             "main-firmware-version":"Google_Auron_paine.6301.58.98"
        }
   }
}
        """
        mock_read_gs.return_value = json.loads(metadata_json)
        board = 'auron_paine'

        fw_version = build_data.get_firmware_versions(board, self.cros_version)
        expected_version = {board: "Google_Auron_paine.6301.58.98"}
        self.assertEqual(fw_version, expected_version)
Beispiel #6
0
    def set_mapping(self, board, version):
        """Assign the Chrome OS mapping for the given board.

        This function assigns the given Chrome OS version to the given
        board.  Additionally, for any model with firmware bundled in the
        assigned build, that model will be assigned the firmware version
        found for it in the build.

        @param board    Chrome OS board to be assigned a new version.
        @param version  New Chrome OS version to be assigned to the
                        board.
        """
        new_version = build_data.get_omaha_upgrade(
            build_data.get_omaha_version_map(), board, version)
        if new_version != version:
            print 'Force %s version from Omaha:  %-12s -> %s' % (
                self._description, board, new_version)
        super(_CrOSVersionMapHandler, self).set_mapping(board, new_version)
        fw_versions = build_data.get_firmware_versions(board, new_version)
        fw_handler = _FirmwareVersionMapHandler(self._afe, self._dry_run)
        for model, fw_version in fw_versions.iteritems():
            if fw_version is not None:
                fw_handler.set_mapping(model, fw_version)
 def test_get_firmware_versions_with_exceptions(self, mock_read_gs):
     """Test get_firmware_versions on normal build with exceptions."""
     afe_mock = mock.Mock()
     fw_version = build_data.get_firmware_versions('auron_paine',
                                                   self.cros_version)
     self.assertEqual(fw_version, {'auron_paine': None})