Ejemplo n.º 1
0
    def test_cbfs_functions(self):
        """Test global functions of cbfs_util"""
        self.assertEqual(cbfs_util.ARCHITECTURE_X86,
                         cbfs_util.find_arch('x86'))
        self.assertIsNone(cbfs_util.find_arch('bad-arch'))

        self.assertEqual(cbfs_util.COMPRESS_LZMA,
                         cbfs_util.find_compress('lzma'))
        self.assertIsNone(cbfs_util.find_compress('bad-comp'))
Ejemplo n.º 2
0
 def ObtainContents(self, skip=None):
     arch = cbfs_util.find_arch(self._cbfs_arg)
     if arch is None:
         self.Raise("Invalid architecture '%s'" % self._cbfs_arg)
     if self.size is None:
         self.Raise("'cbfs' entry must have a size property")
     cbfs = CbfsWriter(self.size, arch)
     for entry in self._cbfs_entries.values():
         # First get the input data and put it in a file. If not available,
         # try later.
         if entry != skip and not entry.ObtainContents():
             return False
         data = entry.GetData()
         cfile = None
         if entry._type == 'raw':
             cfile = cbfs.add_file_raw(entry._cbfs_name, data,
                                       entry._cbfs_offset,
                                       entry._cbfs_compress)
         elif entry._type == 'stage':
             cfile = cbfs.add_file_stage(entry._cbfs_name, data,
                                         entry._cbfs_offset)
         else:
             entry.Raise("Unknown cbfs-type '%s' (use 'raw', 'stage')" %
                         entry._type)
         if cfile:
             entry._cbfs_file = cfile
     data = cbfs.get_data()
     self.SetContents(data)
     return True
Ejemplo n.º 3
0
 def ObtainContents(self, skip_entry=None):
     arch = cbfs_util.find_arch(self._cbfs_arg)
     if arch is None:
         self.Raise("Invalid architecture '%s'" % self._cbfs_arg)
     if self.size is None:
         self.Raise("'cbfs' entry must have a size property")
     cbfs = CbfsWriter(self.size, arch)
     for entry in self._entries.values():
         if entry != skip_entry and not entry.ObtainContents():
             return False
         cfile = self.ObtainCfile(cbfs, entry)
         if cfile:
             entry._cbfs_file = cfile
     data = cbfs.get_data()
     self.SetContents(data)
     return True