summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;