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

Unified Diff: base/files/file_util_unittest.cc

Issue 2862873002: base: add a unit test for SetCloseOnExec() function (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_util_unittest.cc
diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc
index 7b35f59ebfec234095ab61d801e82dfe38726fea..555224d934e2219662eaaec25bae3cf21b1e3d1c 100644
--- a/base/files/file_util_unittest.cc
+++ b/base/files/file_util_unittest.cc
@@ -2267,6 +2267,18 @@ TEST_F(FileUtilTest, SetNonBlocking) {
EXPECT_TRUE(SetNonBlocking(fd.get()));
}
+TEST_F(FileUtilTest, SetCloseOnExec) {
+ const int kInvalidFd = 99999;
+ EXPECT_FALSE(SetCloseOnExec(kInvalidFd));
+
+ base::FilePath path;
+ ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &path));
+ path = path.Append(FPL("file_util")).Append(FPL("original.txt"));
+ ScopedFD fd(open(path.value().c_str(), O_RDONLY));
+ ASSERT_GE(fd.get(), 0);
+ EXPECT_TRUE(SetCloseOnExec(fd.get()));
+}
+
// Testing VerifyPathControlledByAdmin() is hard, because there is no
// way a test can make a file owned by root, or change file paths
// at the root of the file system. VerifyPathControlledByAdmin()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698