from binman import bintool
from binman import cbfs_util
from binman.cbfs_util import CbfsWriter
+from binman import comp_util
from binman import elf
from patman import test_util
from patman import tools
cls.cbfstool = bintool.Bintool.create('cbfstool')
cls.have_cbfstool = cls.cbfstool.is_present()
- cls.have_lz4 = True
- try:
- tools.Run('lz4', '--no-frame-crc', '-c',
- tools.GetInputFilename('u-boot.bin'), binary=True)
- except:
- cls.have_lz4 = False
+ cls.have_lz4 = comp_util.HAVE_LZ4
@classmethod
def tearDownClass(cls):
import struct
import tempfile
+from binman import bintool
from patman import tools
+LZ4 = bintool.Bintool.create('lz4')
+HAVE_LZ4 = LZ4.is_present()
+
+
def compress(indata, algo, with_header=True):
"""Compress some data using a given algorithm
dir=tools.GetOutputDir()).name
tools.WriteFile(fname, indata)
if algo == 'lz4':
- data = tools.Run('lz4', '--no-frame-crc', '-B4', '-5', '-c', fname,
- binary=True)
+ data = LZ4.compress(indata)
# cbfstool uses a very old version of lzma
elif algo == 'lzma':
outfname = tempfile.NamedTemporaryFile(prefix='%s.comp.otmp' % algo,
fname = tools.GetOutputFilename('%s.decomp.tmp' % algo)
tools.WriteFile(fname, indata)
if algo == 'lz4':
- data = tools.Run('lz4', '-dc', fname, binary=True)
+ data = LZ4.decompress(indata)
elif algo == 'lzma':
outfname = tools.GetOutputFilename('%s.decomp.otmp' % algo)
tools.Run('lzma_alone', 'd', fname, outfname)
TestFunctional._MakeInputFile('env.txt', ENV_DATA)
- # Travis-CI may have an old lz4
- cls.have_lz4 = True
- try:
- tools.Run('lz4', '--no-frame-crc', '-c',
- os.path.join(cls._indir, 'u-boot.bin'), binary=True)
- except:
- cls.have_lz4 = False
+ cls.have_lz4 = comp_util.HAVE_LZ4
@classmethod
def tearDownClass(cls):