summaryrefslogtreecommitdiff
path: root/runtime/gc/heap_verification_test.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2017-04-24 10:06:15 -0700
committer Mathieu Chartier <mathieuc@google.com> 2017-04-24 13:13:28 -0700
commit68dda8f20027661c72c8069831cd1cc1c9d46db8 (patch)
tree2cbadf106779972df1036cbdb036eb0f26feee1b /runtime/gc/heap_verification_test.cc
parent5df5acf4dc296d22a868a7c5010a7f5cf2350539 (diff)
Disable some heap verification test cases for memory tool
These test cases may read from red zones for the memory tool case. Also split up some of the test cases to minimize how many tests need to be disabled. Bug: 37187694 Bug: 12687968 Test: ART_USE_READ_BARRIER=false mm test-art-host-valgrind-gtest -j20 Change-Id: I93958d0d3e42d2d3a2b4a7d2c6aa2e17559cb49c
Diffstat (limited to 'runtime/gc/heap_verification_test.cc')
-rw-r--r--runtime/gc/heap_verification_test.cc32
1 files changed, 26 insertions, 6 deletions
diff --git a/runtime/gc/heap_verification_test.cc b/runtime/gc/heap_verification_test.cc
index c8233e37ab..2cdfc16f62 100644
--- a/runtime/gc/heap_verification_test.cc
+++ b/runtime/gc/heap_verification_test.cc
@@ -16,6 +16,7 @@
#include "common_runtime_test.h"
+#include "base/memory_tool.h"
#include "class_linker.h"
#include "handle_scope-inl.h"
#include "mirror/object-inl.h"
@@ -63,7 +64,7 @@ TEST_F(VerificationTest, IsValidHeapObjectAddress) {
reinterpret_cast<const void*>(&uint_klass)));
}
-TEST_F(VerificationTest, IsValidClass) {
+TEST_F(VerificationTest, IsValidClassOrNotInHeap) {
ScopedObjectAccess soa(Thread::Current());
VariableSizedHandleScope hs(soa.Self());
Handle<mirror::String> string(
@@ -72,14 +73,35 @@ TEST_F(VerificationTest, IsValidClass) {
EXPECT_FALSE(v->IsValidClass(reinterpret_cast<const void*>(1)));
EXPECT_FALSE(v->IsValidClass(reinterpret_cast<const void*>(4)));
EXPECT_FALSE(v->IsValidClass(nullptr));
- EXPECT_FALSE(v->IsValidClass(string.Get()));
EXPECT_TRUE(v->IsValidClass(string->GetClass()));
+ EXPECT_FALSE(v->IsValidClass(string.Get()));
+}
+
+TEST_F(VerificationTest, IsValidClassInHeap) {
+ TEST_DISABLED_FOR_MEMORY_TOOL();
+ ScopedObjectAccess soa(Thread::Current());
+ VariableSizedHandleScope hs(soa.Self());
+ Handle<mirror::String> string(
+ hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), "test")));
+ const Verification* const v = Runtime::Current()->GetHeap()->GetVerification();
const uintptr_t uint_klass = reinterpret_cast<uintptr_t>(string->GetClass());
EXPECT_FALSE(v->IsValidClass(reinterpret_cast<const void*>(uint_klass - kObjectAlignment)));
EXPECT_FALSE(v->IsValidClass(reinterpret_cast<const void*>(&uint_klass)));
}
-TEST_F(VerificationTest, DumpObjectInfo) {
+TEST_F(VerificationTest, DumpInvalidObjectInfo) {
+ ScopedLogSeverity sls(LogSeverity::INFO);
+ ScopedObjectAccess soa(Thread::Current());
+ Runtime* const runtime = Runtime::Current();
+ VariableSizedHandleScope hs(soa.Self());
+ const Verification* const v = runtime->GetHeap()->GetVerification();
+ LOG(INFO) << v->DumpObjectInfo(reinterpret_cast<const void*>(1), "obj");
+ LOG(INFO) << v->DumpObjectInfo(reinterpret_cast<const void*>(4), "obj");
+ LOG(INFO) << v->DumpObjectInfo(nullptr, "obj");
+}
+
+TEST_F(VerificationTest, DumpValidObjectInfo) {
+ TEST_DISABLED_FOR_MEMORY_TOOL();
ScopedLogSeverity sls(LogSeverity::INFO);
ScopedObjectAccess soa(Thread::Current());
Runtime* const runtime = Runtime::Current();
@@ -89,9 +111,6 @@ TEST_F(VerificationTest, DumpObjectInfo) {
Handle<mirror::ObjectArray<mirror::Object>> arr(
hs.NewHandle(AllocObjectArray<mirror::Object>(soa.Self(), 256)));
const Verification* const v = runtime->GetHeap()->GetVerification();
- LOG(INFO) << v->DumpObjectInfo(reinterpret_cast<const void*>(1), "obj");
- LOG(INFO) << v->DumpObjectInfo(reinterpret_cast<const void*>(4), "obj");
- LOG(INFO) << v->DumpObjectInfo(nullptr, "obj");
LOG(INFO) << v->DumpObjectInfo(string.Get(), "test");
LOG(INFO) << v->DumpObjectInfo(string->GetClass(), "obj");
const uintptr_t uint_klass = reinterpret_cast<uintptr_t>(string->GetClass());
@@ -102,6 +121,7 @@ TEST_F(VerificationTest, DumpObjectInfo) {
}
TEST_F(VerificationTest, LogHeapCorruption) {
+ TEST_DISABLED_FOR_MEMORY_TOOL();
ScopedLogSeverity sls(LogSeverity::INFO);
ScopedObjectAccess soa(Thread::Current());
Runtime* const runtime = Runtime::Current();