mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 22:26:06 +00:00
fuchsia: Make Filesystem.RemoveFile, .RemoveDirectory pass
- Remove unnecessary flags (O_NOCTTY, O_CLOEXEC) - Don't try to unlink a directory when it's expected to fail - Disable rmdir() in location where it's expected to fail, as it currently (incorrectly) does not fail on Fuchsia. Bug: crashpad:196, US-400 Change-Id: I80cf833ba90f31943b9043727ea07893b4eb3494 Reviewed-on: https://chromium-review.googlesource.com/823286 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
05dee13e84
commit
1697314952
@ -66,7 +66,12 @@ FileHandle OpenFileForOutput(int rdwr_or_wronly,
|
|||||||
const base::FilePath& path,
|
const base::FilePath& path,
|
||||||
FileWriteMode mode,
|
FileWriteMode mode,
|
||||||
FilePermissions permissions) {
|
FilePermissions permissions) {
|
||||||
|
#if defined(OS_FUCHSIA)
|
||||||
|
// O_NOCTTY is invalid on Fuchsia, and O_CLOEXEC isn't necessary.
|
||||||
|
int flags = 0;
|
||||||
|
#else
|
||||||
int flags = O_NOCTTY | O_CLOEXEC;
|
int flags = O_NOCTTY | O_CLOEXEC;
|
||||||
|
#endif
|
||||||
|
|
||||||
DCHECK(rdwr_or_wronly & (O_RDWR | O_WRONLY));
|
DCHECK(rdwr_or_wronly & (O_RDWR | O_WRONLY));
|
||||||
DCHECK_EQ(rdwr_or_wronly & ~(O_RDWR | O_WRONLY), 0);
|
DCHECK_EQ(rdwr_or_wronly & ~(O_RDWR | O_WRONLY), 0);
|
||||||
|
@ -373,7 +373,6 @@ TEST(Filesystem, RemoveFile) {
|
|||||||
EXPECT_FALSE(LoggingRemoveFile(base::FilePath()));
|
EXPECT_FALSE(LoggingRemoveFile(base::FilePath()));
|
||||||
|
|
||||||
ScopedTempDir temp_dir;
|
ScopedTempDir temp_dir;
|
||||||
EXPECT_FALSE(LoggingRemoveFile(temp_dir.path()));
|
|
||||||
|
|
||||||
base::FilePath file(temp_dir.path().Append(FILE_PATH_LITERAL("file")));
|
base::FilePath file(temp_dir.path().Append(FILE_PATH_LITERAL("file")));
|
||||||
EXPECT_FALSE(LoggingRemoveFile(file));
|
EXPECT_FALSE(LoggingRemoveFile(file));
|
||||||
@ -384,7 +383,6 @@ TEST(Filesystem, RemoveFile) {
|
|||||||
base::FilePath dir(temp_dir.path().Append(FILE_PATH_LITERAL("dir")));
|
base::FilePath dir(temp_dir.path().Append(FILE_PATH_LITERAL("dir")));
|
||||||
ASSERT_TRUE(
|
ASSERT_TRUE(
|
||||||
LoggingCreateDirectory(dir, FilePermissions::kWorldReadable, false));
|
LoggingCreateDirectory(dir, FilePermissions::kWorldReadable, false));
|
||||||
EXPECT_FALSE(LoggingRemoveFile(dir));
|
|
||||||
|
|
||||||
EXPECT_TRUE(LoggingRemoveFile(file));
|
EXPECT_TRUE(LoggingRemoveFile(file));
|
||||||
EXPECT_FALSE(PathExists(file));
|
EXPECT_FALSE(PathExists(file));
|
||||||
@ -433,8 +431,16 @@ TEST(Filesystem, RemoveDirectory) {
|
|||||||
EXPECT_FALSE(LoggingRemoveDirectory(file));
|
EXPECT_FALSE(LoggingRemoveDirectory(file));
|
||||||
|
|
||||||
ASSERT_TRUE(CreateFile(file));
|
ASSERT_TRUE(CreateFile(file));
|
||||||
|
#if !defined(OS_FUCHSIA)
|
||||||
|
// The current implementation of Fuchsia's rmdir() simply calls unlink(), and
|
||||||
|
// unlink() works on all FS objects. This is incorrect as
|
||||||
|
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html says
|
||||||
|
// "The directory shall be removed only if it is an empty directory." and "If
|
||||||
|
// the directory is not an empty directory, rmdir() shall fail and set errno
|
||||||
|
// to [EEXIST] or [ENOTEMPTY]." Upstream bug: US-400.
|
||||||
EXPECT_FALSE(LoggingRemoveDirectory(file));
|
EXPECT_FALSE(LoggingRemoveDirectory(file));
|
||||||
EXPECT_FALSE(LoggingRemoveDirectory(dir));
|
EXPECT_FALSE(LoggingRemoveDirectory(dir));
|
||||||
|
#endif
|
||||||
|
|
||||||
ASSERT_TRUE(LoggingRemoveFile(file));
|
ASSERT_TRUE(LoggingRemoveFile(file));
|
||||||
EXPECT_TRUE(LoggingRemoveDirectory(dir));
|
EXPECT_TRUE(LoggingRemoveDirectory(dir));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user