Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(953)

Unified Diff: delta_performer_unittest.cc

Issue 3550020: AU: support for generating new style full updates. (Closed) Base URL: ssh://git@chromiumos-git/update_engine.git
Patch Set: fixes for review Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « delta_diff_generator.cc ('k') | generate_delta_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: delta_performer_unittest.cc
diff --git a/delta_performer_unittest.cc b/delta_performer_unittest.cc
index 12de8a9a24e1784d2e2e6e5ad20dad154165116c..4a11c693b843183a7482ec92e59538acbf9b4598 100755
--- a/delta_performer_unittest.cc
+++ b/delta_performer_unittest.cc
@@ -34,6 +34,11 @@ using testing::Return;
extern const char* kUnittestPrivateKeyPath;
extern const char* kUnittestPublicKeyPath;
+namespace {
+ const size_t kBlockSize = 4096;
+} // namespace {}
+
+
class DeltaPerformerTest : public ::testing::Test { };
TEST(DeltaPerformerTest, ExtentsToByteStringTest) {
@@ -85,7 +90,6 @@ void CompareFilesByBlock(const string& a_file, const string& b_file) {
EXPECT_TRUE(utils::ReadFile(b_file, &b_data)) << "file failed: " << b_file;
EXPECT_EQ(a_data.size(), b_data.size());
- size_t kBlockSize = 4096;
EXPECT_EQ(0, a_data.size() % kBlockSize);
for (size_t i = 0; i < a_data.size(); i += kBlockSize) {
EXPECT_EQ(0, i % kBlockSize);
@@ -277,4 +281,65 @@ TEST(DeltaPerformerTest, RunAsRootSmallImageTest) {
EXPECT_TRUE(performer.VerifyPayload(kUnittestPublicKeyPath));
}
+TEST(DeltaPerformerTest, NewFullUpdateTest) {
+ vector<char> new_root(20 * 1024 * 1024);
+ vector<char> new_kern(16 * 1024 * 1024);
+ const off_t kChunkSize = 128 * 1024;
+ FillWithData(&new_root);
+ FillWithData(&new_kern);
+
+ string new_root_path;
+ EXPECT_TRUE(utils::MakeTempFile("/tmp/NewFullUpdateTest_R.XXXXXX",
+ &new_root_path,
+ NULL));
+ ScopedPathUnlinker new_root_path_unlinker(new_root_path);
+ EXPECT_TRUE(WriteFileVector(new_root_path, new_root));
+
+ string new_kern_path;
+ EXPECT_TRUE(utils::MakeTempFile("/tmp/NewFullUpdateTest_K.XXXXXX",
+ &new_kern_path,
+ NULL));
+ ScopedPathUnlinker new_kern_path_unlinker(new_kern_path);
+ EXPECT_TRUE(WriteFileVector(new_kern_path, new_kern));
+
+ string out_blobs_path;
+ int out_blobs_fd;
+ EXPECT_TRUE(utils::MakeTempFile("/tmp/NewFullUpdateTest_D.XXXXXX",
+ &out_blobs_path,
+ &out_blobs_fd));
+ ScopedPathUnlinker out_blobs_path_unlinker(out_blobs_path);
+ ScopedFdCloser out_blobs_fd_closer(&out_blobs_fd);
+
+ off_t out_blobs_length = 0;
+
+ Graph graph;
+ vector<DeltaArchiveManifest_InstallOperation> kernel_ops;
+ vector<Vertex::Index> final_order;
+
+ EXPECT_TRUE(DeltaDiffGenerator::ReadFullUpdateFromDisk(&graph,
+ new_kern_path,
+ new_root_path,
+ out_blobs_fd,
+ &out_blobs_length,
+ kChunkSize,
+ &kernel_ops,
+ &final_order));
+ EXPECT_EQ(new_root.size() / kChunkSize, graph.size());
+ EXPECT_EQ(new_root.size() / kChunkSize, final_order.size());
+ EXPECT_EQ(new_kern.size() / kChunkSize, kernel_ops.size());
+ for (size_t i = 0; i < (new_root.size() / kChunkSize); ++i) {
+ EXPECT_EQ(i, final_order[i]);
+ EXPECT_EQ(1, graph[i].op.dst_extents_size());
+ EXPECT_EQ(i * kChunkSize / kBlockSize,
+ graph[i].op.dst_extents(0).start_block()) << "i = " << i;
+ EXPECT_EQ(kChunkSize / kBlockSize,
+ graph[i].op.dst_extents(0).num_blocks());
+ if (graph[i].op.type() !=
+ DeltaArchiveManifest_InstallOperation_Type_REPLACE) {
+ EXPECT_EQ(DeltaArchiveManifest_InstallOperation_Type_REPLACE_BZ,
+ graph[i].op.type());
+ }
+ }
+}
+
} // namespace chromeos_update_engine
« no previous file with comments | « delta_diff_generator.cc ('k') | generate_delta_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698