ntdll/tests: Add some tests for creating custom heaps.
This commit is contained in:
parent
73647adaef
commit
a8f5b292c3
1 changed files with 72 additions and 0 deletions
|
@ -3565,6 +3565,77 @@ static void test_RtlDestroyHeap(void)
|
|||
RtlRemoveVectoredExceptionHandler( handler );
|
||||
}
|
||||
|
||||
struct commit_routine_context
|
||||
{
|
||||
void *base;
|
||||
SIZE_T size;
|
||||
};
|
||||
|
||||
static struct commit_routine_context commit_context;
|
||||
|
||||
static NTSTATUS NTAPI test_commit_routine(void *base, void **address, SIZE_T *size)
|
||||
{
|
||||
commit_context.base = base;
|
||||
commit_context.size = *size;
|
||||
|
||||
return VirtualAlloc(*address, *size, MEM_COMMIT, PAGE_READWRITE) ? 0 : STATUS_ASSERTION_FAILURE;
|
||||
}
|
||||
|
||||
static void test_RtlCreateHeap(void)
|
||||
{
|
||||
void *ptr, *base, *reserve;
|
||||
RTL_HEAP_PARAMETERS params;
|
||||
HANDLE heap;
|
||||
BOOL ret;
|
||||
|
||||
heap = RtlCreateHeap(0, NULL, 0, 0, NULL, NULL);
|
||||
ok(!!heap, "Failed to create a heap.\n");
|
||||
RtlDestroyHeap(heap);
|
||||
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
heap = RtlCreateHeap(0, NULL, 0, 0, NULL, ¶ms);
|
||||
ok(!!heap, "Failed to create a heap.\n");
|
||||
RtlDestroyHeap(heap);
|
||||
|
||||
params.Length = 1;
|
||||
heap = RtlCreateHeap(0, NULL, 0, 0, NULL, ¶ms);
|
||||
ok(!!heap, "Failed to create a heap.\n");
|
||||
RtlDestroyHeap(heap);
|
||||
|
||||
params.Length = sizeof(params);
|
||||
params.CommitRoutine = test_commit_routine;
|
||||
params.InitialCommit = 0x1000;
|
||||
params.InitialReserve = 0x10000;
|
||||
|
||||
heap = RtlCreateHeap(0, NULL, 0, 0, NULL, ¶ms);
|
||||
todo_wine
|
||||
ok(!heap, "Unexpected heap.\n");
|
||||
if (heap)
|
||||
RtlDestroyHeap(heap);
|
||||
|
||||
reserve = VirtualAlloc(NULL, 0x10000, MEM_RESERVE, PAGE_READWRITE);
|
||||
base = VirtualAlloc(reserve, 0x1000, MEM_COMMIT, PAGE_READWRITE);
|
||||
ok(!!base, "Unexpected pointer.\n");
|
||||
|
||||
heap = RtlCreateHeap(0, base, 0, 0, NULL, ¶ms);
|
||||
ok(!!heap, "Unexpected heap.\n");
|
||||
|
||||
/* Using block size above initially committed size to trigger
|
||||
new allocation via user callback. */
|
||||
ptr = RtlAllocateHeap(heap, 0, 0x4000);
|
||||
ok(!!ptr, "Failed to allocate a block.\n");
|
||||
todo_wine
|
||||
ok(commit_context.base == base, "Unexpected base %p.\n", commit_context.base);
|
||||
todo_wine
|
||||
ok(!!commit_context.size, "Unexpected allocation size.\n");
|
||||
RtlFreeHeap(heap, 0, ptr);
|
||||
RtlDestroyHeap(heap);
|
||||
|
||||
ret = VirtualFree(reserve, 0, MEM_RELEASE);
|
||||
todo_wine
|
||||
ok(ret, "Unexpected return value.\n");
|
||||
}
|
||||
|
||||
static void test_RtlFirstFreeAce(void)
|
||||
{
|
||||
PACL acl;
|
||||
|
@ -3711,6 +3782,7 @@ START_TEST(rtl)
|
|||
test_LdrRegisterDllNotification();
|
||||
test_DbgPrint();
|
||||
test_RtlDestroyHeap();
|
||||
test_RtlCreateHeap();
|
||||
test_RtlFirstFreeAce();
|
||||
test_RtlInitializeSid();
|
||||
test_RtlValidSecurityDescriptor();
|
||||
|
|
Loading…
Add table
Reference in a new issue