diff options
| author | 2014-08-06 23:35:04 +0000 | |
|---|---|---|
| committer | 2014-08-05 00:30:25 +0000 | |
| commit | 4d110c25bbcc3ed4603e94968ee02db7b2c9db8c (patch) | |
| tree | 9a9342e2924012f907c360c9844429b1596c2a9e /runtime/common_runtime_test.cc | |
| parent | 68b84b78c72824667b66e6b93caab6abf3736f35 (diff) | |
| parent | 7747c8de402f64e3009ca3bcccebddbb70f617ee (diff) | |
Merge "ART: Remove test files after test"
Diffstat (limited to 'runtime/common_runtime_test.cc')
| -rw-r--r-- | runtime/common_runtime_test.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index 997236200c..6f3b3a33d5 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -95,7 +95,7 @@ void ScratchFile::Unlink() { CommonRuntimeTest::CommonRuntimeTest() {} CommonRuntimeTest::~CommonRuntimeTest() {} -void CommonRuntimeTest::SetEnvironmentVariables(std::string& android_data) { +void CommonRuntimeTest::SetUpAndroidRoot() { if (IsHost()) { // $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. @@ -135,7 +135,9 @@ void CommonRuntimeTest::SetEnvironmentVariables(std::string& android_data) { setenv("ANDROID_HOST_OUT", getenv("ANDROID_ROOT"), 1); } } +} +void CommonRuntimeTest::SetUpAndroidData(std::string& android_data) { // On target, Cannot use /mnt/sdcard because it is mounted noexec, so use subdir of dalvik-cache if (IsHost()) { const char* tmpdir = getenv("TMPDIR"); @@ -154,6 +156,15 @@ void CommonRuntimeTest::SetEnvironmentVariables(std::string& android_data) { setenv("ANDROID_DATA", android_data.c_str(), 1); } +void CommonRuntimeTest::TearDownAndroidData(const std::string& android_data, bool fail_on_error) { + if (fail_on_error) { + ASSERT_EQ(rmdir(android_data.c_str()), 0); + } else { + rmdir(android_data.c_str()); + } +} + + const DexFile* CommonRuntimeTest::LoadExpectSingleDexFile(const char* location) { std::vector<const DexFile*> dex_files; std::string error_msg; @@ -167,7 +178,8 @@ const DexFile* CommonRuntimeTest::LoadExpectSingleDexFile(const char* location) } void CommonRuntimeTest::SetUp() { - SetEnvironmentVariables(android_data_); + SetUpAndroidRoot(); + SetUpAndroidData(android_data_); dalvik_cache_.append(android_data_.c_str()); dalvik_cache_.append("/dalvik-cache"); int mkdir_result = mkdir(dalvik_cache_.c_str(), 0700); @@ -211,7 +223,6 @@ void CommonRuntimeTest::SetUp() { runtime_->GetHeap()->VerifyHeap(); // Check for heap corruption before the test } - void CommonRuntimeTest::ClearDirectory(const char* dirpath) { ASSERT_TRUE(dirpath != nullptr); DIR* dir = opendir(dirpath); @@ -245,8 +256,7 @@ void CommonRuntimeTest::TearDown() { ClearDirectory(dalvik_cache_.c_str()); int rmdir_cache_result = rmdir(dalvik_cache_.c_str()); ASSERT_EQ(0, rmdir_cache_result); - int rmdir_data_result = rmdir(android_data_.c_str()); - ASSERT_EQ(0, rmdir_data_result); + TearDownAndroidData(android_data_, true); // icu4c has a fixed 10-element array "gCommonICUDataArray". // If we run > 10 tests, we fill that array and u_setCommonData fails. |