Exemple #1
0
    def decompress(self, indata):
        """Decompress data with lzma_alone

        Args:
            indata (bytes): Data to decompress

        Returns:
            bytes: Decompressed data
        """
        with tempfile.NamedTemporaryFile(prefix='decomp.tmp',
                                         dir=tools.GetOutputDir()) as inf:
            tools.WriteFile(inf.name, indata)
            with tempfile.NamedTemporaryFile(prefix='compo.otmp',
                                             dir=tools.GetOutputDir()) as outf:
                args = ['d', inf.name, outf.name]
                self.run_cmd(*args, binary=True)
                return tools.ReadFile(outf.name, binary=True)
Exemple #2
0
    def decompress(self, indata):
        """Decompress data with lz4

        Args:
            indata (bytes): Data to decompress

        Returns:
            bytes: Decompressed data
        """
        with tempfile.NamedTemporaryFile(prefix='decomp.tmp',
                                         dir=tools.GetOutputDir()) as inf:
            tools.WriteFile(inf.name, indata)
            args = ['-cd', inf.name]
            return self.run_cmd(*args, binary=True)
Exemple #3
0
    def compress(self, indata):
        """Compress data with lz4

        Args:
            indata (bytes): Data to compress

        Returns:
            bytes: Compressed data
        """
        with tempfile.NamedTemporaryFile(prefix='comp.tmp',
                                         dir=tools.GetOutputDir()) as tmp:
            tools.WriteFile(tmp.name, indata)
            args = ['--no-frame-crc', '-B4', '-5', '-c', tmp.name]
            return self.run_cmd(*args, binary=True)
Exemple #4
0
    def test_output_dirs(self):
        """Test outputting files to a directory"""
        # Remove the directory so that files from other tests are not there
        tools._RemoveOutputDir()
        tools.PrepareOutputDir(None)

        # This should create the .dts and .dtb in the output directory
        dtb_file = get_dtb_file('dtoc_test_simple.dts')
        outdir = tools.GetOutputDir()
        fnames = glob.glob(outdir + '/*')
        self.assertEqual(2, len(fnames))

        dtb_platdata.run_steps(['all'], dtb_file, False, None, [outdir], True)
        fnames = glob.glob(outdir + '/*')
        self.assertEqual(4, len(fnames))

        leafs = set(os.path.basename(fname) for fname in fnames)
        self.assertEqual(
            {'dt-structs-gen.h', 'source.dts', 'dt-plat.c', 'source.dtb'},
            leafs)