This adds new unittests to cover more error cases in the parsing logic.
Bug: None
Test: Added more unittests.
Change-Id: I897ae5e966fb6777d047855a72ff0a8489f4711f
Add a parser of format, type and quality in the bsdiff main function.
This allow the bsdiff binary to choose between the BSDFF40|BSDF2 patch
format and compress the patch with desired algorithms.
Bug: 34220646
Test: unittest pass; generate brotli compressed patches with bsdiff
binary
Change-Id: Ia4f7941e4eca7e6047e2749315127d1cf4a988ee
When we close the BrotliDecompressor, we check for
BrotliDecoderIsFinished(). This function may return false if we never
call BrotliDecoderDecompressStream(), leading to a failure in bspatch
in case of an empty brotli stream.
This CL fixes the issue by checking BrotliDecoderIsUsed() along with
IsFinished(). Since we have the compressed stream and the precomputed
uncompressed size in the patch; we need these checks to avoid unexpected
size mismatch.
Bug: 69472150
Test: unittest pass
Change-Id: Icf7b324836fa59fd3111ba91b03622215a0c8f5f
Add a new BSDF2 format that allows compression of ctrl/diff/extra streams
with different algorithms. The compression algorithm supported for now is
bz2 and brotli. This new format is similar to the legacy "BSDIFF40" format
except for the magic headers.
File format:
0 8 magic header
8 8 X
16 8 Y
24 8 new_file_size
32 X compressed control block
32+X Y compressed diff block
32+X+Y ??? compressed extra block
The magic header for BSDF2 format:
0 5 BSDF2
5 1 compressed type for control stream
6 1 compressed type for diff stream
7 1 compressed type for extra stream
Bug: 34220646
Test: unittest pass
Change-Id: I6eb0867e88476dbc4a4b7be609783f8c8a0a41cd
Add a wrapper class to separate the patch read from data stream
decompression. Therefore, bspatch will be able to process the patch
that is compressed with various tools.
Test: unittest pass
Change-Id: I5214e0451bde80366e8a70b960703afb2b2a7d97