bionic_unit_tests: Remove dependency on libpagemap
Use libmeminfo instead. Bug: 111694435 Test: bionic-unit-tests --gtest_filter=DlExtRelroSharingTest.* Change-Id: Ice217a91a16ee0216354608b2776c0f1e5f65c09 Signed-off-by: Sandeep Patil <sspatil@google.com>
This commit is contained in:
parent
9e20193f9e
commit
e3f39a0efc
2 changed files with 12 additions and 22 deletions
|
@ -390,7 +390,7 @@ cc_test_library {
|
|||
"libdl_test.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
"libpagemap",
|
||||
"libmeminfo",
|
||||
"libziparchive",
|
||||
"libLLVMObject",
|
||||
"libLLVMBitReader",
|
||||
|
@ -475,7 +475,7 @@ cc_defaults {
|
|||
static_libs: [
|
||||
// The order of these libraries matters, do not shuffle them.
|
||||
"libbase",
|
||||
"libpagemap",
|
||||
"libmeminfo",
|
||||
"libziparchive",
|
||||
"libz",
|
||||
"libutils",
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <sys/vfs.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <pagemap/pagemap.h>
|
||||
#include <meminfo/procmeminfo.h>
|
||||
#include <ziparchive/zip_archive.h>
|
||||
|
||||
#include "gtest_globals.h"
|
||||
|
@ -488,33 +488,23 @@ TEST_F(DlExtRelroSharingTest, VerifyMemorySaving) {
|
|||
|
||||
void GetPss(bool shared_relro, const char* lib, const char* relro_file, pid_t pid,
|
||||
size_t* total_pss) {
|
||||
pm_kernel_t* kernel;
|
||||
ASSERT_EQ(0, pm_kernel_create(&kernel));
|
||||
|
||||
pm_process_t* process;
|
||||
ASSERT_EQ(0, pm_process_create(kernel, pid, &process));
|
||||
|
||||
pm_map_t** maps;
|
||||
size_t num_maps;
|
||||
ASSERT_EQ(0, pm_process_maps(process, &maps, &num_maps));
|
||||
android::meminfo::ProcMemInfo proc_mem(pid);
|
||||
const std::vector<android::meminfo::Vma>& maps = proc_mem.Maps();
|
||||
ASSERT_GT(maps.size(), 0UL);
|
||||
|
||||
// Calculate total PSS of the library.
|
||||
*total_pss = 0;
|
||||
bool saw_relro_file = false;
|
||||
for (size_t i = 0; i < num_maps; ++i) {
|
||||
if (android::base::EndsWith(maps[i]->name, lib) || strcmp(maps[i]->name, relro_file) == 0) {
|
||||
if (strcmp(maps[i]->name, relro_file) == 0) saw_relro_file = true;
|
||||
for (auto& vma : maps) {
|
||||
if (android::base::EndsWith(vma.name, lib) || (vma.name == relro_file)) {
|
||||
if (vma.name == relro_file) {
|
||||
saw_relro_file = true;
|
||||
}
|
||||
|
||||
pm_memusage_t usage;
|
||||
ASSERT_EQ(0, pm_map_usage(maps[i], &usage));
|
||||
*total_pss += usage.pss;
|
||||
*total_pss += vma.usage.pss;
|
||||
}
|
||||
}
|
||||
|
||||
free(maps);
|
||||
pm_process_destroy(process);
|
||||
pm_kernel_destroy(kernel);
|
||||
|
||||
if (shared_relro) ASSERT_TRUE(saw_relro_file);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue