Commit 9f6146f1 authored by Wez's avatar Wez Committed by Commit Bot

Clean up preconditions for PartitionAlloc large-memory tests.

- Tweak IsLargeMemoryDevice() to treat devices with _almost_ 2GiB of
  available memory as "large", to allow for e.g. some memory being
  reserved for use by devices.
- ASSERT, rather than EXPECT, that SetAddressSpaceLimit() succeeds,
  so that the test will fail fast rather than trying to run, and
  proceeding to OOM the host system.

Bug: 779645
Change-Id: I12eb4cabda28b2fbdb7ef8c5cdee9fb4a60c2781
Reviewed-on: https://chromium-review.googlesource.com/744300Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512845}
parent 3ccc88cb
......@@ -36,7 +36,10 @@ std::unique_ptr<T[]> WrapArrayUnique(T* ptr) {
const size_t kTestMaxAllocation = 4096;
bool IsLargeMemoryDevice() {
return base::SysInfo::AmountOfPhysicalMemory() >= 2LL * 1024 * 1024 * 1024;
// Treat any device with 2GiB or more of physical memory as a "large memory
// device". We check for slightly less than 2GiB so that devices with a small
// amount of memory not accessible to the OS still count as "large".
return base::SysInfo::AmountOfPhysicalMemory() >= 2040LL * 1024 * 1024;
}
bool SetAddressSpaceLimit() {
......@@ -178,7 +181,7 @@ class PartitionAllocTest : public testing::Test {
return;
}
EXPECT_TRUE(SetAddressSpaceLimit());
ASSERT_TRUE(SetAddressSpaceLimit());
// Work out the number of allocations for 6 GB of memory.
const int numAllocations = (6 * 1024 * 1024) / (allocSize / 1024);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment