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

Unified Diff: base/files/protect_file_posix_unittest.cc

Issue 720753002: NOT_FOR_COMMIT: Death Test for intercepting base::File Open/Close Base URL: https://chromium.googlesource.com/chromium/src.git@cache-close
Patch Set: Created 6 years, 1 month 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/base.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/protect_file_posix_unittest.cc
diff --git a/base/files/protect_file_posix_unittest.cc b/base/files/protect_file_posix_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e8ddeaea636082d7e0ce9e8e21529b7bc9d770d3
--- /dev/null
+++ b/base/files/protect_file_posix_unittest.cc
@@ -0,0 +1,31 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#if defined(OS_POSIX)
+#include <unistd.h>
+#endif
+
+#include "base/files/file.h"
+#include "base/files/scoped_temp_dir.h"
+#include "base/posix/eintr_wrapper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+#if defined(OS_POSIX) && GTEST_HAS_DEATH_TEST
+
+TEST(ProtectFilePosixDeathTest, CloseProtected) {
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ base::FilePath file_path = temp_dir.path().AppendASCII("new_file");
+ base::File file(file_path,
+ base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_READ);
+ EXPECT_TRUE(file.IsValid());
+ int fd = file.GetPlatformFile();
+ EXPECT_DEATH(IGNORE_EINTR(close(fd)), "");
+}
+
+#endif // defined(OS_POSIX) && GTEST_HAS_DEATH_TEST
+
+} // namespace
« no previous file with comments | « base/base.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698