| Index: sync/syncable/directory_backing_store_unittest.cc
|
| diff --git a/sync/syncable/directory_backing_store_unittest.cc b/sync/syncable/directory_backing_store_unittest.cc
|
| index 25aca638a8453b5da43fa7591f240581aa093ded..0a1cc3db7e79977725bcfdbd5f10f12cb4607728 100644
|
| --- a/sync/syncable/directory_backing_store_unittest.cc
|
| +++ b/sync/syncable/directory_backing_store_unittest.cc
|
| @@ -2083,22 +2083,37 @@ TEST_F(DirectoryBackingStoreTest, ModelTypeIds) {
|
| }
|
| }
|
|
|
| -// TODO(109668): This had to be disabled because the latest API will
|
| -// intentionally crash when a database is this badly corrupted.
|
| -TEST_F(DirectoryBackingStoreTest, DISABLED_Corruption) {
|
| +// This is a whitebox test intended to exercise the code path where the on-disk
|
| +// directory load code decides to delete the current directory and start fresh.
|
| +//
|
| +// Unfortunately, there's no way to tell that this code path is actually
|
| +// exercised by the test. If the directory failed to detect the corruption, the
|
| +// result would look exactly the same from this level of abstraction.
|
| +//
|
| +// This is considered "minor" corruption because the database recreation is
|
| +// expected to succeed. The alternative, where recreation does not succeed (ie.
|
| +// due to read-only file system), is not tested here.
|
| +TEST_F(DirectoryBackingStoreTest, MinorCorruption) {
|
| {
|
| scoped_ptr<OnDiskDirectoryBackingStore> dbs(
|
| new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath()));
|
| - EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
|
| + EXPECT_EQ(OPENED, LoadAndIgnoreReturnedData(dbs.get()));
|
| + }
|
| +
|
| + // Corrupt the root node.
|
| + {
|
| + sql::Connection connection;
|
| + ASSERT_TRUE(connection.Open(GetDatabasePath()));
|
| + ASSERT_TRUE(connection.Execute(
|
| + "UPDATE metas SET parent_id='bogus' WHERE id = 'r';"));
|
| }
|
| - std::string bad_data("BAD DATA");
|
| - EXPECT_TRUE(file_util::WriteFile(GetDatabasePath(), bad_data.data(),
|
| - bad_data.size()));
|
| +
|
| {
|
| scoped_ptr<OnDiskDirectoryBackingStore> dbs(
|
| new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath()));
|
| + dbs->AllowFailureForTest();
|
|
|
| - EXPECT_FALSE(LoadAndIgnoreReturnedData(dbs.get()));
|
| + EXPECT_EQ(OPENED, LoadAndIgnoreReturnedData(dbs.get()));
|
| }
|
| }
|
|
|
|
|