aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2023-10-20 17:26:46 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-10-20 17:26:46 +0000
commit3f1ccacc9bce497a0d603b1070b0b8ab58a68478 (patch)
tree2ea653f105e2ca64642ef44c328ffc2386fe3755
parentc69470f80950a32f9b14b0eca730663f5aa8b5e4 (diff)
parent47ee2838d758c3bc9944c97edba0dc2b168aec58 (diff)
downloadpuffin-3f1ccacc9bce497a0d603b1070b0b8ab58a68478.tar.gz
PRESUBMIT: enable cros format am: b25bc572b5 am: 47ee2838d7
Original change: https://android-review.googlesource.com/c/platform/external/puffin/+/2794923 Change-Id: Ibd442b5af1e1ac8cf62b485d573ba77e5aa75d04 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--BUILD.gn56
-rw-r--r--OWNERS2
-rw-r--r--PRESUBMIT.cfg4
-rwxr-xr-xscripts/measure_patch_size.py197
-rwxr-xr-xscripts/test_corpus.py280
-rw-r--r--src/brotli_util.cc5
-rw-r--r--src/brotli_util_unittest.cc2
-rw-r--r--src/fuzzer_puffpatch.cc2
-rw-r--r--src/integration_test.cc2
-rw-r--r--src/main.cc2
-rw-r--r--src/patching_unittest.cc2
-rw-r--r--src/puffdiff.cc2
-rw-r--r--src/puffin_unittest.cc2
-rw-r--r--src/puffpatch.cc2
-rw-r--r--src/stream_unittest.cc2
-rw-r--r--src/utils.cc2
-rw-r--r--src/utils_unittest.cc2
17 files changed, 308 insertions, 258 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 7d056bf..96e7d29 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -7,8 +7,8 @@ import("//common-mk/proto_library.gni")
group("all") {
deps = [
- ":libpuffin-proto",
":libpuffdiff",
+ ":libpuffin-proto",
":libpuffpatch",
":puffin",
]
@@ -25,9 +25,7 @@ group("all") {
}
pkg_config("target_defaults") {
- pkg_deps = [
- "libchrome",
- ]
+ pkg_deps = [ "libchrome" ]
if (use.fuzzer) {
# Link against protobuf for fuzzers so we can use libprotobuf-mutator.
pkg_deps += [ "protobuf" ]
@@ -46,15 +44,11 @@ pkg_config("target_defaults") {
proto_library("libpuffin-proto") {
proto_in_dir = "src"
proto_out_dir = "include/puffin/src"
- sources = [
- "src/puffin.proto",
- ]
+ sources = [ "src/puffin.proto" ]
}
pkg_config("libpuffpatch_config") {
- pkg_deps = [
- "libbspatch",
- ]
+ pkg_deps = [ "libbspatch" ]
}
static_library("libpuffpatch") {
@@ -80,9 +74,7 @@ static_library("libpuffpatch") {
}
pkg_config("libpuffdiff_config") {
- pkg_deps = [
- "libbsdiff",
- ]
+ pkg_deps = [ "libbsdiff" ]
}
static_library("libpuffdiff") {
configs += [
@@ -91,9 +83,7 @@ static_library("libpuffdiff") {
":libpuffdiff_config",
]
configs -= [ "//common-mk:use_thin_archive" ]
- deps = [
- ":libpuffpatch",
- ]
+ deps = [ ":libpuffpatch" ]
sources = [
"src/file_stream.cc",
"src/memory_stream.cc",
@@ -103,9 +93,7 @@ static_library("libpuffdiff") {
}
pkg_config("libbrillo") {
- pkg_deps = [
- "libbrillo",
- ]
+ pkg_deps = [ "libbrillo" ]
}
executable("puffin") {
@@ -113,9 +101,7 @@ executable("puffin") {
":libbrillo",
":target_defaults",
]
- deps = [
- ":libpuffdiff",
- ]
+ deps = [ ":libpuffdiff" ]
sources = [
"src/extent_stream.cc",
"src/main.cc",
@@ -140,8 +126,8 @@ if (use.test) {
"src/utils_unittest.cc",
]
deps = [
- "//common-mk/testrunner",
":libpuffdiff",
+ "//common-mk/testrunner",
]
}
}
@@ -153,12 +139,8 @@ if (use.fuzzer) {
":libbrillo",
":target_defaults",
]
- deps = [
- ":libpuffpatch",
- ]
- sources = [
- "src/fuzzer_huff.cc",
- ]
+ deps = [ ":libpuffpatch" ]
+ sources = [ "src/fuzzer_huff.cc" ]
}
executable("puffin_puff_fuzzer") {
configs += [
@@ -166,12 +148,8 @@ if (use.fuzzer) {
":libbrillo",
":target_defaults",
]
- deps = [
- ":libpuffpatch",
- ]
- sources = [
- "src/fuzzer_puff.cc",
- ]
+ deps = [ ":libpuffpatch" ]
+ sources = [ "src/fuzzer_puff.cc" ]
}
executable("puffin_puffpatch_fuzzer") {
configs += [
@@ -179,11 +157,7 @@ if (use.fuzzer) {
":libbrillo",
":target_defaults",
]
- deps = [
- ":libpuffdiff",
- ]
- sources = [
- "src/fuzzer_puffpatch.cc",
- ]
+ deps = [ ":libpuffdiff" ]
+ sources = [ "src/fuzzer_puffpatch.cc" ]
}
}
diff --git a/OWNERS b/OWNERS
index de970a0..d40b9cc 100644
--- a/OWNERS
+++ b/OWNERS
@@ -6,4 +6,4 @@ xunchang@google.com
zhangkelvin@google.com
# Chrome OS
-kimjae@google.com \ No newline at end of file
+kimjae@google.com
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
index e037261..68a3fb1 100644
--- a/PRESUBMIT.cfg
+++ b/PRESUBMIT.cfg
@@ -1,5 +1,3 @@
[Hook Scripts]
+cros format = cros format --check --commit ${PRESUBMIT_COMMIT} ${PRESUBMIT_FILES}
cros lint = cros lint --commit ${PRESUBMIT_COMMIT} ${PRESUBMIT_FILES}
-
-[Hook Overrides]
-clang_format_check: true
diff --git a/scripts/measure_patch_size.py b/scripts/measure_patch_size.py
index 4244040..ac37c71 100755
--- a/scripts/measure_patch_size.py
+++ b/scripts/measure_patch_size.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python3
-#
# Copyright 2018 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
"""A tool for running diffing tools and measuring patch sizes."""
@@ -16,91 +14,122 @@ import tempfile
class Error(Exception):
- """Puffin general processing error."""
+ """Puffin general processing error."""
def ParseArguments(argv):
- """Parses and Validates command line arguments.
-
- Args:
- argv: command line arguments to parse.
-
- Returns:
- The arguments list.
- """
- parser = argparse.ArgumentParser()
-
- parser.add_argument('--src-corpus', metavar='DIR',
- help='The source corpus directory with compressed files.')
- parser.add_argument('--tgt-corpus', metavar='DIR',
- help='The target corpus directory with compressed files.')
- parser.add_argument('--debug', action='store_true',
- help='Turns on verbosity.')
-
- # Parse command-line arguments.
- args = parser.parse_args(argv)
-
- for corpus in (args.src_corpus, args.tgt_corpus):
- if not corpus or not os.path.isdir(corpus):
- raise Error('Corpus directory {} is non-existent or inaccesible'
- .format(corpus))
- return args
+ """Parses and Validates command line arguments.
+
+ Args:
+ argv: command line arguments to parse.
+
+ Returns:
+ The arguments list.
+ """
+ parser = argparse.ArgumentParser()
+
+ parser.add_argument(
+ "--src-corpus",
+ metavar="DIR",
+ help="The source corpus directory with compressed files.",
+ )
+ parser.add_argument(
+ "--tgt-corpus",
+ metavar="DIR",
+ help="The target corpus directory with compressed files.",
+ )
+ parser.add_argument(
+ "--debug", action="store_true", help="Turns on verbosity."
+ )
+
+ # Parse command-line arguments.
+ args = parser.parse_args(argv)
+
+ for corpus in (args.src_corpus, args.tgt_corpus):
+ if not corpus or not os.path.isdir(corpus):
+ raise Error(
+ "Corpus directory {} is non-existent or inaccesible".format(
+ corpus
+ )
+ )
+ return args
def main(argv):
- """The main function."""
- args = ParseArguments(argv[1:])
-
- if args.debug:
- logging.getLogger().setLevel(logging.DEBUG)
-
- # Construct list of appropriate files.
- src_files = list(filter(os.path.isfile,
- [os.path.join(args.src_corpus, f)
- for f in os.listdir(args.src_corpus)]))
- tgt_files = list(filter(os.path.isfile,
- [os.path.join(args.tgt_corpus, f)
- for f in os.listdir(args.tgt_corpus)]))
-
- # Check if all files in src_files have a target file in tgt_files.
- files_mismatch = (set(map(os.path.basename, src_files)) -
- set(map(os.path.basename, tgt_files)))
- if files_mismatch:
- raise Error('Target files {} do not exist in corpus: {}'
- .format(files_mismatch, args.tgt_corpus))
-
- for src in src_files:
- with tempfile.NamedTemporaryFile() as puffdiff_patch, \
- tempfile.NamedTemporaryFile() as bsdiff_patch:
-
- tgt = os.path.join(args.tgt_corpus, os.path.basename(src))
-
- operation = 'puffdiff'
- cmd = ['puffin',
- '--operation={}'.format(operation),
- '--src_file={}'.format(src),
- '--dst_file={}'.format(tgt),
- '--patch_file={}'.format(puffdiff_patch.name)]
- # Running the puffdiff operation
- if subprocess.call(cmd) != 0:
- raise Error('Puffin failed to do {} command: {}'
- .format(operation, cmd))
-
- operation = 'bsdiff'
- cmd = ['bsdiff', '--type', 'bz2', src, tgt, bsdiff_patch.name]
- # Running the bsdiff operation
- if subprocess.call(cmd) != 0:
- raise Error('Failed to do {} command: {}'
- .format(operation, cmd))
-
- logging.debug('%s(%d -> %d) : bsdiff(%d), puffdiff(%d)',
- os.path.basename(src),
- os.stat(src).st_size, os.stat(tgt).st_size,
- os.stat(bsdiff_patch.name).st_size,
- os.stat(puffdiff_patch.name).st_size)
-
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ """The main function."""
+ args = ParseArguments(argv[1:])
+
+ if args.debug:
+ logging.getLogger().setLevel(logging.DEBUG)
+
+ # Construct list of appropriate files.
+ src_files = list(
+ filter(
+ os.path.isfile,
+ [
+ os.path.join(args.src_corpus, f)
+ for f in os.listdir(args.src_corpus)
+ ],
+ )
+ )
+ tgt_files = list(
+ filter(
+ os.path.isfile,
+ [
+ os.path.join(args.tgt_corpus, f)
+ for f in os.listdir(args.tgt_corpus)
+ ],
+ )
+ )
+
+ # Check if all files in src_files have a target file in tgt_files.
+ files_mismatch = set(map(os.path.basename, src_files)) - set(
+ map(os.path.basename, tgt_files)
+ )
+ if files_mismatch:
+ raise Error(
+ "Target files {} do not exist in corpus: {}".format(
+ files_mismatch, args.tgt_corpus
+ )
+ )
+
+ for src in src_files:
+ with tempfile.NamedTemporaryFile() as puffdiff_patch, tempfile.NamedTemporaryFile() as bsdiff_patch:
+ tgt = os.path.join(args.tgt_corpus, os.path.basename(src))
+
+ operation = "puffdiff"
+ cmd = [
+ "puffin",
+ "--operation={}".format(operation),
+ "--src_file={}".format(src),
+ "--dst_file={}".format(tgt),
+ "--patch_file={}".format(puffdiff_patch.name),
+ ]
+ # Running the puffdiff operation
+ if subprocess.call(cmd) != 0:
+ raise Error(
+ "Puffin failed to do {} command: {}".format(operation, cmd)
+ )
+
+ operation = "bsdiff"
+ cmd = ["bsdiff", "--type", "bz2", src, tgt, bsdiff_patch.name]
+ # Running the bsdiff operation
+ if subprocess.call(cmd) != 0:
+ raise Error(
+ "Failed to do {} command: {}".format(operation, cmd)
+ )
+
+ logging.debug(
+ "%s(%d -> %d) : bsdiff(%d), puffdiff(%d)",
+ os.path.basename(src),
+ os.stat(src).st_size,
+ os.stat(tgt).st_size,
+ os.stat(bsdiff_patch.name).st_size,
+ os.stat(puffdiff_patch.name).st_size,
+ )
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
diff --git a/scripts/test_corpus.py b/scripts/test_corpus.py
index 6cff6c4..357e18b 100755
--- a/scripts/test_corpus.py
+++ b/scripts/test_corpus.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python3
-#
# Copyright 2018 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
"""A tool for running puffin tests in a corpus of deflate compressed files."""
@@ -15,127 +13,179 @@ import subprocess
import sys
import tempfile
-_PUFFHUFF = 'puffhuff'
-_PUFFDIFF = 'puffdiff'
+
+_PUFFHUFF = "puffhuff"
+_PUFFDIFF = "puffdiff"
TESTS = (_PUFFHUFF, _PUFFDIFF)
class Error(Exception):
- """Puffin general processing error."""
+ """Puffin general processing error."""
def ParseArguments(argv):
- """Parses and Validates command line arguments.
-
- Args:
- argv: command line arguments to parse.
-
- Returns:
- The arguments list.
- """
- parser = argparse.ArgumentParser()
-
- parser.add_argument('corpus', metavar='CORPUS',
- help='A corpus directory containing compressed files')
- parser.add_argument('-d', '--disabled_tests', default=(), metavar='',
- nargs='*',
- help=('Space separated list of tests to disable. '
- 'Allowed options include: ' + ', '.join(TESTS)),
- choices=TESTS)
- parser.add_argument('--cache_size', type=int, metavar='SIZE',
- help='The size (in bytes) of the cache for puffpatch '
- 'operations.')
- parser.add_argument('--debug', action='store_true',
- help='Turns on verbosity.')
-
- # Parse command-line arguments.
- args = parser.parse_args(argv)
-
- if not os.path.isdir(args.corpus):
- raise Error('Corpus directory {} is non-existent or inaccesible'
- .format(args.corpus))
- return args
+ """Parses and Validates command line arguments.
+
+ Args:
+ argv: command line arguments to parse.
+
+ Returns:
+ The arguments list.
+ """
+ parser = argparse.ArgumentParser()
+
+ parser.add_argument(
+ "corpus",
+ metavar="CORPUS",
+ help="A corpus directory containing compressed files",
+ )
+ parser.add_argument(
+ "-d",
+ "--disabled_tests",
+ default=(),
+ metavar="",
+ nargs="*",
+ help=(
+ "Space separated list of tests to disable. "
+ "Allowed options include: " + ", ".join(TESTS)
+ ),
+ choices=TESTS,
+ )
+ parser.add_argument(
+ "--cache_size",
+ type=int,
+ metavar="SIZE",
+ help="The size (in bytes) of the cache for puffpatch " "operations.",
+ )
+ parser.add_argument(
+ "--debug", action="store_true", help="Turns on verbosity."
+ )
+
+ # Parse command-line arguments.
+ args = parser.parse_args(argv)
+
+ if not os.path.isdir(args.corpus):
+ raise Error(
+ "Corpus directory {} is non-existent or inaccesible".format(
+ args.corpus
+ )
+ )
+ return args
def main(argv):
- """The main function."""
- args = ParseArguments(argv[1:])
-
- if args.debug:
- logging.getLogger().setLevel(logging.DEBUG)
-
- # Construct list of appropriate files.
- files = list(filter(os.path.isfile, [os.path.join(args.corpus, f)
- for f in os.listdir(args.corpus)]))
-
- # For each file in corpus run puffhuff.
- if _PUFFHUFF not in args.disabled_tests:
- for src in files:
- with tempfile.NamedTemporaryFile() as tgt_file:
-
- operation = 'puffhuff'
- logging.debug('Running %s on %s', operation, src)
- cmd = ['puffin',
- '--operation={}'.format(operation),
- '--src_file={}'.format(src),
- '--dst_file={}'.format(tgt_file.name)]
- if subprocess.call(cmd) != 0:
- raise Error('Puffin failed to do {} command: {}'
- .format(operation, cmd))
-
- if not filecmp.cmp(src, tgt_file.name):
- raise Error('The generated file {} is not equivalent to the original '
- 'file {} after {} operation.'
- .format(tgt_file.name, src, operation))
-
- if _PUFFDIFF not in args.disabled_tests:
- # Run puffdiff and puffpatch for each pairs of files in the corpus.
- for src in files:
- for tgt in files:
- with tempfile.NamedTemporaryFile() as patch, \
- tempfile.NamedTemporaryFile() as new_tgt:
-
- operation = 'puffdiff'
- logging.debug('Running %s on %s (%d) and %s (%d)',
+ """The main function."""
+ args = ParseArguments(argv[1:])
+
+ if args.debug:
+ logging.getLogger().setLevel(logging.DEBUG)
+
+ # Construct list of appropriate files.
+ files = list(
+ filter(
+ os.path.isfile,
+ [os.path.join(args.corpus, f) for f in os.listdir(args.corpus)],
+ )
+ )
+
+ # For each file in corpus run puffhuff.
+ if _PUFFHUFF not in args.disabled_tests:
+ for src in files:
+ with tempfile.NamedTemporaryFile() as tgt_file:
+ operation = "puffhuff"
+ logging.debug("Running %s on %s", operation, src)
+ cmd = [
+ "puffin",
+ "--operation={}".format(operation),
+ "--src_file={}".format(src),
+ "--dst_file={}".format(tgt_file.name),
+ ]
+ if subprocess.call(cmd) != 0:
+ raise Error(
+ "Puffin failed to do {} command: {}".format(
+ operation, cmd
+ )
+ )
+
+ if not filecmp.cmp(src, tgt_file.name):
+ raise Error(
+ "The generated file {} is not equivalent to the "
+ "original file {} after {} operation.".format(
+ tgt_file.name, src, operation
+ )
+ )
+
+ if _PUFFDIFF not in args.disabled_tests:
+ # Run puffdiff and puffpatch for each pairs of files in the corpus.
+ for src in files:
+ for tgt in files:
+ with tempfile.NamedTemporaryFile() as patch, \
+ tempfile.NamedTemporaryFile() as new_tgt:
+ operation = "puffdiff"
+ logging.debug(
+ "Running %s on %s (%d) and %s (%d)",
+ operation,
+ os.path.basename(src),
+ os.stat(src).st_size,
+ os.path.basename(tgt),
+ os.stat(tgt).st_size,
+ )
+ cmd = [
+ "puffin",
+ "--operation={}".format(operation),
+ "--src_file={}".format(src),
+ "--dst_file={}".format(tgt),
+ "--patch_file={}".format(patch.name),
+ ]
+
+ # Running the puffdiff operation
+ if subprocess.call(cmd) != 0:
+ raise Error(
+ "Puffin failed to do {} command: {}".format(
+ operation, cmd
+ )
+ )
+
+ logging.debug(
+ "Patch size is: %d", os.stat(patch.name).st_size
+ )
+
+ operation = "puffpatch"
+ logging.debug(
+ "Running %s on src file %s and patch %s",
operation,
- os.path.basename(src), os.stat(src).st_size,
- os.path.basename(tgt), os.stat(tgt).st_size)
- cmd = ['puffin',
- '--operation={}'.format(operation),
- '--src_file={}'.format(src),
- '--dst_file={}'.format(tgt),
- '--patch_file={}'.format(patch.name)]
-
- # Running the puffdiff operation
- if subprocess.call(cmd) != 0:
- raise Error('Puffin failed to do {} command: {}'
- .format(operation, cmd))
-
- logging.debug('Patch size is: %d', os.stat(patch.name).st_size)
-
- operation = 'puffpatch'
- logging.debug('Running %s on src file %s and patch %s',
- operation, os.path.basename(src), patch.name)
- cmd = ['puffin',
- '--operation={}'.format(operation),
- '--src_file={}'.format(src),
- '--dst_file={}'.format(new_tgt.name),
- '--patch_file={}'.format(patch.name)]
- if args.cache_size:
- cmd += ['--cache_size={}'.format(args.cache_size)]
-
- # Running the puffpatch operation
- if subprocess.call(cmd) != 0:
- raise Error('Puffin failed to do {} command: {}'
- .format(operation, cmd))
-
- if not filecmp.cmp(tgt, new_tgt.name):
- raise Error('The generated file {} is not equivalent to the '
- 'original file {} after puffpatch operation.'
- .format(new_tgt.name, tgt))
-
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ os.path.basename(src),
+ patch.name,
+ )
+ cmd = [
+ "puffin",
+ "--operation={}".format(operation),
+ "--src_file={}".format(src),
+ "--dst_file={}".format(new_tgt.name),
+ "--patch_file={}".format(patch.name),
+ ]
+ if args.cache_size:
+ cmd += ["--cache_size={}".format(args.cache_size)]
+
+ # Running the puffpatch operation
+ if subprocess.call(cmd) != 0:
+ raise Error(
+ "Puffin failed to do {} command: {}".format(
+ operation, cmd
+ )
+ )
+
+ if not filecmp.cmp(tgt, new_tgt.name):
+ raise Error(
+ "The generated file {} is not equivalent to the "
+ "original file {} after puffpatch "
+ "operation.".format(
+ new_tgt.name, tgt
+ )
+ )
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
diff --git a/src/brotli_util.cc b/src/brotli_util.cc
index ebe577e..a13ce5f 100644
--- a/src/brotli_util.cc
+++ b/src/brotli_util.cc
@@ -6,8 +6,8 @@
#include "brotli/decode.h"
#include "brotli/encode.h"
-#include "puffin/src/logging.h"
#include "puffin/memory_stream.h"
+#include "puffin/src/logging.h"
namespace puffin {
@@ -27,8 +27,7 @@ bool BrotliEncode(const uint8_t* input,
BrotliEncoderDestroyInstance);
TEST_AND_RETURN_FALSE(encoder != nullptr);
- BrotliEncoderSetParameter(encoder.get(), BROTLI_PARAM_QUALITY,
- quality);
+ BrotliEncoderSetParameter(encoder.get(), BROTLI_PARAM_QUALITY, quality);
BrotliEncoderSetParameter(encoder.get(), BROTLI_PARAM_LGWIN,
kDefaultParamLgwin);
diff --git a/src/brotli_util_unittest.cc b/src/brotli_util_unittest.cc
index 1ef310c..78c58c7 100644
--- a/src/brotli_util_unittest.cc
+++ b/src/brotli_util_unittest.cc
@@ -4,8 +4,8 @@
#include "gtest/gtest.h"
-#include "puffin/src/include/puffin/brotli_util.h"
#include "puffin/memory_stream.h"
+#include "puffin/src/include/puffin/brotli_util.h"
#include "puffin/src/puffin_stream.h"
namespace puffin {
diff --git a/src/fuzzer_puffpatch.cc b/src/fuzzer_puffpatch.cc
index 525be69..622d3b6 100644
--- a/src/fuzzer_puffpatch.cc
+++ b/src/fuzzer_puffpatch.cc
@@ -7,9 +7,9 @@
#include "base/logging.h"
#include "brillo/test_helpers.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/include/puffin/common.h"
#include "puffin/src/include/puffin/puffpatch.h"
-#include "puffin/memory_stream.h"
using puffin::BitExtent;
using puffin::Buffer;
diff --git a/src/integration_test.cc b/src/integration_test.cc
index cbe0fb7..623b222 100644
--- a/src/integration_test.cc
+++ b/src/integration_test.cc
@@ -7,10 +7,10 @@
#include "gtest/gtest.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/include/puffin/puffdiff.h"
#include "puffin/src/include/puffin/puffpatch.h"
#include "puffin/src/include/puffin/utils.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/puffin_stream.h"
#include "puffin/src/unittest_common.h"
diff --git a/src/main.cc b/src/main.cc
index 79ee1ca..bad092a 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -14,6 +14,7 @@
#endif
#include "puffin/file_stream.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/extent_stream.h"
#include "puffin/src/include/puffin/common.h"
#include "puffin/src/include/puffin/huffer.h"
@@ -22,7 +23,6 @@
#include "puffin/src/include/puffin/puffpatch.h"
#include "puffin/src/include/puffin/utils.h"
#include "puffin/src/logging.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/puffin_stream.h"
using puffin::BitExtent;
diff --git a/src/patching_unittest.cc b/src/patching_unittest.cc
index 6e69d79..8ad7a94 100644
--- a/src/patching_unittest.cc
+++ b/src/patching_unittest.cc
@@ -7,12 +7,12 @@
#include "gtest/gtest.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/include/puffin/common.h"
#include "puffin/src/include/puffin/puffdiff.h"
#include "puffin/src/include/puffin/puffpatch.h"
#include "puffin/src/include/puffin/utils.h"
#include "puffin/src/logging.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/puffin_stream.h"
#include "puffin/src/unittest_common.h"
diff --git a/src/puffdiff.cc b/src/puffdiff.cc
index f813c43..4f1470b 100644
--- a/src/puffdiff.cc
+++ b/src/puffdiff.cc
@@ -18,13 +18,13 @@
#include "zucchini/zucchini.h"
#include "puffin/file_stream.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/include/puffin/brotli_util.h"
#include "puffin/src/include/puffin/common.h"
#include "puffin/src/include/puffin/puffer.h"
#include "puffin/src/include/puffin/puffpatch.h"
#include "puffin/src/include/puffin/utils.h"
#include "puffin/src/logging.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/puffin.pb.h"
#include "puffin/src/puffin_stream.h"
diff --git a/src/puffin_unittest.cc b/src/puffin_unittest.cc
index bd5cb79..bdca1f2 100644
--- a/src/puffin_unittest.cc
+++ b/src/puffin_unittest.cc
@@ -8,6 +8,7 @@
#include "gtest/gtest.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/bit_reader.h"
#include "puffin/src/bit_writer.h"
#include "puffin/src/include/puffin/common.h"
@@ -15,7 +16,6 @@
#include "puffin/src/include/puffin/puffer.h"
#include "puffin/src/include/puffin/utils.h"
#include "puffin/src/logging.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/puff_reader.h"
#include "puffin/src/puff_writer.h"
#include "puffin/src/puffin_stream.h"
diff --git a/src/puffpatch.cc b/src/puffpatch.cc
index d41ecd1..c6eb844 100644
--- a/src/puffpatch.cc
+++ b/src/puffpatch.cc
@@ -17,13 +17,13 @@
#include "zucchini/patch_reader.h"
#include "zucchini/zucchini.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/include/puffin/brotli_util.h"
#include "puffin/src/include/puffin/common.h"
#include "puffin/src/include/puffin/huffer.h"
#include "puffin/src/include/puffin/puffer.h"
#include "puffin/src/include/puffin/stream.h"
#include "puffin/src/logging.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/puffin.pb.h"
#include "puffin/src/puffin_stream.h"
diff --git a/src/stream_unittest.cc b/src/stream_unittest.cc
index 279ca8e..0308b53 100644
--- a/src/stream_unittest.cc
+++ b/src/stream_unittest.cc
@@ -7,10 +7,10 @@
#include "gtest/gtest.h"
#include "puffin/file_stream.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/extent_stream.h"
#include "puffin/src/include/puffin/huffer.h"
#include "puffin/src/include/puffin/puffer.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/puffin_stream.h"
#include "puffin/src/unittest_common.h"
diff --git a/src/utils.cc b/src/utils.cc
index fd1feab..232b4dc 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -13,11 +13,11 @@
#include <vector>
#include "puffin/file_stream.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/bit_reader.h"
#include "puffin/src/include/puffin/common.h"
#include "puffin/src/include/puffin/puffer.h"
#include "puffin/src/logging.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/puff_writer.h"
using std::set;
diff --git a/src/utils_unittest.cc b/src/utils_unittest.cc
index 73be63d..5dd8378 100644
--- a/src/utils_unittest.cc
+++ b/src/utils_unittest.cc
@@ -9,9 +9,9 @@
#include "gtest/gtest.h"
#include "puffin/file_stream.h"
+#include "puffin/memory_stream.h"
#include "puffin/src/include/puffin/common.h"
#include "puffin/src/include/puffin/utils.h"
-#include "puffin/memory_stream.h"
#include "puffin/src/unittest_common.h"
using std::string;