AU: Remove support for old-style updates.
This code is basically untested, unused and a security risk. So, remove...
BUG=chromium-os:12542
TEST=unit tests, tested VM update
Change-Id: Ibed0582b09497acef9debdf88658cddc2b5cecce
Reviewed-on: http://gerrit.chromium.org/gerrit/8728
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/SConstruct b/SConstruct
index 5037fa9..22d3d45 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1,4 +1,4 @@
-# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Copyright (c) 2011 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.
@@ -208,8 +208,7 @@
pthread
rootdev
ssl
- xml2
- z""")
+ xml2""")
env['CPPPATH'] = ['..']
env['BUILDERS']['ProtocolBuffer'] = proto_builder
env['BUILDERS']['DbusBindings'] = dbus_bindings_builder
@@ -238,7 +237,6 @@
env['LIBS'] += ['bz2', 'gcov']
sources = Split("""action_processor.cc
- buffered_file_writer.cc
bzip.cc
bzip_extent_writer.cc
certificate_checker.cc
@@ -246,7 +244,6 @@
chrome_proxy_resolver.cc
cycle_breaker.cc
dbus_service.cc
- decompressing_file_writer.cc
delta_diff_generator.cc
delta_performer.cc
download_action.cc
@@ -259,7 +256,6 @@
flimflam_proxy.cc
full_update_generator.cc
graph_utils.cc
- gzip.cc
http_fetcher.cc
libcurl_http_fetcher.cc
marshal.glibmarshal.c
@@ -274,7 +270,6 @@
prefs.cc
proxy_resolver.cc
simple_key_value_store.cc
- split_file_writer.cc
subprocess.cc
tarjan.cc
terminator.cc
@@ -288,13 +283,11 @@
unittest_sources = Split("""action_unittest.cc
action_pipe_unittest.cc
action_processor_unittest.cc
- buffered_file_writer_unittest.cc
bzip_extent_writer_unittest.cc
certificate_checker_unittest.cc
chrome_browser_proxy_resolver_unittest.cc
chrome_proxy_resolver_unittest.cc
cycle_breaker_unittest.cc
- decompressing_file_writer_unittest.cc
delta_diff_generator_unittest.cc
delta_performer_unittest.cc
download_action_unittest.cc
@@ -318,7 +311,6 @@
postinstall_runner_action_unittest.cc
prefs_unittest.cc
simple_key_value_store_unittest.cc
- split_file_writer_unittest.cc
subprocess_unittest.cc
tarjan_unittest.cc
terminator_unittest.cc
diff --git a/buffered_file_writer.cc b/buffered_file_writer.cc
deleted file mode 100644
index 03b8c77..0000000
--- a/buffered_file_writer.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) 2010 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 "update_engine/buffered_file_writer.h"
-
-namespace chromeos_update_engine {
-
-BufferedFileWriter::BufferedFileWriter(FileWriter* next, size_t buffer_size)
- : next_(next),
- buffer_(new char[buffer_size]),
- buffer_size_(buffer_size),
- buffered_bytes_(0) {}
-
-BufferedFileWriter::~BufferedFileWriter() {}
-
-int BufferedFileWriter::Open(const char* path, int flags, mode_t mode) {
- return next_->Open(path, flags, mode);
-}
-
-ssize_t BufferedFileWriter::Write(const void* bytes, size_t count) {
- size_t copied_bytes = 0;
- while (copied_bytes < count) {
- // Buffers as many bytes as possible.
- size_t remaining_free = buffer_size_ - buffered_bytes_;
- size_t copy_bytes = count - copied_bytes;
- if (copy_bytes > remaining_free) {
- copy_bytes = remaining_free;
- }
- const char* char_bytes = reinterpret_cast<const char*>(bytes);
- memcpy(&buffer_[buffered_bytes_], char_bytes + copied_bytes, copy_bytes);
- buffered_bytes_ += copy_bytes;
- copied_bytes += copy_bytes;
-
- // If full, sends the buffer to the next FileWriter.
- if (buffered_bytes_ == buffer_size_) {
- ssize_t rc = WriteBuffer();
- if (rc < 0)
- return rc;
- }
- }
- return count;
-}
-
-int BufferedFileWriter::Close() {
- // Flushes the buffer first, then closes the next FileWriter.
- ssize_t rc_write = WriteBuffer();
- int rc_close = next_->Close();
- return (rc_write < 0) ? rc_write : rc_close;
-}
-
-ssize_t BufferedFileWriter::WriteBuffer() {
- if (buffered_bytes_ == 0)
- return 0;
- ssize_t rc = next_->Write(&buffer_[0], buffered_bytes_);
- buffered_bytes_ = 0;
- return rc;
-}
-
-} // namespace chromeos_update_engine
diff --git a/buffered_file_writer.h b/buffered_file_writer.h
deleted file mode 100644
index a949c33..0000000
--- a/buffered_file_writer.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2010 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.
-
-#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
-#define CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
-
-#include <base/memory/scoped_ptr.h>
-#include <gtest/gtest_prod.h> // for FRIEND_TEST
-
-#include "update_engine/file_writer.h"
-
-// BufferedFileWriter is an implementation of FileWriter that buffers all data
-// before passing it onto another FileWriter.
-
-namespace chromeos_update_engine {
-
-class BufferedFileWriter : public FileWriter {
- public:
- BufferedFileWriter(FileWriter* next, size_t buffer_size);
- virtual ~BufferedFileWriter();
-
- virtual int Open(const char* path, int flags, mode_t mode);
- virtual ssize_t Write(const void* bytes, size_t count);
- virtual int Close();
-
- private:
- FRIEND_TEST(BufferedFileWriterTest, CloseErrorTest);
- FRIEND_TEST(BufferedFileWriterTest, CloseNoDataTest);
- FRIEND_TEST(BufferedFileWriterTest, CloseWriteErrorTest);
- FRIEND_TEST(BufferedFileWriterTest, ConstructorTest);
- FRIEND_TEST(BufferedFileWriterTest, WriteBufferNoDataTest);
- FRIEND_TEST(BufferedFileWriterTest, WriteBufferTest);
- FRIEND_TEST(BufferedFileWriterTest, WriteErrorTest);
- FRIEND_TEST(BufferedFileWriterTest, WriteTest);
- FRIEND_TEST(BufferedFileWriterTest, WriteWrapBufferTest);
-
- // If non-empty, sends the buffer to the next FileWriter.
- ssize_t WriteBuffer();
-
- // The FileWriter that we write all buffered data to.
- FileWriter* const next_;
-
- scoped_array<char> buffer_;
- size_t buffer_size_;
- size_t buffered_bytes_;
-
- DISALLOW_COPY_AND_ASSIGN(BufferedFileWriter);
-};
-
-} // namespace chromeos_update_engine
-
-#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_BUFFERED_FILE_WRITER_H__
diff --git a/buffered_file_writer_unittest.cc b/buffered_file_writer_unittest.cc
deleted file mode 100644
index 1c39a4e..0000000
--- a/buffered_file_writer_unittest.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (c) 2010 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 <gtest/gtest.h>
-
-#include "update_engine/buffered_file_writer.h"
-#include "update_engine/file_writer_mock.h"
-
-using std::string;
-using testing::_;
-using testing::InSequence;
-using testing::Return;
-
-namespace chromeos_update_engine {
-
-static const int kTestFlags = O_CREAT | O_LARGEFILE | O_TRUNC | O_WRONLY;
-static const mode_t kTestMode = 0644;
-
-MATCHER_P2(MemCmp, expected, n, "") { return memcmp(arg, expected, n) == 0; }
-
-class BufferedFileWriterTest : public ::testing::Test {
- protected:
- FileWriterMock file_writer_mock_;
-};
-
-TEST_F(BufferedFileWriterTest, CloseErrorTest) {
- BufferedFileWriter writer(&file_writer_mock_, 100);
- writer.buffered_bytes_ = 1;
- InSequence s;
- EXPECT_CALL(file_writer_mock_, Write(&writer.buffer_[0], 1))
- .Times(1)
- .WillOnce(Return(50));
- EXPECT_CALL(file_writer_mock_, Close()).Times(1).WillOnce(Return(-20));
- EXPECT_EQ(-20, writer.Close());
-}
-
-TEST_F(BufferedFileWriterTest, CloseNoDataTest) {
- BufferedFileWriter writer(&file_writer_mock_, 50);
- InSequence s;
- EXPECT_CALL(file_writer_mock_, Write(_, _)).Times(0);
- EXPECT_CALL(file_writer_mock_, Close()).Times(1).WillOnce(Return(-30));
- EXPECT_EQ(-30, writer.Close());
-}
-
-TEST_F(BufferedFileWriterTest, CloseWriteErrorTest) {
- BufferedFileWriter writer(&file_writer_mock_, 100);
- writer.buffered_bytes_ = 2;
- InSequence s;
- EXPECT_CALL(file_writer_mock_, Write(&writer.buffer_[0], 2))
- .Times(1)
- .WillOnce(Return(-10));
- EXPECT_CALL(file_writer_mock_, Close()).Times(1).WillOnce(Return(-20));
- EXPECT_EQ(-10, writer.Close());
-}
-
-TEST_F(BufferedFileWriterTest, ConstructorTest) {
- BufferedFileWriter writer(&file_writer_mock_, 123);
- EXPECT_EQ(&file_writer_mock_, writer.next_);
- EXPECT_EQ(123, writer.buffer_size_);
- EXPECT_TRUE(writer.buffer_ != NULL);
- EXPECT_EQ(0, writer.buffered_bytes_);
-}
-
-TEST_F(BufferedFileWriterTest, OpenTest) {
- BufferedFileWriter writer(&file_writer_mock_, 100);
- EXPECT_CALL(file_writer_mock_, Open("foo", kTestFlags, kTestMode))
- .Times(1)
- .WillOnce(Return(20));
- EXPECT_EQ(20, writer.Open("foo", kTestFlags, kTestMode));
-}
-
-TEST_F(BufferedFileWriterTest, WriteBufferNoDataTest) {
- BufferedFileWriter writer(&file_writer_mock_, 300);
- EXPECT_CALL(file_writer_mock_, Write(_, _)).Times(0);
- EXPECT_EQ(0, writer.WriteBuffer());
-}
-
-TEST_F(BufferedFileWriterTest, WriteBufferTest) {
- BufferedFileWriter writer(&file_writer_mock_, 200);
- writer.buffered_bytes_ = 100;
- EXPECT_CALL(file_writer_mock_, Write(&writer.buffer_[0], 100))
- .Times(1)
- .WillOnce(Return(-10));
- EXPECT_EQ(-10, writer.WriteBuffer());
-}
-
-TEST_F(BufferedFileWriterTest, WriteErrorTest) {
- string kData = "test_data";
- BufferedFileWriter writer(&file_writer_mock_, 4);
- InSequence s;
- EXPECT_CALL(file_writer_mock_, Write(MemCmp("test", 4), 4))
- .Times(1)
- .WillOnce(Return(3));
- EXPECT_CALL(file_writer_mock_, Write(MemCmp("_dat", 4), 4))
- .Times(1)
- .WillOnce(Return(-10));
- EXPECT_EQ(-10, writer.Write(kData.data(), kData.size()));
- EXPECT_EQ(0, writer.buffered_bytes_);
-}
-
-TEST_F(BufferedFileWriterTest, WriteTest) {
- string kData = "test_data";
- BufferedFileWriter writer(&file_writer_mock_, 100);
- writer.buffered_bytes_ = 10;
- EXPECT_CALL(file_writer_mock_, Write(_, _)).Times(0);
- EXPECT_EQ(kData.size(), writer.Write(kData.data(), kData.size()));
- EXPECT_EQ(0, memcmp(kData.data(), &writer.buffer_[10], kData.size()));
- EXPECT_EQ(kData.size() + 10, writer.buffered_bytes_);
-}
-
-TEST_F(BufferedFileWriterTest, WriteWrapBufferTest) {
- string kData = "test_data1";
- BufferedFileWriter writer(&file_writer_mock_, 3);
- writer.buffered_bytes_ = 1;
- writer.buffer_[0] = 'x';
- InSequence s;
- EXPECT_CALL(file_writer_mock_, Write(MemCmp("xte", 3), 3))
- .Times(1)
- .WillOnce(Return(3));
- EXPECT_CALL(file_writer_mock_, Write(MemCmp("st_", 3), 3))
- .Times(1)
- .WillOnce(Return(3));
- EXPECT_CALL(file_writer_mock_, Write(MemCmp("dat", 3), 3))
- .Times(1)
- .WillOnce(Return(3));
- EXPECT_EQ(kData.size(), writer.Write(kData.data(), kData.size()));
- EXPECT_EQ(0, memcmp("a1", &writer.buffer_[0], 2));
- EXPECT_EQ(2, writer.buffered_bytes_);
-}
-
-} // namespace chromeos_update_engine
diff --git a/decompressing_file_writer.cc b/decompressing_file_writer.cc
deleted file mode 100644
index 0a3280d..0000000
--- a/decompressing_file_writer.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2009 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 "update_engine/decompressing_file_writer.h"
-
-namespace chromeos_update_engine {
-
-// typedef struct z_stream_s {
-// Bytef *next_in; /* next input byte */
-// uInt avail_in; /* number of bytes available at next_in */
-// uLong total_in; /* total nb of input bytes read so far */
-//
-// Bytef *next_out; /* next output byte should be put there */
-// uInt avail_out; /* remaining free space at next_out */
-// uLong total_out; /* total nb of bytes output so far */
-//
-// char *msg; /* last error message, NULL if no error */
-// struct internal_state FAR *state; /* not visible by applications */
-//
-// alloc_func zalloc; /* used to allocate the internal state */
-// free_func zfree; /* used to free the internal state */
-// voidpf opaque; /* private data object passed to zalloc and zfree */
-//
-// int data_type; /* best guess about the data type: binary or text */
-// uLong adler; /* adler32 value of the uncompressed data */
-// uLong reserved; /* reserved for future use */
-// } z_stream;
-
-ssize_t GzipDecompressingFileWriter::Write(const void* bytes, size_t count) {
- // Steps:
- // put the data on next_in
- // call inflate until it returns nothing, each time writing what we get
- // check that next_in has no data left.
-
- // It seems that zlib can keep internal buffers in the stream object,
- // so not all data we get fed to us this time will necessarily
- // be written out this time (in decompressed form).
-
- if (stream_.avail_in) {
- LOG(ERROR) << "Have data already. Bailing";
- return -1;
- }
- char buf[1024];
-
- buffer_.reserve(count);
- buffer_.clear();
- CHECK_GE(buffer_.capacity(), count);
- const char* char_bytes = reinterpret_cast<const char*>(bytes);
- buffer_.insert(buffer_.end(), char_bytes, char_bytes + count);
-
- stream_.next_in = reinterpret_cast<Bytef*>(&buffer_[0]);
- stream_.avail_in = count;
- int retcode = Z_OK;
-
- while (Z_OK == retcode) {
- stream_.next_out = reinterpret_cast<Bytef*>(buf);
- stream_.avail_out = sizeof(buf);
- int retcode = inflate(&stream_, Z_NO_FLUSH);
- // check for Z_STREAM_END, Z_OK, or Z_BUF_ERROR (which is non-fatal)
- if (Z_STREAM_END != retcode && Z_OK != retcode && Z_BUF_ERROR != retcode) {
- LOG(ERROR) << "zlib inflate() error:" << retcode;
- if (stream_.msg)
- LOG(ERROR) << "message:" << stream_.msg;
- return 0;
- }
- int count_received = sizeof(buf) - stream_.avail_out;
- if (count_received > 0) {
- next_->Write(buf, count_received);
- } else {
- // Inflate returned no data; we're done for now. Make sure no
- // input data remain.
- CHECK_EQ(0, stream_.avail_in);
- break;
- }
- }
- return count;
-}
-
-} // namespace chromeos_update_engine
diff --git a/decompressing_file_writer.h b/decompressing_file_writer.h
deleted file mode 100644
index cd8e294..0000000
--- a/decompressing_file_writer.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) 2009 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.
-
-#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__
-#define CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__
-
-#include <zlib.h>
-#include "base/basictypes.h"
-#include "update_engine/file_writer.h"
-
-// GzipDecompressingFileWriter is an implementation of FileWriter. It will
-// gzip decompress all data that is passed via Write() onto another FileWriter,
-// which is responsible for actually writing the data out. Calls to
-// Open and Close are passed through to the other FileWriter.
-
-namespace chromeos_update_engine {
-
-class GzipDecompressingFileWriter : public FileWriter {
- public:
- explicit GzipDecompressingFileWriter(FileWriter* next) : next_(next) {
- memset(&stream_, 0, sizeof(stream_));
- CHECK_EQ(inflateInit2(&stream_, 16 + MAX_WBITS), Z_OK);
- }
- virtual ~GzipDecompressingFileWriter() {
- inflateEnd(&stream_);
- }
-
- virtual int Open(const char* path, int flags, mode_t mode) {
- return next_->Open(path, flags, mode);
- }
-
- // Write() calls into zlib to decompress the bytes passed in. It will not
- // necessarily write all the decompressed data associated with this set of
- // passed-in compressed data during this call, however for a valid gzip
- // stream, after the entire stream has been written to this object,
- // the entire decompressed stream will have been written to the
- // underlying FileWriter.
- virtual ssize_t Write(const void* bytes, size_t count);
-
- virtual int Close() {
- return next_->Close();
- }
- private:
- // The FileWriter that we write all uncompressed data to
- FileWriter* next_;
-
- // The zlib state
- z_stream stream_;
-
- // This is for an optimization in Write(). We can keep this buffer around
- // in our class to avoid repeated calls to malloc().
- std::vector<char> buffer_;
-
- DISALLOW_COPY_AND_ASSIGN(GzipDecompressingFileWriter);
-};
-
-} // namespace chromeos_update_engine
-
-#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DECOMPRESSING_FILE_WRITER_H__
diff --git a/decompressing_file_writer_unittest.cc b/decompressing_file_writer_unittest.cc
deleted file mode 100644
index c1666db..0000000
--- a/decompressing_file_writer_unittest.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2009 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 <string.h>
-#include <unistd.h>
-#include <string>
-#include <vector>
-#include <gtest/gtest.h>
-#include "update_engine/decompressing_file_writer.h"
-#include "update_engine/mock_file_writer.h"
-#include "update_engine/test_utils.h"
-
-using std::string;
-using std::vector;
-
-namespace chromeos_update_engine {
-
-class GzipDecompressingFileWriterTest : public ::testing::Test { };
-
-TEST(GzipDecompressingFileWriterTest, SimpleTest) {
- MockFileWriter mock_file_writer;
- GzipDecompressingFileWriter decompressing_file_writer(&mock_file_writer);
-
- // Here is the shell magic to include binary file in C source:
- // hexdump -v -e '" " 12/1 "0x%02x, " "\n"' $FILENAME
- // | sed -e '$s/0x ,//g' -e 's/^/ /g' | awk
- // 'BEGIN { print "unsigned char file[] = {" } END { print "};" } { print }'
-
- // uncompressed, contains just 3 bytes: "hi\n"
- unsigned char hi_txt_gz[] = {
- 0x1f, 0x8b, 0x08, 0x08, 0x62, 0xf5, 0x8a, 0x4a,
- 0x02, 0x03, 0x68, 0x69, 0x2e, 0x74, 0x78, 0x74,
- 0x00, 0xcb, 0xc8, 0xe4, 0x02, 0x00, 0x7a, 0x7a,
- 0x6f, 0xed, 0x03, 0x00, 0x00, 0x00,
- };
- char hi[] = "hi\n";
- vector<char> hi_vector(hi, hi + strlen(hi));
-
- const string path("unused");
- ASSERT_EQ(0, decompressing_file_writer.Open(
- path.c_str(), O_CREAT | O_LARGEFILE | O_TRUNC | O_WRONLY, 0644));
- ASSERT_EQ(sizeof(hi_txt_gz),
- decompressing_file_writer.Write(hi_txt_gz, sizeof(hi_txt_gz)));
- ASSERT_EQ(hi_vector.size(), mock_file_writer.bytes().size());
- for (unsigned int i = 0; i < hi_vector.size(); i++) {
- EXPECT_EQ(hi_vector[i], mock_file_writer.bytes()[i]) << "i = " << i;
- }
-}
-
-TEST(GzipDecompressingFileWriterTest, IllegalStreamTest) {
- MockFileWriter mock_file_writer;
- GzipDecompressingFileWriter decompressing_file_writer(&mock_file_writer);
-
- const string path("unused");
- ASSERT_EQ(0, decompressing_file_writer.Open(
- path.c_str(), O_CREAT | O_LARGEFILE | O_TRUNC | O_WRONLY, 0644));
- EXPECT_EQ(0, decompressing_file_writer.Write("\0\0\0\0\0\0\0\0", 8));
- EXPECT_EQ(0, mock_file_writer.bytes().size());
-}
-
-TEST(GzipDecompressingFileWriterTest, LargeTest) {
- const string kPath("/tmp/GzipDecompressingFileWriterTest");
- const string kPathgz(kPath + ".gz");
- // First, generate some data, say 10 megs:
- DirectFileWriter uncompressed_file;
- const char* k10bytes = "0123456789";
- const unsigned int k10bytesSize = 10;
- const unsigned int kUncompressedFileSize = strlen(k10bytes) * 1024 * 1024;
- uncompressed_file.Open(kPath.c_str(),
- O_CREAT | O_LARGEFILE | O_TRUNC | O_WRONLY, 0644);
- for (unsigned int i = 0; i < kUncompressedFileSize / k10bytesSize; i++) {
- ASSERT_EQ(k10bytesSize, uncompressed_file.Write("0123456789", 10));
- }
- uncompressed_file.Close();
-
- // compress the file
- EXPECT_EQ(0,
- system((string("cat ") + kPath + " | gzip > " + kPathgz).c_str()));
-
- // Now read the compressed file and put it into a DecompressingFileWriter
- MockFileWriter mock_file_writer;
- GzipDecompressingFileWriter decompressing_file_writer(&mock_file_writer);
-
- const string path("unused");
- ASSERT_EQ(0, decompressing_file_writer.Open(
- path.c_str(), O_CREAT | O_LARGEFILE | O_TRUNC | O_WRONLY, 0644));
-
- // Open compressed file for reading:
- int fd_in = open(kPathgz.c_str(), O_LARGEFILE | O_RDONLY, 0);
- ASSERT_GE(fd_in, 0);
- char buf[100];
- int sz;
- while ((sz = read(fd_in, buf, sizeof(buf))) > 0) {
- decompressing_file_writer.Write(buf, sz);
- }
- close(fd_in);
- decompressing_file_writer.Close();
-
- ASSERT_EQ(kUncompressedFileSize, mock_file_writer.bytes().size());
- for (unsigned int i = 0; i < kUncompressedFileSize; i++) {
- ASSERT_EQ(mock_file_writer.bytes()[i], '0' + (i % 10)) << "i = " << i;
- }
- unlink(kPath.c_str());
- unlink(kPathgz.c_str());
-}
-
-} // namespace chromeos_update_engine
diff --git a/delta_performer.cc b/delta_performer.cc
index fa35ce8..0e49df7 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -606,11 +606,11 @@
const string& download_hash_data = hash_calculator_.hash();
TEST_AND_RETURN_VAL(kActionCodeDownloadPayloadVerificationError,
!download_hash_data.empty());
- TEST_AND_RETURN_VAL(kActionCodeDownloadPayloadVerificationError,
+ TEST_AND_RETURN_VAL(kActionCodeDownloadHashMismatchError,
download_hash_data == update_check_response_hash);
// Verifies the download size.
- TEST_AND_RETURN_VAL(kActionCodeDownloadPayloadVerificationError,
+ TEST_AND_RETURN_VAL(kActionCodeDownloadSizeMismatchError,
update_check_response_size ==
manifest_metadata_size_ + buffer_offset_);
diff --git a/download_action.cc b/download_action.cc
index 9da925c..989625d 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -44,31 +44,10 @@
if (writer_) {
LOG(INFO) << "Using writer for test.";
} else {
- if (install_plan_.is_full_update) {
- kernel_file_writer_.reset(new DirectFileWriter);
- rootfs_file_writer_.reset(new DirectFileWriter);
- kernel_buffered_file_writer_.reset(
- new BufferedFileWriter(kernel_file_writer_.get(),
- kFileWriterBufferSize));
- rootfs_buffered_file_writer_.reset(
- new BufferedFileWriter(rootfs_file_writer_.get(),
- kFileWriterBufferSize));
- split_file_writer_.reset(
- new SplitFileWriter(kernel_buffered_file_writer_.get(),
- rootfs_buffered_file_writer_.get()));
- split_file_writer_->SetFirstOpenArgs(
- install_plan_.kernel_install_path.c_str(),
- O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE,
- 0644);
- decompressing_file_writer_.reset(
- new GzipDecompressingFileWriter(split_file_writer_.get()));
- writer_ = decompressing_file_writer_.get();
- } else {
- delta_performer_.reset(new DeltaPerformer(prefs_));
- delta_performer_->set_current_kernel_hash(install_plan_.kernel_hash);
- delta_performer_->set_current_rootfs_hash(install_plan_.rootfs_hash);
- writer_ = delta_performer_.get();
- }
+ delta_performer_.reset(new DeltaPerformer(prefs_));
+ delta_performer_->set_current_kernel_hash(install_plan_.kernel_hash);
+ delta_performer_->set_current_rootfs_hash(install_plan_.rootfs_hash);
+ writer_ = delta_performer_.get();
}
int rc = writer_->Open(install_plan_.install_path.c_str(),
O_TRUNC | O_WRONLY | O_CREAT | O_LARGEFILE,
@@ -79,15 +58,14 @@
processor_->ActionComplete(this, kActionCodeInstallDeviceOpenError);
return;
}
- if (!install_plan_.is_full_update) {
- if (!delta_performer_->OpenKernel(
- install_plan_.kernel_install_path.c_str())) {
- LOG(ERROR) << "Unable to open kernel file "
- << install_plan_.kernel_install_path.c_str();
- writer_->Close();
- processor_->ActionComplete(this, kActionCodeKernelDeviceOpenError);
- return;
- }
+ if (delta_performer_.get() &&
+ !delta_performer_->OpenKernel(
+ install_plan_.kernel_install_path.c_str())) {
+ LOG(ERROR) << "Unable to open kernel file "
+ << install_plan_.kernel_install_path.c_str();
+ writer_->Close();
+ processor_->ActionComplete(this, kActionCodeKernelDeviceOpenError);
+ return;
}
if (delegate_) {
delegate_->SetDownloadStatus(true); // Set to active.
@@ -127,10 +105,6 @@
TerminateProcessing();
return;
}
- // DeltaPerformer checks the hashes for delta updates.
- if (install_plan_.is_full_update) {
- omaha_hash_calculator_.Update(bytes, length);
- }
}
namespace {
@@ -159,36 +133,20 @@
}
ActionExitCode code =
successful ? kActionCodeSuccess : kActionCodeDownloadTransferError;
- if (code == kActionCodeSuccess) {
- if (!install_plan_.is_full_update) {
- code = delta_performer_->VerifyPayload("",
- install_plan_.download_hash,
- install_plan_.size);
- if (code != kActionCodeSuccess) {
- LOG(ERROR) << "Download of " << install_plan_.download_url
- << " failed due to payload verification error.";
- } else if (!delta_performer_->GetNewPartitionInfo(
- &install_plan_.kernel_size,
- &install_plan_.kernel_hash,
- &install_plan_.rootfs_size,
- &install_plan_.rootfs_hash)) {
- LOG(ERROR) << "Unable to get new partition hash info.";
- code = kActionCodeDownloadNewPartitionInfoError;
- }
- } else {
- // Makes sure the hash and size are correct for an old-style full update.
- omaha_hash_calculator_.Finalize();
- if (omaha_hash_calculator_.hash() != install_plan_.download_hash) {
- LOG(ERROR) << "Download of " << install_plan_.download_url
- << " failed. Expected hash " << install_plan_.download_hash
- << " but got hash " << omaha_hash_calculator_.hash();
- code = kActionCodeDownloadHashMismatchError;
- } else if (bytes_received_ != install_plan_.size) {
- LOG(ERROR) << "Download of " << install_plan_.download_url
- << " failed. Expected size " << install_plan_.size
- << " but got size " << bytes_received_;
- code = kActionCodeDownloadSizeMismatchError;
- }
+ if (code == kActionCodeSuccess && delta_performer_.get()) {
+ code = delta_performer_->VerifyPayload("",
+ install_plan_.download_hash,
+ install_plan_.size);
+ if (code != kActionCodeSuccess) {
+ LOG(ERROR) << "Download of " << install_plan_.download_url
+ << " failed due to payload verification error.";
+ } else if (!delta_performer_->GetNewPartitionInfo(
+ &install_plan_.kernel_size,
+ &install_plan_.kernel_hash,
+ &install_plan_.rootfs_size,
+ &install_plan_.rootfs_hash)) {
+ LOG(ERROR) << "Unable to get new partition hash info.";
+ code = kActionCodeDownloadNewPartitionInfoError;
}
}
diff --git a/download_action.h b/download_action.h
index 373e6fe..e743b41 100644
--- a/download_action.h
+++ b/download_action.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -16,20 +16,12 @@
#include <google/protobuf/stubs/common.h>
#include "update_engine/action.h"
-#include "update_engine/decompressing_file_writer.h"
#include "update_engine/delta_performer.h"
-#include "update_engine/buffered_file_writer.h"
#include "update_engine/http_fetcher.h"
#include "update_engine/install_plan.h"
-#include "update_engine/omaha_hash_calculator.h"
-#include "update_engine/split_file_writer.h"
-// The Download Action downloads a specified url to disk. The url should
-// point to either a full or delta update. If a full update, the file will
-// be piped into a SplitFileWriter, which will direct it to the kernel
-// and rootfs partitions. If it's a delta update, the destination kernel
-// and rootfs should already contain the source-version that this delta
-// update goes from. In this case, the update will be piped into a
+// The Download Action downloads a specified url to disk. The url should point
+// to an update in a delta payload format. The payload will be piped into a
// DeltaPerformer that will apply the delta to the disk.
namespace chromeos_update_engine {
@@ -109,23 +101,11 @@
// either point to *decompressing_file_writer_ or *delta_performer_.
FileWriter* writer_;
- // These are used for full updates:
- scoped_ptr<GzipDecompressingFileWriter> decompressing_file_writer_;
- scoped_ptr<SplitFileWriter> split_file_writer_;
- scoped_ptr<DirectFileWriter> kernel_file_writer_;
- scoped_ptr<DirectFileWriter> rootfs_file_writer_;
- scoped_ptr<BufferedFileWriter> kernel_buffered_file_writer_;
- scoped_ptr<BufferedFileWriter> rootfs_buffered_file_writer_;
-
- // Used to apply a delta update:
scoped_ptr<DeltaPerformer> delta_performer_;
// Pointer to the HttpFetcher that does the http work.
scoped_ptr<HttpFetcher> http_fetcher_;
- // Used to find the hash of the bytes downloaded
- OmahaHashCalculator omaha_hash_calculator_;
-
// Used by TransferTerminated to figure if this action terminated itself or
// was terminated by the action processor.
ActionExitCode code_;
diff --git a/download_action_unittest.cc b/download_action_unittest.cc
index 16c2507..bf12326 100644
--- a/download_action_unittest.cc
+++ b/download_action_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -116,8 +116,6 @@
}
void TestWithData(const vector<char>& data,
- bool hash_test,
- bool size_test,
int fail_write,
bool use_download_delegate) {
GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
@@ -129,12 +127,10 @@
// We pull off the first byte from data and seek past it.
- string hash = hash_test ?
- OmahaHashCalculator::OmahaHashOfString("random string") :
+ string hash =
OmahaHashCalculator::OmahaHashOfBytes(&data[1], data.size() - 1);
- uint64_t size = data.size() + (size_test ? 1 : 0);
- InstallPlan install_plan(true,
- false,
+ uint64_t size = data.size();
+ InstallPlan install_plan(false,
"",
size,
hash,
@@ -162,11 +158,7 @@
EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1);
}
ActionExitCode expected_code = kActionCodeSuccess;
- if (hash_test)
- expected_code = kActionCodeDownloadHashMismatchError;
- else if (size_test)
- expected_code = kActionCodeDownloadSizeMismatchError;
- else if (fail_write > 0)
+ if (fail_write > 0)
expected_code = kActionCodeDownloadWriteError;
DownloadActionTestProcessorDelegate delegate(expected_code);
delegate.loop_ = loop;
@@ -191,8 +183,6 @@
const char* foo = "foo";
small.insert(small.end(), foo, foo + strlen(foo));
TestWithData(small,
- false, // hash_test
- false, // size_test
0, // fail_write
true); // use_download_delegate
}
@@ -205,8 +195,6 @@
c = ('9' == c) ? '0' : c + 1;
}
TestWithData(big,
- false, // hash_test
- false, // size_test
0, // fail_write
true); // use_download_delegate
}
@@ -219,40 +207,15 @@
c = ('9' == c) ? '0' : c + 1;
}
TestWithData(big,
- false, // hash_test
- false, // size_test
2, // fail_write
true); // use_download_delegate
}
-TEST(DownloadActionTest, BadHashTest) {
- vector<char> small;
- const char* foo = "foo";
- small.insert(small.end(), foo, foo + strlen(foo));
- TestWithData(small,
- true, // hash_test
- false, // size_test
- 0, // fail_write
- true); // use_download_delegate
-}
-
-TEST(DownloadActionTest, BadSizeTest) {
- const char* something = "something";
- vector<char> small(something, something + strlen(something));
- TestWithData(small,
- false, // hash_test
- true, // size_test
- 0, // fail_write
- true); // use_download_delegate
-}
-
TEST(DownloadActionTest, NoDownloadDelegateTest) {
vector<char> small;
const char* foo = "foofoo";
small.insert(small.end(), foo, foo + strlen(foo));
TestWithData(small,
- false, // hash_test
- false, // size_test
0, // fail_write
false); // use_download_delegate
}
@@ -287,7 +250,7 @@
// takes ownership of passed in HttpFetcher
ObjectFeederAction<InstallPlan> feeder_action;
- InstallPlan install_plan(true, false, "", 0, "", temp_file.GetPath(), "");
+ InstallPlan install_plan(false, "", 0, "", temp_file.GetPath(), "");
feeder_action.set_obj(install_plan);
PrefsMock prefs;
DownloadAction download_action(&prefs,
@@ -387,8 +350,7 @@
DirectFileWriter writer;
// takes ownership of passed in HttpFetcher
- InstallPlan install_plan(true,
- false,
+ InstallPlan install_plan(false,
"",
1,
OmahaHashCalculator::OmahaHashOfString("x"),
@@ -427,7 +389,7 @@
DirectFileWriter writer;
// takes ownership of passed in HttpFetcher
- InstallPlan install_plan(true, false, "", 0, "", path, "");
+ InstallPlan install_plan(false, "", 0, "", path, "");
ObjectFeederAction<InstallPlan> feeder_action;
feeder_action.set_obj(install_plan);
PrefsMock prefs;
diff --git a/filesystem_copier_action.cc b/filesystem_copier_action.cc
index 7da54a8..364922b 100644
--- a/filesystem_copier_action.cc
+++ b/filesystem_copier_action.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -69,12 +69,7 @@
return;
}
install_plan_ = GetInputObject();
-
- // Note that we do need to run hash verification for new-style full updates
- // but currently the |is_full_update| field is set to true only for old-style
- // full updates and we don't have any expected partition info in that case.
- if (install_plan_.is_full_update ||
- (!verify_hash_ && install_plan_.is_resume)) {
+ if (!verify_hash_ && install_plan_.is_resume) {
// No copy or hash verification needed. Done!
if (HasOutputPipe())
SetOutputObject(install_plan_);
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc
index 2ce3cc4..7926e22 100644
--- a/filesystem_copier_action_unittest.cc
+++ b/filesystem_copier_action_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -145,7 +145,6 @@
// Set up the action objects
InstallPlan install_plan;
- install_plan.is_full_update = false;
if (verify_hash) {
if (use_kernel_partition) {
install_plan.kernel_install_path = a_dev;
@@ -263,32 +262,6 @@
EXPECT_EQ(kActionCodeError, delegate.code_);
}
-TEST_F(FilesystemCopierActionTest, FullUpdateTest) {
- ActionProcessor processor;
- FilesystemCopierActionTest2Delegate delegate;
-
- processor.set_delegate(&delegate);
-
- ObjectFeederAction<InstallPlan> feeder_action;
- const char* kUrl = "http://some/url";
- InstallPlan install_plan(true, false, kUrl, 0, "", "", "");
- feeder_action.set_obj(install_plan);
- FilesystemCopierAction copier_action(false, false);
- ObjectCollectorAction<InstallPlan> collector_action;
-
- BondActions(&feeder_action, &copier_action);
- BondActions(&copier_action, &collector_action);
-
- processor.EnqueueAction(&feeder_action);
- processor.EnqueueAction(&copier_action);
- processor.EnqueueAction(&collector_action);
- processor.StartProcessing();
- EXPECT_FALSE(processor.IsRunning());
- EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kActionCodeSuccess, delegate.code_);
- EXPECT_EQ(kUrl, collector_action.object().download_url);
-}
-
TEST_F(FilesystemCopierActionTest, ResumeTest) {
ActionProcessor processor;
FilesystemCopierActionTest2Delegate delegate;
@@ -297,7 +270,7 @@
ObjectFeederAction<InstallPlan> feeder_action;
const char* kUrl = "http://some/url";
- InstallPlan install_plan(false, true, kUrl, 0, "", "", "");
+ InstallPlan install_plan(true, kUrl, 0, "", "", "");
feeder_action.set_obj(install_plan);
FilesystemCopierAction copier_action(false, false);
ObjectCollectorAction<InstallPlan> collector_action;
@@ -323,7 +296,6 @@
ObjectFeederAction<InstallPlan> feeder_action;
InstallPlan install_plan(false,
- false,
"",
0,
"",
diff --git a/gzip.cc b/gzip.cc
deleted file mode 100644
index 0850b3e..0000000
--- a/gzip.cc
+++ /dev/null
@@ -1,185 +0,0 @@
-// Copyright (c) 2009 The Chromium 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 "update_engine/gzip.h"
-#include <stdlib.h>
-#include <algorithm>
-#include <zlib.h>
-#include "base/logging.h"
-#include "update_engine/utils.h"
-
-using std::max;
-using std::string;
-using std::vector;
-
-namespace chromeos_update_engine {
-
-bool GzipDecompressData(const char* const in, const size_t in_size,
- char** out, size_t* out_size) {
- if (in_size == 0) {
- // malloc(0) may legally return NULL, so do malloc(1)
- *out = reinterpret_cast<char*>(malloc(1));
- *out_size = 0;
- return true;
- }
- TEST_AND_RETURN_FALSE(out);
- TEST_AND_RETURN_FALSE(out_size);
- z_stream stream;
- memset(&stream, 0, sizeof(stream));
- TEST_AND_RETURN_FALSE(inflateInit2(&stream, 16 + MAX_WBITS) == Z_OK);
-
- // guess that output will be roughly double the input size
- *out_size = in_size * 2;
- *out = reinterpret_cast<char*>(malloc(*out_size));
- TEST_AND_RETURN_FALSE(*out);
-
- // TODO(adlr): ensure that this const_cast is safe.
- stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(in));
- stream.avail_in = in_size;
- stream.next_out = reinterpret_cast<Bytef*>(*out);
- stream.avail_out = *out_size;
- for (;;) {
- int rc = inflate(&stream, Z_FINISH);
- switch (rc) {
- case Z_STREAM_END: {
- *out_size = reinterpret_cast<char*>(stream.next_out) - (*out);
- TEST_AND_RETURN_FALSE(inflateEnd(&stream) == Z_OK);
- return true;
- }
- case Z_OK: // fall through
- case Z_BUF_ERROR: {
- // allocate more space
- ptrdiff_t out_length =
- reinterpret_cast<char*>(stream.next_out) - (*out);
- *out_size *= 2;
- char* new_out = reinterpret_cast<char*>(realloc(*out, *out_size));
- if (!new_out) {
- free(*out);
- return false;
- }
- *out = new_out;
- stream.next_out = reinterpret_cast<Bytef*>((*out) + out_length);
- stream.avail_out = (*out_size) - out_length;
- break;
- }
- default:
- LOG(INFO) << "Unknown inflate() return value: " << rc;
- if (stream.msg)
- LOG(INFO) << " message: " << stream.msg;
- free(*out);
- return false;
- }
- }
-}
-
-bool GzipCompressData(const char* const in, const size_t in_size,
- char** out, size_t* out_size) {
- if (in_size == 0) {
- // malloc(0) may legally return NULL, so do malloc(1)
- *out = reinterpret_cast<char*>(malloc(1));
- *out_size = 0;
- return true;
- }
- TEST_AND_RETURN_FALSE(out);
- TEST_AND_RETURN_FALSE(out_size);
- z_stream stream;
- memset(&stream, 0, sizeof(stream));
- TEST_AND_RETURN_FALSE(deflateInit2(&stream,
- Z_BEST_COMPRESSION,
- Z_DEFLATED,
- 16 + MAX_WBITS,
- 9, // most memory used/best compression
- Z_DEFAULT_STRATEGY) == Z_OK);
-
- // guess that output will be roughly half the input size
- *out_size = max(static_cast<size_t>(1), in_size / 2);
- *out = reinterpret_cast<char*>(malloc(*out_size));
- TEST_AND_RETURN_FALSE(*out);
-
- // TODO(adlr): ensure that this const_cast is safe.
- stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(in));
- stream.avail_in = in_size;
- stream.next_out = reinterpret_cast<Bytef*>(*out);
- stream.avail_out = *out_size;
- for (;;) {
- int rc = deflate(&stream, Z_FINISH);
- switch (rc) {
- case Z_STREAM_END: {
- *out_size = reinterpret_cast<char*>(stream.next_out) - (*out);
- TEST_AND_RETURN_FALSE(deflateEnd(&stream) == Z_OK);
- return true;
- }
- case Z_OK: // fall through
- case Z_BUF_ERROR: {
- // allocate more space
- ptrdiff_t out_length =
- reinterpret_cast<char*>(stream.next_out) - (*out);
- *out_size *= 2;
- char* new_out = reinterpret_cast<char*>(realloc(*out, *out_size));
- if (!new_out) {
- free(*out);
- return false;
- }
- *out = new_out;
- stream.next_out = reinterpret_cast<Bytef*>((*out) + out_length);
- stream.avail_out = (*out_size) - out_length;
- break;
- }
- default:
- LOG(INFO) << "Unknown defalate() return value: " << rc;
- if (stream.msg)
- LOG(INFO) << " message: " << stream.msg;
- free(*out);
- return false;
- }
- }
-}
-
-bool GzipDecompress(const std::vector<char>& in, std::vector<char>* out) {
- TEST_AND_RETURN_FALSE(out);
- char* out_buf;
- size_t out_size;
- TEST_AND_RETURN_FALSE(GzipDecompressData(&in[0], in.size(),
- &out_buf, &out_size));
- out->insert(out->end(), out_buf, out_buf + out_size);
- free(out_buf);
- return true;
-}
-
-bool GzipCompress(const std::vector<char>& in, std::vector<char>* out) {
- TEST_AND_RETURN_FALSE(out);
- char* out_buf;
- size_t out_size;
- TEST_AND_RETURN_FALSE(GzipCompressData(&in[0], in.size(),
- &out_buf, &out_size));
- out->insert(out->end(), out_buf, out_buf + out_size);
- free(out_buf);
- return true;
-}
-
-bool GzipCompressString(const std::string& str,
- std::vector<char>* out) {
- TEST_AND_RETURN_FALSE(out);
- char* out_buf;
- size_t out_size;
- TEST_AND_RETURN_FALSE(GzipCompressData(str.data(), str.size(),
- &out_buf, &out_size));
- out->insert(out->end(), out_buf, out_buf + out_size);
- free(out_buf);
- return true;
-}
-
-bool GzipDecompressString(const std::string& str,
- std::vector<char>* out) {
- TEST_AND_RETURN_FALSE(out);
- char* out_buf;
- size_t out_size;
- TEST_AND_RETURN_FALSE(GzipDecompressData(str.data(), str.size(),
- &out_buf, &out_size));
- out->insert(out->end(), out_buf, out_buf + out_size);
- free(out_buf);
- return true;
-}
-
-} // namespace chromeos_update_engine
diff --git a/gzip.h b/gzip.h
deleted file mode 100644
index d1f4aff..0000000
--- a/gzip.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2009 The Chromium 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 <string>
-#include <vector>
-
-namespace chromeos_update_engine {
-
-// Gzip compresses or decompresses the input to the output.
-// Returns true on success. If true, *out will point to a malloc()ed
-// buffer, which must be free()d by the caller.
-bool GzipCompressData(const char* const in, const size_t in_size,
- char** out, size_t* out_size);
-bool GzipDecompressData(const char* const in, const size_t in_size,
- char** out, size_t* out_size);
-
-// Helper functions:
-bool GzipDecompress(const std::vector<char>& in, std::vector<char>* out);
-bool GzipCompress(const std::vector<char>& in, std::vector<char>* out);
-bool GzipCompressString(const std::string& str, std::vector<char>* out);
-bool GzipDecompressString(const std::string& str, std::vector<char>* out);
-
-} // namespace chromeos_update_engine {
diff --git a/install_plan.h b/install_plan.h
index 08472c8..2418aab 100644
--- a/install_plan.h
+++ b/install_plan.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -16,15 +16,13 @@
namespace chromeos_update_engine {
struct InstallPlan {
- InstallPlan(bool is_full,
- bool is_resume,
+ InstallPlan(bool is_resume,
const std::string& url,
uint64_t size,
const std::string& hash,
const std::string& install_path,
const std::string& kernel_install_path)
- : is_full_update(is_full),
- is_resume(is_resume),
+ : is_resume(is_resume),
download_url(url),
size(size),
download_hash(hash),
@@ -32,9 +30,8 @@
kernel_install_path(kernel_install_path),
kernel_size(0),
rootfs_size(0) {}
- InstallPlan() : is_full_update(false), is_resume(false), size(0) {}
+ InstallPlan() : is_resume(false), size(0) {}
- bool is_full_update;
bool is_resume;
std::string download_url; // url to download from
uint64_t size; // size of the download url's data
@@ -59,20 +56,18 @@
std::vector<char> rootfs_hash;
bool operator==(const InstallPlan& that) const {
- return (is_full_update == that.is_full_update) &&
- (is_resume == that.is_resume) &&
- (download_url == that.download_url) &&
- (size == that.size) &&
- (download_hash == that.download_hash) &&
- (install_path == that.install_path) &&
- (kernel_install_path == that.kernel_install_path);
+ return ((is_resume == that.is_resume) &&
+ (download_url == that.download_url) &&
+ (size == that.size) &&
+ (download_hash == that.download_hash) &&
+ (install_path == that.install_path) &&
+ (kernel_install_path == that.kernel_install_path));
}
bool operator!=(const InstallPlan& that) const {
return !((*this) == that);
}
void Dump() const {
LOG(INFO) << "InstallPlan: "
- << (is_full_update ? "full_update" : "delta_update")
<< (is_resume ? ", resume" : ", new_update")
<< ", url: " << download_url
<< ", size: " << size
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 8080b64..6311332 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -464,8 +464,6 @@
output_object.needs_admin =
XmlGetProperty(updatecheck_node, "needsadmin") == "true";
output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true";
- output_object.is_delta =
- XmlGetProperty(updatecheck_node, "IsDelta") == "true";
output_object.deadline = XmlGetProperty(updatecheck_node, "deadline");
SetOutputObject(output_object);
}
diff --git a/omaha_request_action.h b/omaha_request_action.h
index 2edc13c..b32a3af 100644
--- a/omaha_request_action.h
+++ b/omaha_request_action.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -50,7 +50,6 @@
off_t size;
bool needs_admin;
bool prompt;
- bool is_delta;
};
COMPILE_ASSERT(sizeof(off_t) == 8, off_t_not_64bit);
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 6f4df63..776e5e7 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -257,7 +257,6 @@
EXPECT_EQ("1.2.3.4", response.display_version);
EXPECT_EQ("http://code/base", response.codebase);
EXPECT_EQ("http://more/info", response.more_info_url);
- EXPECT_TRUE(response.is_delta);
EXPECT_EQ("HASH1234=", response.hash);
EXPECT_EQ(123, response.size);
EXPECT_FALSE(response.needs_admin);
@@ -381,6 +380,7 @@
"status=\"ok\"/><updatecheck "
"DisplayVersion=\"1.2.3.4\" "
"Prompt=\"false\" "
+ "IsDelta=\"true\" "
"codebase=\"http://code/base\" hash=\"foo\" "
"sha256=\"HASH1234=\" needsadmin=\"true\" "
"size=\"123\" "
@@ -394,7 +394,6 @@
EXPECT_EQ("1.2.3.4", response.display_version);
EXPECT_EQ("http://code/base", response.codebase);
EXPECT_EQ("", response.more_info_url);
- EXPECT_FALSE(response.is_delta);
EXPECT_EQ("HASH1234=", response.hash);
EXPECT_EQ(123, response.size);
EXPECT_TRUE(response.needs_admin);
diff --git a/omaha_response_handler_action.cc b/omaha_response_handler_action.cc
index 74e149f..c83b328 100644
--- a/omaha_response_handler_action.cc
+++ b/omaha_response_handler_action.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -53,13 +53,6 @@
install_plan_.kernel_install_path =
utils::BootKernelDevice(install_plan_.install_path);
- install_plan_.is_full_update = !response.is_delta;
- if (!response.is_delta && utils::FileExists(key_path_.c_str())) {
- // Can't sign old style full payloads but signature is required so bail out.
- completer.set_code(kActionCodeSignedDeltaPayloadExpectedError);
- return;
- }
-
TEST_AND_RETURN(HasOutputPipe());
if (HasOutputPipe())
SetOutputObject(install_plan_);
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index 4a60315..87fa1e8 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -23,7 +23,6 @@
// If out is non-NULL, it's set w/ the response from the action.
bool DoTest(const OmahaResponse& in,
const string& boot_dev,
- bool test_key,
InstallPlan* out);
};
@@ -59,7 +58,6 @@
bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in,
const string& boot_dev,
- bool test_key,
InstallPlan* out) {
ActionProcessor processor;
OmahaResponseHandlerActionProcessorDelegate delegate;
@@ -73,9 +71,6 @@
.WillOnce(Return(true));
}
OmahaResponseHandlerAction response_handler_action(&prefs);
- if (test_key) {
- response_handler_action.set_key_path("/dev/null");
- }
response_handler_action.set_boot_device(boot_dev);
BondActions(&feeder_action, &response_handler_action);
ObjectCollectorAction<InstallPlan> collector_action;
@@ -89,9 +84,7 @@
if (out)
*out = collector_action.object();
EXPECT_TRUE(delegate.code_set_);
- ActionExitCode expected_code = test_key ?
- kActionCodeSignedDeltaPayloadExpectedError : kActionCodeSuccess;
- return delegate.code_ == expected_code;
+ return delegate.code_ == kActionCodeSuccess;
}
TEST_F(OmahaResponseHandlerActionTest, SimpleTest) {
@@ -107,11 +100,9 @@
in.size = 12;
in.needs_admin = true;
in.prompt = false;
- in.is_delta = false;
in.deadline = "20101020";
InstallPlan install_plan;
- EXPECT_TRUE(DoTest(in, "/dev/sda3", false, &install_plan));
- EXPECT_TRUE(install_plan.is_full_update);
+ EXPECT_TRUE(DoTest(in, "/dev/sda3", &install_plan));
EXPECT_EQ(in.codebase, install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.download_hash);
EXPECT_EQ("/dev/sda5", install_plan.install_path);
@@ -136,10 +127,8 @@
in.size = 12;
in.needs_admin = true;
in.prompt = true;
- in.is_delta = true;
InstallPlan install_plan;
- EXPECT_TRUE(DoTest(in, "/dev/sda5", false, &install_plan));
- EXPECT_FALSE(install_plan.is_full_update);
+ EXPECT_TRUE(DoTest(in, "/dev/sda5", &install_plan));
EXPECT_EQ(in.codebase, install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.download_hash);
EXPECT_EQ("/dev/sda3", install_plan.install_path);
@@ -158,11 +147,9 @@
in.size = 12;
in.needs_admin = true;
in.prompt = true;
- in.is_delta = false;
in.deadline = "some-deadline";
InstallPlan install_plan;
- EXPECT_TRUE(DoTest(in, "/dev/sda3", false, &install_plan));
- EXPECT_TRUE(install_plan.is_full_update);
+ EXPECT_TRUE(DoTest(in, "/dev/sda3", &install_plan));
EXPECT_EQ(in.codebase, install_plan.download_url);
EXPECT_EQ(in.hash, install_plan.download_hash);
EXPECT_EQ("/dev/sda5", install_plan.install_path);
@@ -174,21 +161,11 @@
}
}
-TEST_F(OmahaResponseHandlerActionTest, PublicKeyOldStyleTest) {
- OmahaResponse in;
- in.update_exists = true;
- in.codebase = "http://foo/the_update_a.b.c.d.tgz";
- in.is_delta = false;
- InstallPlan install_plan;
- EXPECT_TRUE(DoTest(in, "/dev/sda3", true, &install_plan));
-}
-
TEST_F(OmahaResponseHandlerActionTest, NoUpdatesTest) {
OmahaResponse in;
in.update_exists = false;
InstallPlan install_plan;
- EXPECT_FALSE(DoTest(in, "/dev/sda1", false, &install_plan));
- EXPECT_FALSE(install_plan.is_full_update);
+ EXPECT_FALSE(DoTest(in, "/dev/sda1", &install_plan));
EXPECT_EQ("", install_plan.download_url);
EXPECT_EQ("", install_plan.download_hash);
EXPECT_EQ("", install_plan.install_path);
diff --git a/split_file_writer.cc b/split_file_writer.cc
deleted file mode 100644
index dd211c8..0000000
--- a/split_file_writer.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2010 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 "update_engine/split_file_writer.h"
-#include <algorithm>
-
-using std::min;
-
-namespace chromeos_update_engine {
-
-int SplitFileWriter::Open(const char* path, int flags, mode_t mode) {
- int first_result = first_file_writer_->Open(first_path_,
- first_flags_,
- first_mode_);
- if (first_result < 0) {
- LOG(ERROR) << "Error opening first file " << first_path_;
- return first_result;
- }
- int second_result = second_file_writer_->Open(path, flags, mode);
- if (second_result < 0) {
- LOG(ERROR) << "Error opening second file " << path;
- first_file_writer_->Close();
- return second_result;
- }
- return second_result;
-}
-
-namespace {
-ssize_t PerformWrite(FileWriter* writer, const void* bytes, size_t count) {
- int rc = writer->Write(bytes, count);
- if (rc < 0) {
- LOG(ERROR) << "Write failed to file.";
- return rc;
- }
- if (rc != static_cast<int>(count)) {
- LOG(ERROR) << "Not all bytes successfully written to file.";
- return -EIO;
- }
- return rc;
-}
-}
-
-ssize_t SplitFileWriter::Write(const void* bytes, size_t count) {
- const size_t original_count = count;
-
- // This first block is trying to read the first sizeof(uint64_t)
- // bytes, which are the number of bytes that should be written
- // to the first FileWriter.
- if (bytes_received_ < static_cast<off_t>(sizeof(uint64_t))) {
- // Write more to the initial buffer
- size_t bytes_to_copy = min(static_cast<off_t>(count),
- static_cast<off_t>(sizeof(first_length_buf_)) -
- bytes_received_);
- memcpy(&first_length_buf_[bytes_received_], bytes, bytes_to_copy);
- bytes_received_ += bytes_to_copy;
- count -= bytes_to_copy;
- bytes = static_cast<const void*>(
- static_cast<const char*>(bytes) + bytes_to_copy);
-
- // See if we have all we need
- if (bytes_received_ == sizeof(first_length_buf_)) {
- // Parse first number
- uint64_t big_endian_first_length;
- memcpy(&big_endian_first_length, first_length_buf_,
- sizeof(big_endian_first_length));
- first_length_ = be64toh(big_endian_first_length);
- }
- if (count == 0)
- return original_count;
- }
- CHECK_GE(bytes_received_, static_cast<off_t>(sizeof(uint64_t)));
-
- // This block of code is writing to the first FileWriter.
- if (bytes_received_ - static_cast<off_t>(sizeof(uint64_t)) < first_length_) {
- // Write to first FileWriter
- size_t bytes_to_write = min(
- first_length_ -
- (bytes_received_ - static_cast<off_t>(sizeof(uint64_t))),
- static_cast<off_t>(count));
-
- int rc = PerformWrite(first_file_writer_, bytes, bytes_to_write);
- if (rc != static_cast<int>(bytes_to_write))
- return rc;
-
- bytes_received_ += bytes_to_write;
- count -= bytes_to_write;
- bytes = static_cast<const void*>(
- static_cast<const char*>(bytes) + bytes_to_write);
- if (count == 0)
- return original_count;
- }
-
- CHECK_GE(static_cast<off_t>(bytes_received_),
- first_length_ + static_cast<off_t>(sizeof(uint64_t)));
- // Write to second FileWriter
- int rc = PerformWrite(second_file_writer_, bytes, count);
- if (rc != static_cast<int>(count))
- return rc;
- return original_count;
-}
-
-int SplitFileWriter::Close() {
- int first_result = first_file_writer_->Close();
- if (first_result < 0)
- LOG(ERROR) << "Error Close()ing first file.";
- int second_result = second_file_writer_->Close();
- if (second_result < 0)
- LOG(ERROR) << "Error Close()ing second file.";
- // Return error if either had returned error.
- return second_result < 0 ? second_result : first_result;
-}
-
-} // namespace chromeos_update_engine
diff --git a/split_file_writer.h b/split_file_writer.h
deleted file mode 100644
index 508cae0..0000000
--- a/split_file_writer.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2010 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.
-
-#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
-#define CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
-
-#include "update_engine/file_writer.h"
-
-// SplitFileWriter is an implementation of FileWriter suited to our
-// full autoupdate format. The first 8 bytes read are assumed to be a
-// big-endian number describing how many of the next following bytes
-// go to the first FileWriter. After that, the rest of the bytes all
-// go to the second FileWriter.
-
-namespace chromeos_update_engine {
-
-class SplitFileWriter : public FileWriter {
- public:
- SplitFileWriter(FileWriter* first_file_writer, FileWriter* second_file_writer)
- : first_file_writer_(first_file_writer),
- first_length_(0),
- first_path_(NULL),
- first_flags_(0),
- first_mode_(0),
- second_file_writer_(second_file_writer),
- bytes_received_(0) {}
-
- void SetFirstOpenArgs(const char* path, int flags, mode_t mode) {
- first_path_ = path;
- first_flags_ = flags;
- first_mode_ = mode;
- }
-
- // If both succeed, returns the return value from the second Open() call.
- // On error, both files will be left closed.
- virtual int Open(const char* path, int flags, mode_t mode);
-
- virtual ssize_t Write(const void* bytes, size_t count);
-
- virtual int Close();
-
- private:
- // Data for the first file writer.
- FileWriter* const first_file_writer_;
- off_t first_length_;
- const char* first_path_;
- int first_flags_;
- mode_t first_mode_;
-
- // The second file writer.
- FileWriter* const second_file_writer_;
-
- // Bytes written thus far.
- off_t bytes_received_;
- char first_length_buf_[sizeof(uint64_t)];
-
- DISALLOW_COPY_AND_ASSIGN(SplitFileWriter);
-};
-
-} // namespace chromeos_update_engine
-
-#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SPLIT_FILE_WRITER_H__
diff --git a/split_file_writer_unittest.cc b/split_file_writer_unittest.cc
deleted file mode 100644
index 5720e27..0000000
--- a/split_file_writer_unittest.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2010 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 <algorithm>
-#include <string>
-#include <vector>
-#include <gtest/gtest.h>
-#include "update_engine/split_file_writer.h"
-#include "update_engine/test_utils.h"
-#include "update_engine/utils.h"
-
-using std::min;
-using std::string;
-using std::vector;
-
-namespace chromeos_update_engine {
-
-class SplitFileWriterTest : public ::testing::Test {
- protected:
- void DoTest(size_t bytes_per_call);
-};
-
-void SplitFileWriterTest::DoTest(size_t bytes_per_call) {
- string first_file;
- EXPECT_TRUE(utils::MakeTempFile("/tmp/SplitFileWriterTestFirst.XXXXXX",
- &first_file,
- NULL));
- ScopedPathUnlinker first_file_unlinker(first_file);
- string second_file;
- EXPECT_TRUE(utils::MakeTempFile("/tmp/SplitFileWriterTestSecond.XXXXXX",
- &second_file,
- NULL));
- ScopedPathUnlinker second_file_unlinker(second_file);
-
- // Create joined data
- uint64_t first_bytes = 789;
- uint64_t second_bytes = 1000;
-
- vector<char> buf(sizeof(uint64_t) + first_bytes + second_bytes);
- uint64_t big_endian_first_bytes = htobe64(first_bytes);
-
- FillWithData(&buf);
- memcpy(&buf[0], &big_endian_first_bytes, sizeof(big_endian_first_bytes));
-
- // Create FileWriters
- DirectFileWriter first_file_writer;
- DirectFileWriter second_file_writer;
- SplitFileWriter split_file_writer(&first_file_writer, &second_file_writer);
-
- split_file_writer.SetFirstOpenArgs(
- first_file.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0644);
- EXPECT_GE(split_file_writer.Open(
- second_file.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0644), 0);
- ScopedFileWriterCloser closer(&split_file_writer);
-
- size_t bytes_written_total = 0;
- for (size_t i = 0; i < buf.size(); i += bytes_per_call) {
- size_t bytes_this_iteration = min(bytes_per_call,
- buf.size() - bytes_written_total);
- EXPECT_EQ(bytes_this_iteration,
- split_file_writer.Write(&buf[bytes_written_total],
- bytes_this_iteration));
- bytes_written_total += bytes_this_iteration;
- }
- EXPECT_EQ(buf.size(), bytes_written_total);
-
- vector<char> first_actual_data;
- vector<char> second_actual_data;
- EXPECT_TRUE(utils::ReadFile(first_file, &first_actual_data));
- EXPECT_TRUE(utils::ReadFile(second_file, &second_actual_data));
-
- EXPECT_EQ(first_bytes, first_actual_data.size());
- EXPECT_EQ(second_bytes, second_actual_data.size());
-
- vector<char> first_part_from_orig(&buf[sizeof(uint64_t)],
- &buf[sizeof(uint64_t) + first_bytes]);
- vector<char> second_part_from_orig(
- &buf[sizeof(uint64_t) + first_bytes],
- &buf[sizeof(uint64_t) + first_bytes + second_bytes]);
-
- EXPECT_TRUE(ExpectVectorsEq(first_part_from_orig, first_actual_data));
- EXPECT_TRUE(ExpectVectorsEq(second_part_from_orig, second_actual_data));
-}
-
-TEST_F(SplitFileWriterTest, SimpleTest) {
- DoTest(1024 * 1024 * 1024); // Something very big
-}
-
-TEST_F(SplitFileWriterTest, OneByteAtATimeTest) {
- DoTest(1);
-}
-
-TEST_F(SplitFileWriterTest, ThreeBytesAtATimeTest) {
- DoTest(3);
-}
-
-} // namespace chromeos_update_engine
diff --git a/update_attempter.cc b/update_attempter.cc
index 8953803..4eb2d87 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -116,7 +116,6 @@
last_checked_time_(0),
new_version_("0.0.0.0"),
new_size_(0),
- is_full_update_(false),
proxy_manual_checks_(0),
obeying_proxies_(true),
chrome_proxy_resolver_(dbus_iface),
@@ -395,11 +394,10 @@
}
}
if (code != kActionCodeSuccess) {
- // If this was a delta update attempt and the current state is at or past
- // the download phase, count the failure in case a switch to full update
- // becomes necessary. Ignore network transfer timeouts and failures.
+ // If the current state is at or past the download phase, count the failure
+ // in case a switch to full update becomes necessary. Ignore network
+ // transfer timeouts and failures.
if (status_ >= UPDATE_STATUS_DOWNLOADING &&
- !is_full_update_ &&
code != kActionCodeDownloadTransferError) {
MarkDeltaUpdateFailure();
}
@@ -419,7 +417,6 @@
// TODO(adlr): put version in InstallPlan
new_version_ = "0.0.0.0";
new_size_ = plan.size;
- is_full_update_ = plan.is_full_update;
SetupDownload();
SetupPriorityManagement();
SetStatusAndNotify(UPDATE_STATUS_UPDATE_AVAILABLE);
@@ -655,7 +652,6 @@
}
void UpdateAttempter::MarkDeltaUpdateFailure() {
- CHECK(!is_full_update_);
// Don't try to resume a failed delta update.
DeltaPerformer::ResetUpdateProgress(prefs_, false);
int64_t delta_failures;
diff --git a/update_attempter.h b/update_attempter.h
index 46dd41c..882893a 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -264,7 +264,6 @@
int64_t last_checked_time_;
std::string new_version_;
int64_t new_size_;
- bool is_full_update_;
// Device paramaters common to all Omaha requests.
OmahaRequestDeviceParams omaha_request_params_;
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index b0dccf8..6c5b5a2 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -56,7 +56,6 @@
EXPECT_EQ(0, attempter_.last_checked_time_);
EXPECT_EQ("0.0.0.0", attempter_.new_version_);
EXPECT_EQ(0, attempter_.new_size_);
- EXPECT_FALSE(attempter_.is_full_update_);
processor_ = new ActionProcessorMock();
attempter_.processor_.reset(processor_); // Transfers ownership.
attempter_.prefs_ = &prefs_;
@@ -185,7 +184,6 @@
}
TEST_F(UpdateAttempterTest, MarkDeltaUpdateFailureTest) {
- attempter_.is_full_update_ = false;
EXPECT_CALL(prefs_, GetInt64(kPrefsDeltaUpdateFailures, _))
.WillOnce(Return(false))
.WillOnce(DoAll(SetArgumentPointee<1>(-1), Return(true)))
diff --git a/zip_unittest.cc b/zip_unittest.cc
index 72bd7f3..c73d28d 100644
--- a/zip_unittest.cc
+++ b/zip_unittest.cc
@@ -1,14 +1,16 @@
-// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 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 <string.h>
#include <unistd.h>
+
#include <string>
#include <vector>
+
#include <gtest/gtest.h>
+
#include "update_engine/bzip.h"
-#include "update_engine/gzip.h"
#include "update_engine/test_utils.h"
#include "update_engine/utils.h"
@@ -30,29 +32,6 @@
std::vector<char>* out) const = 0;
};
-class GzipTest {};
-
-template <>
-class ZipTest<GzipTest> : public ::testing::Test {
- public:
- bool ZipDecompress(const std::vector<char>& in,
- std::vector<char>* out) const {
- return GzipDecompress(in, out);
- }
- bool ZipCompress(const std::vector<char>& in,
- std::vector<char>* out) const {
- return GzipCompress(in, out);
- }
- bool ZipCompressString(const std::string& str,
- std::vector<char>* out) const {
- return GzipCompressString(str, out);
- }
- bool ZipDecompressString(const std::string& str,
- std::vector<char>* out) const {
- return GzipDecompressString(str, out);
- }
-};
-
class BzipTest {};
template <>
@@ -76,8 +55,7 @@
}
};
-typedef ::testing::Types<GzipTest, BzipTest>
- ZipTestTypes;
+typedef ::testing::Types<BzipTest> ZipTestTypes;
TYPED_TEST_CASE(ZipTest, ZipTestTypes);