summaryrefslogtreecommitdiff
path: root/runtime/gc/heap_verification_test.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2017-04-24 21:55:08 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-04-24 21:55:10 +0000
commit11ce48e83f3bf63672487511576bd54408d096da (patch)
tree0a2bd09cbd99a919f9c22fff1b8d2498c69a66af /runtime/gc/heap_verification_test.cc
parent06660db82d6b3d59080584431addf3797a468a70 (diff)
parent68dda8f20027661c72c8069831cd1cc1c9d46db8 (diff)
Merge "Disable some heap verification test cases for memory tool"
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();