diff options
author | Christopher Ferris <cferris@google.com> | 2020-02-12 17:41:01 -0800 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2020-02-12 17:41:01 -0800 |
commit | cce88c0a03c369be98f38594c36c7edb40cefd23 (patch) | |
tree | bcc698c97d16e4df446452dd2ba7636a90846713 /tests/malloc_test.cpp | |
parent | 06ea3cf8830106103c4e3037f19d86ea76969e09 (diff) |
Update malloc_info test for scudo.
Scudo implemented malloc_info for the primary allocator, so add some
small amount of validation.
Test: Ran the malloc_info tests and verified they pass.
Change-Id: Ib7c609e46cc1ed73fa5c042df92fa9b568880f21
Diffstat (limited to 'tests/malloc_test.cpp')
-rw-r--r-- | tests/malloc_test.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp index 6620cdbfd..4da6d3f4d 100644 --- a/tests/malloc_test.cpp +++ b/tests/malloc_test.cpp @@ -387,9 +387,6 @@ TEST(malloc, malloc_info) { ASSERT_STREQ("malloc", root->Name()); std::string version(root->Attribute("version")); if (version == "jemalloc-1") { - // Verify jemalloc version of this data. - ASSERT_STREQ("jemalloc-1", root->Attribute("version")); - auto arena = root->FirstChildElement(); for (; arena != nullptr; arena = arena->NextSiblingElement()) { int val; @@ -418,10 +415,18 @@ TEST(malloc, malloc_info) { } } } + } else if (version == "scudo-1") { + auto element = root->FirstChildElement(); + for (; element != nullptr; element = element->NextSiblingElement()) { + int val; + + ASSERT_STREQ("alloc", element->Name()); + ASSERT_EQ(tinyxml2::XML_SUCCESS, element->QueryIntAttribute("size", &val)); + ASSERT_EQ(tinyxml2::XML_SUCCESS, element->QueryIntAttribute("count", &val)); + } } else { - // Do not verify output for scudo or debug malloc. - ASSERT_TRUE(version == "scudo-1" || version == "debug-malloc-1") - << "Unknown version: " << version; + // Do not verify output for debug malloc. + ASSERT_TRUE(version == "debug-malloc-1") << "Unknown version: " << version; } #endif } @@ -452,9 +457,6 @@ TEST(malloc, malloc_info_matches_mallinfo) { ASSERT_STREQ("malloc", root->Name()); std::string version(root->Attribute("version")); if (version == "jemalloc-1") { - // Verify jemalloc version of this data. - ASSERT_STREQ("jemalloc-1", root->Attribute("version")); - auto arena = root->FirstChildElement(); for (; arena != nullptr; arena = arena->NextSiblingElement()) { int val; @@ -477,10 +479,22 @@ TEST(malloc, malloc_info_matches_mallinfo) { // since malloc_info allocates some memory. EXPECT_LE(mallinfo_before_allocated_bytes, total_allocated_bytes); EXPECT_GE(mallinfo_after_allocated_bytes, total_allocated_bytes); + } else if (version == "scudo-1") { + auto element = root->FirstChildElement(); + for (; element != nullptr; element = element->NextSiblingElement()) { + ASSERT_STREQ("alloc", element->Name()); + int size; + ASSERT_EQ(tinyxml2::XML_SUCCESS, element->QueryIntAttribute("size", &size)); + int count; + ASSERT_EQ(tinyxml2::XML_SUCCESS, element->QueryIntAttribute("count", &count)); + total_allocated_bytes += size * count; + } + // Scudo only gives the information on the primary, so simply make + // sure that the value is non-zero. + EXPECT_NE(0U, total_allocated_bytes); } else { - // Do not verify output for scudo or debug malloc. - ASSERT_TRUE(version == "scudo-1" || version == "debug-malloc-1") - << "Unknown version: " << version; + // Do not verify output for debug malloc. + ASSERT_TRUE(version == "debug-malloc-1") << "Unknown version: " << version; } #endif } |