https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e5fc2b4ce3962145feadce...
commit e5fc2b4ce3962145feadce5a6f17fe454ff0f85e Author: Thomas Faber thomas.faber@reactos.org AuthorDate: Sun Sep 30 16:09:26 2018 +0200 Commit: Thomas Faber thomas.faber@reactos.org CommitDate: Wed Jan 9 08:18:41 2019 +0100
[KMTESTS:EX] Add a test that triggers big pool expansion. CORE-15051 --- modules/rostests/kmtests/ntos_ex/ExPools.c | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
diff --git a/modules/rostests/kmtests/ntos_ex/ExPools.c b/modules/rostests/kmtests/ntos_ex/ExPools.c index 9b67eeda82..5ed7f4b09f 100644 --- a/modules/rostests/kmtests/ntos_ex/ExPools.c +++ b/modules/rostests/kmtests/ntos_ex/ExPools.c @@ -264,10 +264,52 @@ TestPoolQuota(VOID) KmtEndSeh(STATUS_SUCCESS); }
+static +VOID +TestBigPoolExpansion(VOID) +{ + POOL_TYPE PoolType; + PVOID *BigAllocations; + const ULONG MaxAllocations = 1024 * 128; + ULONG NumAllocations; + + for (PoolType = NonPagedPool; PoolType <= PagedPool; PoolType++) + { + BigAllocations = ExAllocatePoolWithTag(PoolType, + MaxAllocations * sizeof(*BigAllocations), + 'ABmK'); + + /* Allocate a lot of pages (== big pool allocations) */ + for (NumAllocations = 0; NumAllocations < MaxAllocations; NumAllocations++) + { + BigAllocations[NumAllocations] = ExAllocatePoolWithTag(PoolType, + PAGE_SIZE, + 'aPmK'); + if (BigAllocations[NumAllocations] == NULL) + { + NumAllocations--; + break; + } + } + + trace("Got %lu allocations for PoolType %d\n", NumAllocations, PoolType); + + /* Free them */ + for (; NumAllocations < MaxAllocations; NumAllocations--) + { + ASSERT(BigAllocations[NumAllocations] != NULL); + ExFreePoolWithTag(BigAllocations[NumAllocations], + 'aPmK'); + } + ExFreePoolWithTag(BigAllocations, 'ABmK'); + } +} + START_TEST(ExPools) { PoolsTest(); PoolsCorruption(); TestPoolTags(); TestPoolQuota(); + TestBigPoolExpansion(); }