From 1c26e2ed9bf8ae5cd9f4c5437fcfe0b131b4a7da Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Thu, 26 Oct 2017 17:19:41 -0700 Subject: Add the brotli compressor for bsdiff Add a new compressor interface; and the brotli compressor which is similar to the existing bz2 one. Also add a new CompressorType argument to PatchWriter's init function; this allows us to choose the right compressor based on the input option in the future. Bug: 34220646 Test: Run bsdiff/bspatch with brotli compressor/decompressor over a list of files from angler's system image. Make succeeds. Change-Id: Id9a3db2d7d051dcb751a1fc362f4c3b9226e878b --- brotli_compressor_unittest.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 brotli_compressor_unittest.cc (limited to 'brotli_compressor_unittest.cc') diff --git a/brotli_compressor_unittest.cc b/brotli_compressor_unittest.cc new file mode 100644 index 0000000..5b968c3 --- /dev/null +++ b/brotli_compressor_unittest.cc @@ -0,0 +1,29 @@ +// Copyright 2017 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "bsdiff/brotli_compressor.h" + +#include + +namespace { + +const uint8_t kHelloWorld[] = { + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x0a, +}; +} // namespace + +namespace bsdiff { + +TEST(BrotliCompressorTest, BrotliCompressorSmoke) { + BrotliCompressor brotli_compressor; + EXPECT_TRUE(brotli_compressor.Write(kHelloWorld, sizeof(kHelloWorld))); + EXPECT_TRUE(brotli_compressor.Finish()); + std::vector compressed_data = brotli_compressor.GetCompressedData(); + EXPECT_GT(compressed_data.size(), static_cast(0)); + + // TODO(xunchang) run brotli decompressor and check we can get back + // kHelloWorld. +} + +} // namespace bsdiff \ No newline at end of file -- cgit v1.2.3