Commit ab528fac authored by tfarina's avatar tfarina Committed by Commit bot

base: add a unit test for SetCloseOnExec() function

BUG=None
TEST=base_unittests --gtest_filter=FileUtilTest.SetCloseOnExec
R=thestig@chromium.org

Review-Url: https://codereview.chromium.org/2862873002
Cr-Commit-Position: refs/heads/master@{#469422}
parent d1c9c9bd
...@@ -2267,6 +2267,18 @@ TEST_F(FileUtilTest, SetNonBlocking) { ...@@ -2267,6 +2267,18 @@ TEST_F(FileUtilTest, SetNonBlocking) {
EXPECT_TRUE(SetNonBlocking(fd.get())); 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 // Testing VerifyPathControlledByAdmin() is hard, because there is no
// way a test can make a file owned by root, or change file paths // way a test can make a file owned by root, or change file paths
// at the root of the file system. VerifyPathControlledByAdmin() // at the root of the file system. VerifyPathControlledByAdmin()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment