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

Unified Diff: base/files/file_unittest.cc

Issue 1372113002: Remove memory corruption testing from base::File(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: narrowed Created 5 years, 3 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 | « base/files/file_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_unittest.cc
diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc
index fd79a37c64c777845032737899b69cb654c5898e..67dbbfd1ec87eecc9eeb14f9c71d5082f2e5c847 100644
--- a/base/files/file_unittest.cc
+++ b/base/files/file_unittest.cc
@@ -5,7 +5,6 @@
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -510,71 +509,3 @@ TEST(FileTest, GetInfoForDirectory) {
EXPECT_EQ(0, info.size);
}
#endif // defined(OS_WIN)
-
-#if defined(OS_POSIX) && defined(GTEST_HAS_DEATH_TEST)
-TEST(FileTest, MemoryCorruption) {
- {
- // Test that changing the checksum value is detected.
- base::File file;
- EXPECT_NE(file.file_.file_memory_checksum_,
- static_cast<unsigned int>(file.GetPlatformFile()));
- file.file_.file_memory_checksum_ = file.GetPlatformFile();
- EXPECT_DEATH(file.IsValid(), "");
-
- file.file_.UpdateChecksum(); // Do not crash on File::~File().
- }
-
- {
- // Test that changing the file descriptor value is detected.
- base::File file;
- file.file_.file_.reset(17);
- EXPECT_DEATH(file.IsValid(), "");
-
- // Do not crash on File::~File().
- ignore_result(file.file_.file_.release());
- file.file_.UpdateChecksum();
- }
-
- {
- // Test that GetPlatformFile() checks for corruption.
- base::File file;
- file.file_.file_memory_checksum_ = file.GetPlatformFile();
- EXPECT_DEATH(file.GetPlatformFile(), "");
-
- file.file_.UpdateChecksum(); // Do not crash on File::~File().
- }
-
- {
- // Test that the base::File destructor checks for corruption.
- scoped_ptr<base::File> file(new File());
- file->file_.file_memory_checksum_ = file->GetPlatformFile();
- EXPECT_DEATH(file.reset(), "");
-
- // Do not crash on this thread's destructor call.
- file->file_.UpdateChecksum();
- }
-
- {
- // Test that the base::File constructor checks for corruption.
- base::File file;
- file.file_.file_memory_checksum_ = file.GetPlatformFile();
- EXPECT_DEATH(File f(file.Pass()), "");
-
- file.file_.UpdateChecksum(); // Do not crash on File::~File().
- }
-
- {
- // Test that doing IO checks for corruption.
- base::File file;
- file.file_.file_.reset(17); // A fake open FD value.
-
- EXPECT_DEATH(file.Seek(File::FROM_BEGIN, 0), "");
- EXPECT_DEATH(file.Read(0, NULL, 0), "");
- EXPECT_DEATH(file.ReadAtCurrentPos(NULL, 0), "");
- EXPECT_DEATH(file.Write(0, NULL, 0), "");
-
- ignore_result(file.file_.file_.release());
- file.file_.UpdateChecksum();
- }
-}
-#endif // defined(OS_POSIX)
« no previous file with comments | « base/files/file_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698