summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Narayan Kamath <narayan@google.com> 2017-05-23 13:20:07 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-05-23 13:20:09 +0000
commit73b9f4599844cd24f327785f46ff576622d8f691 (patch)
treee25bae926712488ae17215f33312447aadb90dcb
parenta17d6792358ffae7323e9f4e54e1b16eda5d6e0b (diff)
parenteda7d3d7ea48a6ab6bb6ad007b14a10e1a9896cd (diff)
Merge "FdFile: fix operator=(FdFile&&)"
-rw-r--r--runtime/base/unix_file/fd_file.cc1
-rw-r--r--runtime/base/unix_file/fd_file_test.cc14
2 files changed, 15 insertions, 0 deletions
diff --git a/runtime/base/unix_file/fd_file.cc b/runtime/base/unix_file/fd_file.cc
index 03fc959f6b..00b5567012 100644
--- a/runtime/base/unix_file/fd_file.cc
+++ b/runtime/base/unix_file/fd_file.cc
@@ -91,6 +91,7 @@ FdFile& FdFile::operator=(FdFile&& other) {
fd_ = other.fd_;
file_path_ = std::move(other.file_path_);
auto_close_ = other.auto_close_;
+ read_only_mode_ = other.read_only_mode_;
other.Release(); // Release other.
return *this;
diff --git a/runtime/base/unix_file/fd_file_test.cc b/runtime/base/unix_file/fd_file_test.cc
index 7657a38cec..6aef348433 100644
--- a/runtime/base/unix_file/fd_file_test.cc
+++ b/runtime/base/unix_file/fd_file_test.cc
@@ -186,6 +186,20 @@ TEST_F(FdFileTest, MoveConstructor) {
ASSERT_EQ(file2.Close(), 0);
}
+TEST_F(FdFileTest, OperatorMoveEquals) {
+ // Make sure the read_only_ flag is correctly copied
+ // over.
+ art::ScratchFile tmp;
+ FdFile file(tmp.GetFilename(), O_RDONLY, false);
+ ASSERT_TRUE(file.ReadOnlyMode());
+
+ FdFile file2(tmp.GetFilename(), O_RDWR, false);
+ ASSERT_FALSE(file2.ReadOnlyMode());
+
+ file2 = std::move(file);
+ ASSERT_TRUE(file2.ReadOnlyMode());
+}
+
TEST_F(FdFileTest, EraseWithPathUnlinks) {
// New scratch file, zero-length.
art::ScratchFile tmp;