[KMTESTS]
authorJérôme Gardou <jerome.gardou@reactos.org>
Mon, 1 Sep 2014 22:41:36 +0000 (22:41 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Mon, 1 Sep 2014 22:41:36 +0000 (22:41 +0000)
 - Test what happens to the 'base' of memory allocated with ZwAllocateVirtualMemory
 - Fix some tests according to w2k3sp2 behaviour.
Thanks Amine for testing ;-)

svn path=/trunk/; revision=64028

rostests/kmtests/ntos_mm/ZwAllocateVirtualMemory.c

index 785cb51..52e973d 100644 (file)
@@ -31,8 +31,13 @@ typedef struct _TEST_CONTEXT
 
 #define ALLOC_MEMORY_WITH_FREE(ProcessHandle, BaseAddress, ZeroBits, RegionSize, AllocationType, Protect, RetStatus, FreeStatus)   \
     do {                                                                                                                   \
 
 #define ALLOC_MEMORY_WITH_FREE(ProcessHandle, BaseAddress, ZeroBits, RegionSize, AllocationType, Protect, RetStatus, FreeStatus)   \
     do {                                                                                                                   \
+        PVOID __BaseSave = BaseAddress;                                                                                    \
         Status = ZwAllocateVirtualMemory(ProcessHandle, &BaseAddress, ZeroBits, &RegionSize, AllocationType, Protect);     \
         ok_eq_hex(Status, RetStatus);                                                                                      \
         Status = ZwAllocateVirtualMemory(ProcessHandle, &BaseAddress, ZeroBits, &RegionSize, AllocationType, Protect);     \
         ok_eq_hex(Status, RetStatus);                                                                                      \
+        if (__BaseSave != NULL)                                                                                            \
+            ok_eq_pointer(BaseAddress, __BaseSave);                                                                        \
+        else if (!NT_SUCCESS(Status))                                                                                      \
+            ok_eq_pointer(BaseAddress, NULL);                                                                              \
         RegionSize = 0;                                                                                                    \
         Status = ZwFreeVirtualMemory(ProcessHandle, &BaseAddress, &RegionSize, MEM_RELEASE);                               \
         if (FreeStatus != IGNORE) ok_eq_hex(Status, FreeStatus);                                                           \
         RegionSize = 0;                                                                                                    \
         Status = ZwFreeVirtualMemory(ProcessHandle, &BaseAddress, &RegionSize, MEM_RELEASE);                               \
         if (FreeStatus != IGNORE) ok_eq_hex(Status, FreeStatus);                                                           \
@@ -104,7 +109,7 @@ SimpleErrorChecks(VOID)
 
     //BASE ADDRESS TESTS
     Base = (PVOID)0x00567A20;
 
     //BASE ADDRESS TESTS
     Base = (PVOID)0x00567A20;
-    ALLOC_MEMORY_WITH_FREE(NtCurrentProcess(), Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_CONFLICTING_ADDRESSES, STATUS_FREE_VM_NOT_AT_BASE);
+    ALLOC_MEMORY_WITH_FREE(NtCurrentProcess(), Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_CONFLICTING_ADDRESSES, STATUS_UNABLE_TO_DELETE_SECTION);
 
     Base = (PVOID) 0x60000000;
     ALLOC_MEMORY_WITH_FREE(NtCurrentProcess(), Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
 
     Base = (PVOID) 0x60000000;
     ALLOC_MEMORY_WITH_FREE(NtCurrentProcess(), Base, 0, RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
@@ -501,7 +506,7 @@ START_TEST(ZwAllocateVirtualMemory)
 
     Status = STATUS_SUCCESS;
     Status = StressTesting(MEM_COMMIT);
 
     Status = STATUS_SUCCESS;
     Status = StressTesting(MEM_COMMIT);
-    ok_eq_hex(Status, STATUS_COMMITMENT_LIMIT);
+    ok_eq_hex(Status, STATUS_NO_MEMORY);
 
     SystemProcessTest();
 }
 
     SystemProcessTest();
 }