summaryrefslogtreecommitdiffstats
path: root/runtime/common_runtime_test.h
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-06-26 04:59:51 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-06-25 17:34:34 +0000
commit8803c1cb633de1b0e0a48ffea30ddd8fac201a0e (patch)
tree242d4a1ccc6c3702ac5c2be54b519140f314d4fd /runtime/common_runtime_test.h
parent8a9f3ee5c955e4ff7cf9af6551fd432b454c4b13 (diff)
parent86f5662a9374ee03bcd2b440a67f1e90eaac70c0 (diff)
downloadart-8803c1cb633de1b0e0a48ffea30ddd8fac201a0e.tar.gz
art-8803c1cb633de1b0e0a48ffea30ddd8fac201a0e.tar.bz2
art-8803c1cb633de1b0e0a48ffea30ddd8fac201a0e.zip
Merge "ART: Use ANDROID_HOST_OUT for ANDROID_ROOT in Runtime tests"
Diffstat (limited to 'runtime/common_runtime_test.h')
-rw-r--r--runtime/common_runtime_test.h44
1 files changed, 27 insertions, 17 deletions
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 1df4c05e36..fdbc9c22c3 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -114,32 +114,42 @@ class CommonRuntimeTest : public testing::Test {
public:
static void SetEnvironmentVariables(std::string& android_data) {
if (IsHost()) {
- // $ANDROID_ROOT is set on the device, but not on the host.
- // We need to set this so that icu4c can find its locale data.
- std::string root;
- const char* android_build_top = getenv("ANDROID_BUILD_TOP");
- if (android_build_top != nullptr) {
- root += android_build_top;
- } else {
- // Not set by build server, so default to current directory
- char* cwd = getcwd(nullptr, 0);
- setenv("ANDROID_BUILD_TOP", cwd, 1);
- root += cwd;
- free(cwd);
- }
+ // $ANDROID_ROOT is set on the device, but not necessarily on the host.
+ // But it needs to be set so that icu4c can find its locale data.
+ const char* android_root_from_env = getenv("ANDROID_ROOT");
+ if (android_root_from_env == nullptr) {
+ // Use ANDROID_HOST_OUT for ANDROID_ROOT if it is set.
+ const char* android_host_out = getenv("ANDROID_HOST_OUT");
+ if (android_host_out != nullptr) {
+ setenv("ANDROID_ROOT", android_host_out, 1);
+ } else {
+ // Build it from ANDROID_BUILD_TOP or cwd
+ std::string root;
+ const char* android_build_top = getenv("ANDROID_BUILD_TOP");
+ if (android_build_top != nullptr) {
+ root += android_build_top;
+ } else {
+ // Not set by build server, so default to current directory
+ char* cwd = getcwd(nullptr, 0);
+ setenv("ANDROID_BUILD_TOP", cwd, 1);
+ root += cwd;
+ free(cwd);
+ }
#if defined(__linux__)
- root += "/out/host/linux-x86";
+ root += "/out/host/linux-x86";
#elif defined(__APPLE__)
- root += "/out/host/darwin-x86";
+ root += "/out/host/darwin-x86";
#else
#error unsupported OS
#endif
- setenv("ANDROID_ROOT", root.c_str(), 1);
+ setenv("ANDROID_ROOT", root.c_str(), 1);
+ }
+ }
setenv("LD_LIBRARY_PATH", ":", 0); // Required by java.lang.System.<clinit>.
// Not set by build server, so default
if (getenv("ANDROID_HOST_OUT") == nullptr) {
- setenv("ANDROID_HOST_OUT", root.c_str(), 1);
+ setenv("ANDROID_HOST_OUT", getenv("ANDROID_ROOT"), 1);
}
}