Fallback to using ANDROID_HOST_OUT env-var in gtests
When running gtests using external runners in conjunction with certain
runners the gtest can believe that it is being run from a directory
other than ANDROID_HOST_OUT. Instead of aborting this change makes the
gtest simply accept the env-var and use it instead of trying to
determine it based on the executable's path.
Test: manual, VSCode
Change-Id: I1ae7bbc58bea1813683d3180c9ee93be21f21df5
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index 875920c..efc223c 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -214,7 +214,11 @@
std::filesystem::path expected(android_host_out);
if (android_host_out_from_env != nullptr) {
std::filesystem::path from_env(std::filesystem::weakly_canonical(android_host_out_from_env));
- CHECK_EQ(std::filesystem::weakly_canonical(expected).string(), from_env.string());
+ if (std::filesystem::weakly_canonical(expected).string() != from_env.string()) {
+ LOG(WARNING) << "Execution path (" << expected << ") not below ANDROID_HOST_OUT ("
+ << from_env << ")! Using env-var.";
+ expected = from_env;
+ }
} else {
setenv("ANDROID_HOST_OUT", android_host_out.c_str(), /*overwrite=*/0);
}