Blacklist handling of the netflix plugin.

The netflix plugin is triggering a bug in bsdiff, so adding a blacklist
of bsdiff testing for this file until bsdiff is fixed.

BUG=chromium-os:28552
TEST=Built/ran new unittests. Did NOT diff a ChromeOS image (yet).

Change-Id: Ib2ba71ab815105fb4db88e0b24335d34693b96f7
Reviewed-on: https://gerrit.chromium.org/gerrit/19205
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Commit-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
diff --git a/delta_diff_generator_unittest.cc b/delta_diff_generator_unittest.cc
index bd0b48e..632b8e7 100644
--- a/delta_diff_generator_unittest.cc
+++ b/delta_diff_generator_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2012 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.
 
@@ -70,6 +70,7 @@
   DeltaArchiveManifest_InstallOperation op;
   EXPECT_TRUE(DeltaDiffGenerator::ReadFileToDiff(old_path(),
                                                  new_path(),
+                                                 std::set<string>(),
                                                  &data,
                                                  &op,
                                                  true));
@@ -99,6 +100,7 @@
   DeltaArchiveManifest_InstallOperation op;
   EXPECT_TRUE(DeltaDiffGenerator::ReadFileToDiff(old_path(),
                                                  new_path(),
+                                                 std::set<string>(),
                                                  &data,
                                                  &op,
                                                  true));
@@ -117,6 +119,97 @@
   EXPECT_EQ(1, BlocksInExtents(op.dst_extents()));
 }
 
+TEST_F(DeltaDiffGeneratorTest, RunAsRootBsdiffBlacklistNoMatchTest) {
+  EXPECT_TRUE(utils::WriteFile(old_path().c_str(),
+                               reinterpret_cast<const char*>(kRandomString),
+                               sizeof(kRandomString) - 1));
+  EXPECT_TRUE(utils::WriteFile(new_path().c_str(),
+                               reinterpret_cast<const char*>(kRandomString),
+                               sizeof(kRandomString)));
+  vector<char> data;
+  DeltaArchiveManifest_InstallOperation op;
+
+  std::set<string> bsdiff_blacklist;
+  bsdiff_blacklist.insert("fuzzy_bunny");  // Not the new_path
+
+  EXPECT_TRUE(DeltaDiffGenerator::ReadFileToDiff(old_path(),
+                                                 new_path(),
+                                                 bsdiff_blacklist,
+                                                 &data,
+                                                 &op,
+                                                 true));
+  EXPECT_FALSE(data.empty());
+
+  EXPECT_TRUE(op.has_type());
+  EXPECT_EQ(DeltaArchiveManifest_InstallOperation_Type_BSDIFF, op.type());
+  EXPECT_FALSE(op.has_data_offset());
+  EXPECT_FALSE(op.has_data_length());
+  EXPECT_EQ(1, op.src_extents_size());
+  EXPECT_EQ(sizeof(kRandomString) - 1, op.src_length());
+  EXPECT_EQ(1, op.dst_extents_size());
+  EXPECT_EQ(sizeof(kRandomString), op.dst_length());
+  EXPECT_EQ(BlocksInExtents(op.src_extents()),
+            BlocksInExtents(op.dst_extents()));
+  EXPECT_EQ(1, BlocksInExtents(op.dst_extents()));
+}
+
+
+TEST_F(DeltaDiffGeneratorTest, RunAsRootBsdiffBlacklistMatchTest) {
+  EXPECT_TRUE(utils::WriteFile(old_path().c_str(),
+                               reinterpret_cast<const char*>(kRandomString),
+                               sizeof(kRandomString) - 1));
+  EXPECT_TRUE(utils::WriteFile(new_path().c_str(),
+                               reinterpret_cast<const char*>(kRandomString),
+                               sizeof(kRandomString)));
+  vector<char> data;
+  DeltaArchiveManifest_InstallOperation op;
+
+  std::set<string> bsdiff_blacklist;
+  bsdiff_blacklist.insert("fuzzy_bunny");
+  bsdiff_blacklist.insert(old_path());
+
+  EXPECT_TRUE(DeltaDiffGenerator::ReadFileToDiff(old_path(),
+                                                 new_path(),
+                                                 bsdiff_blacklist,
+                                                 &data,
+                                                 &op,
+                                                 true));
+  EXPECT_FALSE(data.empty());
+
+  // The point of this test is that we don't use BSDIFF the way the above
+  // did. The rest of the details are to be caught in other tests.
+  EXPECT_TRUE(op.has_type());
+  EXPECT_NE(DeltaArchiveManifest_InstallOperation_Type_BSDIFF, op.type());
+}
+
+TEST_F(DeltaDiffGeneratorTest, RunAsRootBsdiffBlacklistMoveMatchTest) {
+  EXPECT_TRUE(utils::WriteFile(old_path().c_str(),
+                               reinterpret_cast<const char*>(kRandomString),
+                               sizeof(kRandomString)));
+  EXPECT_TRUE(utils::WriteFile(new_path().c_str(),
+                               reinterpret_cast<const char*>(kRandomString),
+                               sizeof(kRandomString)));
+  vector<char> data;
+  DeltaArchiveManifest_InstallOperation op;
+
+  std::set<string> bsdiff_blacklist;
+  bsdiff_blacklist.insert("fuzzy_bunny");
+  bsdiff_blacklist.insert(old_path());
+
+  EXPECT_TRUE(DeltaDiffGenerator::ReadFileToDiff(old_path(),
+                                                 new_path(),
+                                                 bsdiff_blacklist,
+                                                 &data,
+                                                 &op,
+                                                 true));
+  EXPECT_TRUE(data.empty());
+
+  // The point of this test is that we can still use a MOVE for a file
+  // that is blacklisted.
+  EXPECT_TRUE(op.has_type());
+  EXPECT_EQ(DeltaArchiveManifest_InstallOperation_Type_MOVE, op.type());
+}
+
 TEST_F(DeltaDiffGeneratorTest, RunAsRootReplaceSmallTest) {
   vector<char> new_data;
   for (int i = 0; i < 2; i++) {
@@ -130,6 +223,7 @@
     DeltaArchiveManifest_InstallOperation op;
     EXPECT_TRUE(DeltaDiffGenerator::ReadFileToDiff(old_path(),
                                                    new_path(),
+                                                   std::set<string>(),
                                                    &data,
                                                    &op,
                                                    true));
@@ -161,6 +255,7 @@
   DeltaArchiveManifest_InstallOperation op;
   EXPECT_TRUE(DeltaDiffGenerator::ReadFileToDiff(old_path(),
                                                  new_path(),
+                                                 std::set<string>(),
                                                  &data,
                                                  &op,
                                                  false));