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

Unified Diff: base/files/file_util_unittest.cc

Issue 2823343002: Add a POSIX version of FileUtilTest.SetNonBlocking. (Closed)
Patch Set: Just add the test, fix Android, fix bad upload Created 3 years, 8 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 2d95be4fff578a55b1ddeb2261166dc0d162757f..7b35f59ebfec234095ab61d801e82dfe38726fea 100644
--- a/base/files/file_util_unittest.cc
+++ b/base/files/file_util_unittest.cc
@@ -2255,6 +2255,17 @@ TEST_F(FileUtilTest, IsDirectoryEmpty) {
}
#if defined(OS_POSIX)
+TEST_F(FileUtilTest, SetNonBlocking) {
+ const int kInvalidFd = 99999;
+ EXPECT_FALSE(SetNonBlocking(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));
tfarina 2017/04/18 22:14:42 Could we also test with socket() or for our test i
Lei Zhang 2017/04/18 22:19:11 I wasn't really aiming for this to be a comprehens
+ ASSERT_GE(fd.get(), 0);
+ EXPECT_TRUE(SetNonBlocking(fd.get()));
+}
// Testing VerifyPathControlledByAdmin() is hard, because there is no
// way a test can make a file owned by root, or change file paths
« 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