diff options
Diffstat (limited to 'src/common_test.h')
| -rw-r--r-- | src/common_test.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/common_test.h b/src/common_test.h index 1fbe718ff8..14a68a2de0 100644 --- a/src/common_test.h +++ b/src/common_test.h @@ -1,6 +1,7 @@ // Copyright 2011 Google Inc. All Rights Reserved. #include <dirent.h> +#include <dlfcn.h> #include <sys/stat.h> #include <sys/types.h> @@ -11,6 +12,9 @@ #include "class_linker.h" #include "dex_file.h" +#include "unicode/uclean.h" +#include "unicode/uvernum.h" + #include "gtest/gtest.h" namespace art { @@ -315,11 +319,20 @@ class ScratchFile { int fd_; }; -class RuntimeTest : public testing::Test { +class CommonTest : public testing::Test { protected: virtual void SetUp() { is_host_ = getenv("ANDROID_BUILD_TOP") != NULL; + if (is_host_) { + // $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; + root += getenv("ANDROID_BUILD_TOP"); + root += "/out/host/linux-x86"; + setenv("ANDROID_ROOT", root.c_str(), 1); + } + android_data_.reset(strdup(is_host_ ? "/tmp/art-data-XXXXXX" : "/sdcard/art-data-XXXXXX")); ASSERT_TRUE(android_data_ != NULL); const char* android_data_modified = mkdtemp(android_data_.get()); @@ -368,6 +381,15 @@ class RuntimeTest : public testing::Test { ASSERT_EQ(0, rmdir_cache_result); int rmdir_data_result = rmdir(android_data_.get()); ASSERT_EQ(0, rmdir_data_result); + + // icu4c has a fixed 10-element array "gCommonICUDataArray". + // If we run > 10 tests, we fill that array and u_setCommonData fails. + // There's a function to clear the array, but it's not public... + typedef void (*IcuCleanupFn)(); + void* sym = dlsym(RTLD_DEFAULT, "u_cleanup_" U_ICU_VERSION_SHORT); + CHECK(sym != NULL); + IcuCleanupFn icu_cleanup_fn = reinterpret_cast<IcuCleanupFn>(sym); + (*icu_cleanup_fn)(); } std::string GetLibCoreDexFileName() { @@ -394,7 +416,7 @@ class RuntimeTest : public testing::Test { bool is_host_; scoped_ptr_malloc<char> android_data_; std::string art_cache_; - scoped_ptr<DexFile> java_lang_dex_file_; + scoped_ptr<const DexFile> java_lang_dex_file_; scoped_ptr<Runtime> runtime_; ClassLinker* class_linker_; }; |