From 68dda8f20027661c72c8069831cd1cc1c9d46db8 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Mon, 24 Apr 2017 10:06:15 -0700 Subject: 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 --- runtime/gc/heap_verification_test.cc | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'runtime/gc/heap_verification_test.cc') 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(&uint_klass))); } -TEST_F(VerificationTest, IsValidClass) { +TEST_F(VerificationTest, IsValidClassOrNotInHeap) { ScopedObjectAccess soa(Thread::Current()); VariableSizedHandleScope hs(soa.Self()); Handle string( @@ -72,14 +73,35 @@ TEST_F(VerificationTest, IsValidClass) { EXPECT_FALSE(v->IsValidClass(reinterpret_cast(1))); EXPECT_FALSE(v->IsValidClass(reinterpret_cast(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 string( + hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), "test"))); + const Verification* const v = Runtime::Current()->GetHeap()->GetVerification(); const uintptr_t uint_klass = reinterpret_cast(string->GetClass()); EXPECT_FALSE(v->IsValidClass(reinterpret_cast(uint_klass - kObjectAlignment))); EXPECT_FALSE(v->IsValidClass(reinterpret_cast(&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(1), "obj"); + LOG(INFO) << v->DumpObjectInfo(reinterpret_cast(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> arr( hs.NewHandle(AllocObjectArray(soa.Self(), 256))); const Verification* const v = runtime->GetHeap()->GetVerification(); - LOG(INFO) << v->DumpObjectInfo(reinterpret_cast(1), "obj"); - LOG(INFO) << v->DumpObjectInfo(reinterpret_cast(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(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(); -- cgit v1.2.3-59-g8ed1b