forked from OSchip/llvm-project
[NFC][scudo] Small test cleanup
Fixing issues raised on D102979 review. Reviewed By: cryptoad Differential Revision: https://reviews.llvm.org/D102994
This commit is contained in:
parent
095e91c973
commit
6435ca4e2b
|
@ -1,4 +1,4 @@
|
||||||
//===-- common_test.cpp ---------------------------------------*- C++ -*-===//
|
//===-- common_test.cpp -----------------------------------------*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
@ -16,6 +16,8 @@
|
||||||
namespace scudo {
|
namespace scudo {
|
||||||
|
|
||||||
static uptr getResidentMemorySize() {
|
static uptr getResidentMemorySize() {
|
||||||
|
if (!SCUDO_LINUX)
|
||||||
|
UNREACHABLE("Not implemented!");
|
||||||
uptr Size;
|
uptr Size;
|
||||||
uptr Resident;
|
uptr Resident;
|
||||||
std::ifstream IFS("/proc/self/statm");
|
std::ifstream IFS("/proc/self/statm");
|
||||||
|
@ -32,7 +34,7 @@ TEST(ScudoCommonTest, SKIP_ON_FUCHSIA(ResidentMemorySize)) {
|
||||||
const uptr Size = 1ull << 30;
|
const uptr Size = 1ull << 30;
|
||||||
const uptr Threshold = Size >> 3;
|
const uptr Threshold = Size >> 3;
|
||||||
|
|
||||||
MapPlatformData Data;
|
MapPlatformData Data = {};
|
||||||
uptr *P = reinterpret_cast<uptr *>(
|
uptr *P = reinterpret_cast<uptr *>(
|
||||||
map(nullptr, Size, "ResidentMemorySize", 0, &Data));
|
map(nullptr, Size, "ResidentMemorySize", 0, &Data));
|
||||||
const uptr N = Size / sizeof(*P);
|
const uptr N = Size / sizeof(*P);
|
||||||
|
@ -47,12 +49,11 @@ TEST(ScudoCommonTest, SKIP_ON_FUCHSIA(ResidentMemorySize)) {
|
||||||
releasePagesToOS((uptr)P, 0, Size, &Data);
|
releasePagesToOS((uptr)P, 0, Size, &Data);
|
||||||
EXPECT_EQ(std::count(P, P + N, 0), N);
|
EXPECT_EQ(std::count(P, P + N, 0), N);
|
||||||
// FIXME: does not work with QEMU-user.
|
// FIXME: does not work with QEMU-user.
|
||||||
// EXPECT_LT(getResidentMemorySize() - OnStart, Threshold) << OnStart << " "
|
// EXPECT_LT(getResidentMemorySize() - OnStart, Threshold);
|
||||||
// << getResidentMemorySize();
|
|
||||||
|
|
||||||
memset(P, 1, Size);
|
memset(P, 1, Size);
|
||||||
EXPECT_EQ(std::count(P, P + N, 0), 0);
|
EXPECT_EQ(std::count(P, P + N, 0), 0);
|
||||||
EXPECT_LT(getResidentMemorySize() - Size, Threshold);
|
EXPECT_LT(getResidentMemorySize() - Size, Threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace scudo
|
} // namespace scudo
|
||||||
|
|
Loading…
Reference in New Issue