From 9a126ba3b3cb696e05d5b842ae8fe457d3b19f14 Mon Sep 17 00:00:00 2001 From: Lei Jin Date: Tue, 28 Jan 2014 16:03:55 -0800 Subject: [PATCH] only corrupt private file checksum in backupable_db_test Summary: if it happens (randomly) to corrupt shared file in the test, then the checksum will be inconsistent between meta files from different backup. BackupEngine will then detect this issue and fail. But in reality, this does not happen since the checksum is checked on every backup. So here, only corrupt checksum of private file to let BackupEngine to construct properly (but fail during restore). Test Plan: run test with valgrind Reviewers: igor Reviewed By: igor CC: leveldb Differential Revision: https://reviews.facebook.net/D15531 --- utilities/backupable/backupable_db_test.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/utilities/backupable/backupable_db_test.cc b/utilities/backupable/backupable_db_test.cc index c5909f8e7..89326bfe7 100644 --- a/utilities/backupable/backupable_db_test.cc +++ b/utilities/backupable/backupable_db_test.cc @@ -250,17 +250,15 @@ class FileManager : public EnvWrapper { return s; } - std::vector positions; - auto pos = metadata.find(" crc32 "); + auto pos = metadata.find("private"); + if (pos == std::string::npos) { + return Status::Corruption("private file is expected"); + } + pos = metadata.find(" crc32 ", pos + 6); if (pos == std::string::npos) { return Status::Corruption("checksum not found"); } - do { - positions.push_back(pos); - pos = metadata.find(" crc32 ", pos + 6); - } while (pos != std::string::npos); - pos = positions[rnd_.Next() % positions.size()]; if (metadata.size() < pos + 7) { return Status::Corruption("bad CRC32 checksum value"); }