[NFC][scudo] Avoid integer overflow in test

releasePagesToOS may shrink RSS below the value stored on start.
This commit is contained in:
Vitaly Buka 2021-06-03 00:06:45 -07:00
parent 1faff79b7c
commit b40908e639
1 changed files with 4 additions and 4 deletions

View File

@ -37,16 +37,16 @@ TEST(ScudoCommonTest, SKIP_ON_FUCHSIA(ResidentMemorySize)) {
MapPlatformData Data = {};
void *P = map(nullptr, Size, "ResidentMemorySize", 0, &Data);
ASSERT_NE(nullptr, P);
EXPECT_LT(getResidentMemorySize() - OnStart, Threshold);
EXPECT_LT(getResidentMemorySize(), OnStart + Threshold);
memset(P, 1, Size);
EXPECT_GT(getResidentMemorySize() - OnStart, Size - Threshold);
EXPECT_GT(getResidentMemorySize(), OnStart + Size - Threshold);
releasePagesToOS((uptr)P, 0, Size, &Data);
EXPECT_LT(getResidentMemorySize() - OnStart, Threshold);
EXPECT_LT(getResidentMemorySize(), OnStart + Threshold);
memset(P, 1, Size);
EXPECT_GT(getResidentMemorySize() - OnStart, Size - Threshold);
EXPECT_GT(getResidentMemorySize(), OnStart + Size - Threshold);
unmap(P, Size, 0, &Data);
}