Chromium Code Reviews| Index: base/files/file_util_unittest.cc |
| diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc |
| index 08c9587cc0655895e4604cc7e85be88f25215d05..e61cb89267feb3fe22dfafdc0098db1b82d211b4 100644 |
| --- a/base/files/file_util_unittest.cc |
| +++ b/base/files/file_util_unittest.cc |
| @@ -2143,6 +2143,28 @@ TEST_F(FileUtilTest, TouchFile) { |
| file_info.last_modified.ToInternalValue()); |
| } |
| +#if defined(OS_POSIX) && !defined(OS_ANDROID) |
| +TEST_F(FileUtilTest, WriteFileWithMode) { |
| + FilePath data_dir = |
| + temp_dir_.path().Append(FILE_PATH_LITERAL("FilePathTest")); |
| + |
| + // Create a fresh, empty copy of this directory. |
| + if (PathExists(data_dir)) { |
|
asanka
2014/11/03 14:44:57
This test, and the creation of a separate test dir
|
| + ASSERT_TRUE(DeleteFile(data_dir, true)); |
| + } |
| + ASSERT_TRUE(CreateDirectory(data_dir)); |
| + |
| + FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); |
| + std::string data("hello"); |
| + mode_t mode = 0644; |
| + ASSERT_TRUE(WriteFileWithMode(foobar, data.c_str(), data.length(), mode)); |
| + |
| + struct stat status; |
| + ASSERT_EQ(0, stat(foobar.value().c_str(), &status)); |
|
asanka
2014/11/03 14:44:57
Is there's a more aggressive umask on the MSan bot
|
| + ASSERT_EQ(mode, status.st_mode & 0777); |
| +} |
| +#endif |
| + |
| TEST_F(FileUtilTest, IsDirectoryEmpty) { |
| FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir")); |