diff options
Diffstat (limited to 'libartbase/base/common_art_test.cc')
-rw-r--r-- | libartbase/base/common_art_test.cc | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc index 4823fc2de4..b0f1c6cbfe 100644 --- a/libartbase/base/common_art_test.cc +++ b/libartbase/base/common_art_test.cc @@ -507,7 +507,12 @@ std::string CommonArtTestImpl::GetClassPathOption(const char* option, std::string CommonArtTestImpl::GetTestDexFileName(const char* name) const { CHECK(name != nullptr); // The needed jar files for gtest are located next to the gtest binary itself. - std::string executable_dir = android::base::GetExecutableDirectory(); + std::string cmdline; + bool result = android::base::ReadFileToString("/proc/self/cmdline", &cmdline); + CHECK(result); + UniqueCPtr<char[]> executable_path(realpath(cmdline.c_str(), nullptr)); + CHECK(executable_path != nullptr); + std::string executable_dir = dirname(executable_path.get()); for (auto ext : {".jar", ".dex"}) { std::string path = executable_dir + "/art-gtest-jars-" + name + ext; if (OS::FileExists(path.c_str())) { @@ -559,19 +564,7 @@ std::string CommonArtTestImpl::GetImageDirectory() { CHECK(host_dir != nullptr); return std::string(host_dir) + "/apex/art_boot_images/javalib"; } - // On device, the boot image is generated by `generate-boot-image`. - // In a standalone test, the boot image is located next to the gtest binary itself. - std::string path = android::base::GetExecutableDirectory() + "/art_boot_images"; - if (OS::DirectoryExists(path.c_str())) { - return path; - } - // In a chroot test, the boot image is located in a predefined location. - path = "/data/local/tmp/art_boot_images"; - if (OS::DirectoryExists(path.c_str())) { - return path; - } - LOG(FATAL) << "Boot image not found"; - UNREACHABLE(); + return GetPrebuiltPrimaryBootImageDir(); } std::string CommonArtTestImpl::GetCoreFileLocation(const char* suffix) { |