Adjust embedded dex locations in host boot image.

The run tests require that "out/host/linux-x86" is included.

This matches core.art locations.

This is CL is partial revert of CL/1234908.

Test: m test-art-host-gtest
Bug: 147817558
Bug: 147819342
Change-Id: I2083cba10235def41c07e34a01a4ee8cd548d978
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index a7675f4..62535a4 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -276,11 +276,7 @@
   }
 }
 
-// Helper - find directory with the following format:
-// ${ANDROID_BUILD_TOP}/${subdir1}/${subdir2}-${version}/${subdir3}/bin/
-std::string CommonArtTestImpl::GetAndroidToolsDir(const std::string& subdir1,
-                                                  const std::string& subdir2,
-                                                  const std::string& subdir3) {
+std::string CommonArtTestImpl::GetAndroidBuildTop() {
   std::string root;
   const char* android_build_top = getenv("ANDROID_BUILD_TOP");
   if (android_build_top != nullptr) {
@@ -292,8 +288,19 @@
     root = cwd;
     free(cwd);
   }
+  CHECK(!root.empty());
+  if (root.back() != '/') {
+    root += '/';
+  }
+  return root;
+}
 
-  std::string toolsdir = root + "/" + subdir1;
+// Helper - find directory with the following format:
+// ${ANDROID_BUILD_TOP}/${subdir1}/${subdir2}-${version}/${subdir3}/bin/
+std::string CommonArtTestImpl::GetAndroidToolsDir(const std::string& subdir1,
+                                                  const std::string& subdir2,
+                                                  const std::string& subdir3) {
+  std::string toolsdir = GetAndroidBuildTop() + subdir1;
   std::string founddir;
   DIR* dir;
   if ((dir = opendir(toolsdir.c_str())) != nullptr) {
@@ -338,8 +345,7 @@
   MemMap::Init();
   static constexpr bool kVerifyChecksum = true;
   const ArtDexFileLoader dex_file_loader;
-  std::string prefix = IsHost() ? GetAndroidRoot() : "";
-  std::string filename = prefix + location;
+  std::string filename(location);
   if (!dex_file_loader.Open(filename.c_str(),
                             std::string(location),
                             /* verify= */ true,
@@ -436,8 +442,8 @@
     const std::vector<std::string>& modules) const {
   std::vector<std::string> result = GetLibCoreDexFileNames(modules);
   if (IsHost()) {
-    // Strip the build directory prefix (e.g. .../host/linux-x86)
-    std::string prefix = GetAndroidRoot();
+    // Strip the ANDROID_BUILD_TOP directory including the directory separator '/'.
+    std::string prefix = GetAndroidBuildTop();
     for (std::string& location : result) {
       CHECK_GT(location.size(), prefix.size());
       CHECK_EQ(location.compare(0u, prefix.size(), prefix), 0);
diff --git a/libartbase/base/common_art_test.h b/libartbase/base/common_art_test.h
index 8cd25c3..07d32d6 100644
--- a/libartbase/base/common_art_test.h
+++ b/libartbase/base/common_art_test.h
@@ -253,6 +253,9 @@
     return !kIsTargetBuild;
   }
 
+  // Returns ${ANDROID_BUILD_TOP}. Ensure it has tailing /.
+  static std::string GetAndroidBuildTop();
+
   // Helper - find directory with the following format:
   // ${ANDROID_BUILD_TOP}/${subdir1}/${subdir2}-${version}/${subdir3}/bin/
   static std::string GetAndroidToolsDir(const std::string& subdir1,