Loading libmeminfo/libmeminfo_test.cpp +0 −9 Original line number Diff line number Diff line Loading @@ -293,15 +293,6 @@ TEST(TestProcMemInfo, IsSmapsSupportedTest) { EXPECT_EQ(supported, IsSmapsRollupSupported(-1)); } TEST(TestProcMemInfo, SmapsOrRollupReturn) { // if /proc/<pid>/smaps_rollup file exists, .SmapsRollup() must return true; // false otherwise std::string path = ::android::base::StringPrintf("/proc/%d/smaps_rollup", pid); ProcMemInfo proc_mem(pid); MemUsage stats; EXPECT_EQ(!access(path.c_str(), F_OK), proc_mem.SmapsOrRollup(&stats)); } TEST(TestProcMemInfo, SmapsOrRollupTest) { std::string rollup = R"rollup(12c00000-7fe859e000 ---p 00000000 00:00 0 [rollup] Loading libmeminfo/procmeminfo.cpp +10 −4 Original line number Diff line number Diff line Loading @@ -406,9 +406,10 @@ bool SmapsOrRollupFromFile(const std::string& path, MemUsage* stats) { return false; } char line[1024]; char* line = nullptr; size_t line_alloc = 0; stats->clear(); while (fgets(line, sizeof(line), fp.get()) != nullptr) { while (getline(&line, &line_alloc, fp.get()) > 0) { switch (line[0]) { case 'P': if (strncmp(line, "Pss:", 4) == 0) { Loading Loading @@ -441,6 +442,8 @@ bool SmapsOrRollupFromFile(const std::string& path, MemUsage* stats) { } } // free getline() managed buffer free(line); return true; } Loading @@ -450,14 +453,17 @@ bool SmapsOrRollupPssFromFile(const std::string& path, uint64_t* pss) { return false; } *pss = 0; char line[1024]; while (fgets(line, sizeof(line), fp.get()) != nullptr) { char* line = nullptr; size_t line_alloc = 0; while (getline(&line, &line_alloc, fp.get()) > 0) { uint64_t v; if (sscanf(line, "Pss: %" SCNu64 " kB", &v) == 1) { *pss += v; } } // free getline() managed buffer free(line); return true; } Loading Loading
libmeminfo/libmeminfo_test.cpp +0 −9 Original line number Diff line number Diff line Loading @@ -293,15 +293,6 @@ TEST(TestProcMemInfo, IsSmapsSupportedTest) { EXPECT_EQ(supported, IsSmapsRollupSupported(-1)); } TEST(TestProcMemInfo, SmapsOrRollupReturn) { // if /proc/<pid>/smaps_rollup file exists, .SmapsRollup() must return true; // false otherwise std::string path = ::android::base::StringPrintf("/proc/%d/smaps_rollup", pid); ProcMemInfo proc_mem(pid); MemUsage stats; EXPECT_EQ(!access(path.c_str(), F_OK), proc_mem.SmapsOrRollup(&stats)); } TEST(TestProcMemInfo, SmapsOrRollupTest) { std::string rollup = R"rollup(12c00000-7fe859e000 ---p 00000000 00:00 0 [rollup] Loading
libmeminfo/procmeminfo.cpp +10 −4 Original line number Diff line number Diff line Loading @@ -406,9 +406,10 @@ bool SmapsOrRollupFromFile(const std::string& path, MemUsage* stats) { return false; } char line[1024]; char* line = nullptr; size_t line_alloc = 0; stats->clear(); while (fgets(line, sizeof(line), fp.get()) != nullptr) { while (getline(&line, &line_alloc, fp.get()) > 0) { switch (line[0]) { case 'P': if (strncmp(line, "Pss:", 4) == 0) { Loading Loading @@ -441,6 +442,8 @@ bool SmapsOrRollupFromFile(const std::string& path, MemUsage* stats) { } } // free getline() managed buffer free(line); return true; } Loading @@ -450,14 +453,17 @@ bool SmapsOrRollupPssFromFile(const std::string& path, uint64_t* pss) { return false; } *pss = 0; char line[1024]; while (fgets(line, sizeof(line), fp.get()) != nullptr) { char* line = nullptr; size_t line_alloc = 0; while (getline(&line, &line_alloc, fp.get()) > 0) { uint64_t v; if (sscanf(line, "Pss: %" SCNu64 " kB", &v) == 1) { *pss += v; } } // free getline() managed buffer free(line); return true; } Loading