Akihiro Sagawa : ntdll/tests: Add more tests if we have real VM counters.

Alexandre Julliard julliard at winehq.org
Mon Jul 3 15:56:47 CDT 2017


Module: wine
Branch: master
Commit: 7c06d99e83b1df153d307332def29c299ebe2eb2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7c06d99e83b1df153d307332def29c299ebe2eb2

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Mon Jul  3 23:24:35 2017 +0900

ntdll/tests: Add more tests if we have real VM counters.

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/info.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index f1de206..e90e4a7 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -1069,6 +1069,9 @@ static void test_query_process_vm(void)
     VM_COUNTERS pvi;
     ULONG old_size = FIELD_OFFSET(VM_COUNTERS,PrivatePageCount);
     HANDLE process;
+    SIZE_T prev_size;
+    const SIZE_T alloc_size = 16 * 1024 * 1024;
+    void *ptr;
 
     status = pNtQueryInformationProcess(NULL, ProcessVmCounters, NULL, sizeof(pvi), NULL);
     ok( status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_HANDLE,
@@ -1119,6 +1122,47 @@ static void test_query_process_vm(void)
     ok( pvi.PagefileUsage > 0, "Expected a PagefileUsage > 0\n");
 
     CloseHandle(process);
+
+    /* Check if we have real counters */
+    status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
+    ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
+    prev_size = pvi.VirtualSize;
+    if (winetest_debug > 1)
+        dump_vm_counters("VM counters before VirtualAlloc", &pvi);
+    ptr = VirtualAlloc(NULL, alloc_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
+    ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError());
+    status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
+    ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
+    if (winetest_debug > 1)
+        dump_vm_counters("VM counters after VirtualAlloc", &pvi);
+    todo_wine ok( pvi.VirtualSize >= prev_size + alloc_size,
+        "Expected to be greater than %lu, got %lu\n", prev_size + alloc_size, pvi.VirtualSize);
+    VirtualFree( ptr, 0, MEM_RELEASE);
+
+    status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
+    ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
+    prev_size = pvi.VirtualSize;
+    if (winetest_debug > 1)
+        dump_vm_counters("VM counters before VirtualAlloc", &pvi);
+    ptr = VirtualAlloc(NULL, alloc_size, MEM_RESERVE, PAGE_READWRITE);
+    ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError());
+    status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
+    ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
+    if (winetest_debug > 1)
+        dump_vm_counters("VM counters after VirtualAlloc(MEM_RESERVE)", &pvi);
+    todo_wine ok( pvi.VirtualSize >= prev_size + alloc_size,
+        "Expected to be greater than %lu, got %lu\n", prev_size + alloc_size, pvi.VirtualSize);
+    prev_size = pvi.VirtualSize;
+
+    ptr = VirtualAlloc(ptr, alloc_size, MEM_COMMIT, PAGE_READWRITE);
+    ok( ptr != NULL, "VirtualAlloc failed, err %u\n", GetLastError());
+    status = pNtQueryInformationProcess(GetCurrentProcess(), ProcessVmCounters, &pvi, sizeof(pvi), NULL);
+    ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
+    if (winetest_debug > 1)
+        dump_vm_counters("VM counters after VirtualAlloc(MEM_COMMIT)", &pvi);
+    ok( pvi.VirtualSize == prev_size,
+        "Expected to equal to %lu, got %lu\n", prev_size, pvi.VirtualSize);
+    VirtualFree( ptr, 0, MEM_RELEASE);
 }
 
 static void test_query_process_io(void)




More information about the wine-cvs mailing list