Revert "test: Remove icu cleanup hack"
This reverts commit d4b294c14bd4e1654b276b931ee035b895b8e6cd.
Without this hack, the gCommonICUDataArray seems to
non-deterministically accumulate entries, and sometimes overflows,
causing test failures.
Bug: 31469648
Test: gdb /data/nativetest64/art/arm64/art_runtime_compiler_tests/reflection_test
Change-Id: Ie5a5b7b957de79758a227bfd2919b4cd0155cde8
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 7234952..5bc4e88 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -409,6 +409,15 @@
TearDownAndroidData(android_data_, true);
dalvik_cache_.clear();
+ // 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 != nullptr) << dlerror();
+ IcuCleanupFn icu_cleanup_fn = reinterpret_cast<IcuCleanupFn>(sym);
+ (*icu_cleanup_fn)();
+
Runtime::Current()->GetHeap()->VerifyHeap(); // Check for heap corruption after the test
}