summaryrefslogtreecommitdiffstats
path: root/runtime/common_runtime_test.cc
diff options
context:
space:
mode:
authorDavid Srbecky <dsrbecky@google.com>2015-04-21 15:19:06 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-21 15:19:06 +0000
commitb4314b3aa80f0e6d3a55da7865e80658a150f1e8 (patch)
tree7b06abf97929e40d15719fc452f63cdf8b2bdd3a /runtime/common_runtime_test.cc
parent1c28591571c035dfdd76f28d17151b3a6eba4aac (diff)
parent3e52aa4d406fe802dabee2a2e7ba8764cc13aaaa (diff)
downloadart-b4314b3aa80f0e6d3a55da7865e80658a150f1e8.zip
art-b4314b3aa80f0e6d3a55da7865e80658a150f1e8.tar.gz
art-b4314b3aa80f0e6d3a55da7865e80658a150f1e8.tar.bz2
Merge "Move GetAndroidToolsDir to common location."
Diffstat (limited to 'runtime/common_runtime_test.cc')
-rw-r--r--runtime/common_runtime_test.cc77
1 files changed, 77 insertions, 0 deletions
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 60b7fa2..e17b885 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -16,6 +16,7 @@
#include "common_runtime_test.h"
+#include <cstdio>
#include <dirent.h>
#include <dlfcn.h>
#include <fcntl.h>
@@ -188,6 +189,82 @@ void CommonRuntimeTest::TearDownAndroidData(const std::string& android_data, boo
}
}
+// Helper - find directory with the following format:
+// ${ANDROID_BUILD_TOP}/${subdir1}/${subdir2}-${version}/${subdir3}/bin/
+static std::string GetAndroidToolsDir(const std::string& subdir1,
+ const std::string& subdir2,
+ const std::string& subdir3) {
+ 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);
+ }
+
+ std::string toolsdir = root + "/" + subdir1;
+ std::string founddir;
+ DIR* dir;
+ if ((dir = opendir(toolsdir.c_str())) != nullptr) {
+ float maxversion = 0;
+ struct dirent* entry;
+ while ((entry = readdir(dir)) != nullptr) {
+ std::string format = subdir2 + "-%f";
+ float version;
+ if (std::sscanf(entry->d_name, format.c_str(), &version) == 1) {
+ if (version > maxversion) {
+ maxversion = version;
+ founddir = toolsdir + "/" + entry->d_name + "/" + subdir3 + "/bin/";
+ }
+ }
+ }
+ closedir(dir);
+ }
+
+ if (founddir.empty()) {
+ ADD_FAILURE() << "Can not find Android tools directory.";
+ }
+ return founddir;
+}
+
+std::string CommonRuntimeTest::GetAndroidHostToolsDir() {
+ return GetAndroidToolsDir("prebuilts/gcc/linux-x86/host",
+ "x86_64-linux-glibc2.15",
+ "x86_64-linux");
+}
+
+std::string CommonRuntimeTest::GetAndroidTargetToolsDir(InstructionSet isa) {
+ switch (isa) {
+ case kArm:
+ case kThumb2:
+ return GetAndroidToolsDir("prebuilts/gcc/linux-x86/arm",
+ "arm-linux-androideabi",
+ "arm-linux-androideabi");
+ case kArm64:
+ return GetAndroidToolsDir("prebuilts/gcc/linux-x86/aarch64",
+ "aarch64-linux-android",
+ "aarch64-linux-android");
+ case kX86:
+ case kX86_64:
+ return GetAndroidToolsDir("prebuilts/gcc/linux-x86/x86",
+ "x86_64-linux-android",
+ "x86_64-linux-android");
+ case kMips:
+ case kMips64:
+ return GetAndroidToolsDir("prebuilts/gcc/linux-x86/mips",
+ "mips64el-linux-android",
+ "mips64el-linux-android");
+ case kNone:
+ break;
+ }
+ ADD_FAILURE() << "Invalid isa " << isa;
+ return "";
+}
+
std::string CommonRuntimeTest::GetCoreArtLocation() {
return GetCoreFileLocation("art");
}