Make image test multi image

Required for testing multi image layout in future CLs.

Bug: 28640955

Test: clean-oat-host, test-art-host, device booting

(cherry picked from commit 25adcfb7dc81131add3a0a681ae18bced6f7a0e0)

Change-Id: I14809f56e711b4a87e01056c327eddbbd087f4ee
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 7234952..8a48604 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -76,9 +76,10 @@
   file_.reset(new File(fd, GetFilename(), true));
 }
 
-ScratchFile::ScratchFile(const ScratchFile& other, const char* suffix) {
-  filename_ = other.GetFilename();
-  filename_ += suffix;
+ScratchFile::ScratchFile(const ScratchFile& other, const char* suffix)
+    : ScratchFile(other.GetFilename() + suffix) {}
+
+ScratchFile::ScratchFile(const std::string& filename) : filename_(filename) {
   int fd = open(filename_.c_str(), O_RDWR | O_CREAT, 0666);
   CHECK_NE(-1, fd);
   file_.reset(new File(fd, GetFilename(), true));
@@ -90,6 +91,18 @@
   file_.reset(file);
 }
 
+ScratchFile::ScratchFile(ScratchFile&& other) {
+  *this = std::move(other);
+}
+
+ScratchFile& ScratchFile::operator=(ScratchFile&& other) {
+  if (GetFile() != other.GetFile()) {
+    std::swap(filename_, other.filename_);
+    std::swap(file_, other.file_);
+  }
+  return *this;
+}
+
 ScratchFile::~ScratchFile() {
   Unlink();
 }