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

Unified Diff: delta_performer_unittest.cc

Issue 3785008: AU: Don't send no-op operations in the delta payload. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: fix comment 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_performer.cc ('k') | no next file » | 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 e9d44fa31746ed8ba3f53630d81487dc2cf5bda9..3c05b1d9f62dc44c14d04e21dc5fdba2d8b8b07f 100755
--- a/delta_performer_unittest.cc
+++ b/delta_performer_unittest.cc
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include <base/file_util.h>
#include <base/scoped_ptr.h>
#include <base/string_util.h>
#include <google/protobuf/repeated_field.h>
@@ -112,7 +113,7 @@ bool WriteSparseFile(const string& path, off_t size) {
return true;
}
-void DoSmallImageTest(bool full_kernel) {
+void DoSmallImageTest(bool full_kernel, bool noop) {
string a_img, b_img;
EXPECT_TRUE(utils::MakeTempFile("/tmp/a_img.XXXXXX", &a_img, NULL));
ScopedPathUnlinker a_img_unlinker(a_img);
@@ -120,7 +121,6 @@ void DoSmallImageTest(bool full_kernel) {
ScopedPathUnlinker b_img_unlinker(b_img);
CreateExtImageAtPath(a_img, NULL);
- CreateExtImageAtPath(b_img, NULL);
int image_size = static_cast<int>(utils::FileSize(a_img));
@@ -129,12 +129,7 @@ void DoSmallImageTest(bool full_kernel) {
"dd if=/dev/zero of=%s seek=%d bs=1 count=1",
a_img.c_str(),
image_size + 1024 * 1024 - 1)));
- EXPECT_EQ(0, System(base::StringPrintf(
- "dd if=/dev/zero of=%s seek=%d bs=1 count=1",
- b_img.c_str(),
- image_size + 1024 * 1024 - 1)));
EXPECT_EQ(image_size + 1024 * 1024, utils::FileSize(a_img));
- EXPECT_EQ(image_size + 1024 * 1024, utils::FileSize(b_img));
// Make some changes to the A image.
{
@@ -154,8 +149,17 @@ void DoSmallImageTest(bool full_kernel) {
ones.size()));
}
- // Make some changes to the B image.
- {
+ if (noop) {
+ EXPECT_TRUE(file_util::CopyFile(FilePath(a_img), FilePath(b_img)));
+ } else {
+ CreateExtImageAtPath(b_img, NULL);
+ EXPECT_EQ(0, System(base::StringPrintf(
+ "dd if=/dev/zero of=%s seek=%d bs=1 count=1",
+ b_img.c_str(),
+ image_size + 1024 * 1024 - 1)));
+ EXPECT_EQ(image_size + 1024 * 1024, utils::FileSize(b_img));
+
+ // Make some changes to the B image.
string b_mnt;
ScopedLoopMounter b_mounter(b_img, &b_mnt, 0);
@@ -196,6 +200,10 @@ void DoSmallImageTest(bool full_kernel) {
const char* new_data_string = "This is new data.";
strcpy(&new_kernel_data[0], new_data_string);
+ if (noop) {
+ old_kernel_data = new_kernel_data;
+ }
+
// Write kernels to disk
EXPECT_TRUE(utils::WriteFile(
old_kernel.c_str(), &old_kernel_data[0], old_kernel_data.size()));
@@ -258,6 +266,11 @@ void DoSmallImageTest(bool full_kernel) {
EXPECT_EQ(expected_sig_data_length, manifest.signatures_size());
EXPECT_FALSE(signature.data().empty());
+ if (noop) {
+ EXPECT_EQ(1, manifest.install_operations_size());
+ EXPECT_EQ(1, manifest.kernel_install_operations_size());
+ }
+
if (full_kernel) {
EXPECT_FALSE(manifest.has_old_kernel_info());
} else {
@@ -333,11 +346,15 @@ void DoSmallImageTest(bool full_kernel) {
}
TEST(DeltaPerformerTest, RunAsRootSmallImageTest) {
- DoSmallImageTest(false);
+ DoSmallImageTest(false, false);
}
TEST(DeltaPerformerTest, RunAsRootFullKernelSmallImageTest) {
- DoSmallImageTest(true);
+ DoSmallImageTest(true, false);
+}
+
+TEST(DeltaPerformerTest, RunAsRootNoopSmallImageTest) {
+ DoSmallImageTest(false, true);
}
TEST(DeltaPerformerTest, NewFullUpdateTest) {
« no previous file with comments | « delta_performer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698