mirror of
https://github.com/reactos/reactos.git
synced 2025-06-26 10:19:51 +00:00
[APITESTS]
- add simple tests for NtFreeVirtualMemory svn path=/trunk/; revision=52642
This commit is contained in:
parent
d309cc3c56
commit
0a8af6df7c
4 changed files with 124 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
add_definitions(-D_DLL -D__USE_CRTIMP)
|
add_definitions(-D_DLL -D__USE_CRTIMP)
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
|
NtFreeVirtualMemory.c
|
||||||
RtlInitializeBitMap.c
|
RtlInitializeBitMap.c
|
||||||
ZwContinue.c
|
ZwContinue.c
|
||||||
testlist.c)
|
testlist.c)
|
||||||
|
|
118
rostests/apitests/ntdll/NtFreeVirtualMemory.c
Normal file
118
rostests/apitests/ntdll/NtFreeVirtualMemory.c
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <wine/test.h>
|
||||||
|
#include <ndk/ntndk.h>
|
||||||
|
|
||||||
|
static void Test_NtFreeVirtualMemory(void)
|
||||||
|
{
|
||||||
|
PVOID Buffer = NULL, Buffer2;
|
||||||
|
SIZE_T Length = PAGE_SIZE;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer,
|
||||||
|
0,
|
||||||
|
&Length,
|
||||||
|
MEM_RESERVE,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed : 0x%08x\n", Status);
|
||||||
|
ok(Length == PAGE_SIZE, "Length mismatch : 0x08x\n", Length);
|
||||||
|
ok(((ULONG_PTR)Buffer % PAGE_SIZE) == 0, "The buffer is not aligned to PAGE_SIZE.\n");
|
||||||
|
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer,
|
||||||
|
&Length,
|
||||||
|
MEM_DECOMMIT);
|
||||||
|
ok(Status == STATUS_SUCCESS, "NtFreeVirtualMemory failed : 0x%08x\n", Status);
|
||||||
|
|
||||||
|
/* Now try to free more than we got */
|
||||||
|
Length++;
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer,
|
||||||
|
&Length,
|
||||||
|
MEM_DECOMMIT);
|
||||||
|
ok(Status == STATUS_UNABLE_TO_FREE_VM, "NtFreeVirtualMemory returned status : 0x%08x\n", Status);
|
||||||
|
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer,
|
||||||
|
&Length,
|
||||||
|
MEM_RELEASE);
|
||||||
|
ok(Status == STATUS_UNABLE_TO_FREE_VM, "NtFreeVirtualMemory returned status : 0x%08x\n", Status);
|
||||||
|
|
||||||
|
/* Free out of bounds from the wrong origin */
|
||||||
|
Length = PAGE_SIZE;
|
||||||
|
Buffer2 = (PVOID)((ULONG_PTR)Buffer+1);
|
||||||
|
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer2,
|
||||||
|
&Length,
|
||||||
|
MEM_DECOMMIT);
|
||||||
|
ok(Status == STATUS_UNABLE_TO_FREE_VM, "NtFreeVirtualMemory returned status : 0x%08x\n", Status);
|
||||||
|
|
||||||
|
Buffer2 = (PVOID)((ULONG_PTR)Buffer+1);
|
||||||
|
Length = PAGE_SIZE;
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer2,
|
||||||
|
&Length,
|
||||||
|
MEM_RELEASE);
|
||||||
|
ok(Status == STATUS_UNABLE_TO_FREE_VM, "NtFreeVirtualMemory returned status : 0x%08x\n", Status);
|
||||||
|
|
||||||
|
/* Same but in bounds */
|
||||||
|
Length = PAGE_SIZE - 1;
|
||||||
|
Buffer2 = (PVOID)((ULONG_PTR)Buffer+1);
|
||||||
|
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer2,
|
||||||
|
&Length,
|
||||||
|
MEM_DECOMMIT);
|
||||||
|
ok(Status == STATUS_SUCCESS, "NtFreeVirtualMemory returned status : 0x%08x\n", Status);
|
||||||
|
ok(Buffer2 == Buffer, "NtFreeVirtualMemory set wrong buffer.\n");
|
||||||
|
ok(Length == PAGE_SIZE, "NtFreeVirtualMemory did not round Length to PAGE_SIZE.\n");
|
||||||
|
|
||||||
|
Buffer2 = (PVOID)((ULONG_PTR)Buffer+1);
|
||||||
|
Length = PAGE_SIZE-1;
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer2,
|
||||||
|
&Length,
|
||||||
|
MEM_RELEASE);
|
||||||
|
ok(Status == STATUS_SUCCESS, "NtFreeVirtualMemory returned status : 0x%08x\n", Status);
|
||||||
|
ok(Buffer2 == Buffer, "NtFreeVirtualMemory set wrong buffer.\n");
|
||||||
|
ok(Length == PAGE_SIZE, "NtFreeVirtualMemory did not round Length to PAGE_SIZE.\n");
|
||||||
|
|
||||||
|
/* Now allocate two pages and try to free them one after the other */
|
||||||
|
Length = 2*PAGE_SIZE;
|
||||||
|
Status = NtAllocateVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer,
|
||||||
|
0,
|
||||||
|
&Length,
|
||||||
|
MEM_RESERVE,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed : 0x%08x\n", Status);
|
||||||
|
ok(Length == 2*PAGE_SIZE, "Length mismatch : 0x08x\n", Length);
|
||||||
|
ok(((ULONG_PTR)Buffer % PAGE_SIZE) == 0, "The buffer is not aligned to PAGE_SIZE.\n");
|
||||||
|
|
||||||
|
Buffer2 = Buffer;
|
||||||
|
Length = PAGE_SIZE;
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer2,
|
||||||
|
&Length,
|
||||||
|
MEM_RELEASE);
|
||||||
|
ok(NT_SUCCESS(Status), "NtAllocateVirtualMemory failed : 0x%08x\n", Status);
|
||||||
|
ok(Length == PAGE_SIZE, "Length mismatch : 0x08x\n", Length);
|
||||||
|
ok(Buffer2 == Buffer, "The buffer is not aligned to PAGE_SIZE.\n");
|
||||||
|
|
||||||
|
Buffer2 = (PVOID)((ULONG_PTR)Buffer+PAGE_SIZE);
|
||||||
|
Length = PAGE_SIZE;
|
||||||
|
Status = NtFreeVirtualMemory(NtCurrentProcess(),
|
||||||
|
&Buffer2,
|
||||||
|
&Length,
|
||||||
|
MEM_RELEASE);
|
||||||
|
ok(NT_SUCCESS(Status), "NtFreeVirtualMemory failed : 0x%08x\n", Status);
|
||||||
|
ok(Length == PAGE_SIZE, "Length mismatch : 0x08x\n", Length);
|
||||||
|
ok(Buffer2 == (PVOID)((ULONG_PTR)Buffer+PAGE_SIZE), "The buffer is not aligned to PAGE_SIZE.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(NtFreeVirtualMemory)
|
||||||
|
{
|
||||||
|
Test_NtFreeVirtualMemory();
|
||||||
|
}
|
|
@ -1,13 +1,15 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||||
<group>
|
<group>
|
||||||
<module name="ntdll_apitest" type="win32cui" installbase="bin" installname="ntdll_apitest.exe">
|
<module name="ntdll_apitest" type="win32cui" installbase="bin" installname="ntdll_apitest.exe"
|
||||||
|
allowwarnings="true">
|
||||||
<include base="ntdll_apitest">.</include>
|
<include base="ntdll_apitest">.</include>
|
||||||
<library>wine</library>
|
<library>wine</library>
|
||||||
<library>ntdll</library>
|
<library>ntdll</library>
|
||||||
<library>pseh</library>
|
<library>pseh</library>
|
||||||
<file>testlist.c</file>
|
<file>testlist.c</file>
|
||||||
|
|
||||||
|
<file>NtFreeVirtualMemory.c</file>
|
||||||
<file>RtlInitializeBitMap.c</file>
|
<file>RtlInitializeBitMap.c</file>
|
||||||
<file>ZwContinue.c</file>
|
<file>ZwContinue.c</file>
|
||||||
<if property="ARCH" value="i386">
|
<if property="ARCH" value="i386">
|
||||||
|
|
|
@ -7,11 +7,13 @@
|
||||||
|
|
||||||
extern void func_RtlInitializeBitMap(void);
|
extern void func_RtlInitializeBitMap(void);
|
||||||
extern void func_ZwContinue(void);
|
extern void func_ZwContinue(void);
|
||||||
|
extern void func_NtFreeVirtualMemory(void);
|
||||||
|
|
||||||
const struct test winetest_testlist[] =
|
const struct test winetest_testlist[] =
|
||||||
{
|
{
|
||||||
{ "RtlInitializeBitMap", func_RtlInitializeBitMap },
|
{ "RtlInitializeBitMap", func_RtlInitializeBitMap },
|
||||||
{ "ZwContinue", func_ZwContinue },
|
{ "ZwContinue", func_ZwContinue },
|
||||||
|
{ "NtFreeVirtualMemory", func_NtFreeVirtualMemory },
|
||||||
|
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue