https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4a7f3bdb4e7e8f5419f6586aba1708aee2393f04

commit 4a7f3bdb4e7e8f5419f6586aba1708aee2393f04
Author:     Amine Khaldi <[email protected]>
AuthorDate: Sun Jan 21 22:43:04 2018 +0100
Commit:     Amine Khaldi <[email protected]>
CommitDate: Sun Jan 21 22:43:04 2018 +0100

    [PSAPI_WINETEST] Sync with Wine 3.0. CORE-14225
---
 modules/rostests/winetests/psapi/psapi_main.c | 78 +++++++++++++--------------
 1 file changed, 38 insertions(+), 40 deletions(-)

diff --git a/modules/rostests/winetests/psapi/psapi_main.c 
b/modules/rostests/winetests/psapi/psapi_main.c
index b02c7a0f06..a8fe243a73 100644
--- a/modules/rostests/winetests/psapi/psapi_main.c
+++ b/modules/rostests/winetests/psapi/psapi_main.c
@@ -107,7 +107,7 @@ static void test_EnumProcesses(void)
 
 static void test_EnumProcessModules(void)
 {
-    HMODULE hMod = GetModuleHandleA(NULL);
+    HMODULE hMod;
     DWORD ret, cbNeeded = 0xdeadbeef;
 
     SetLastError(0xdeadbeef);
@@ -119,14 +119,18 @@ static void test_EnumProcessModules(void)
     ok(GetLastError() == ERROR_ACCESS_DENIED, "expected 
error=ERROR_ACCESS_DENIED but got %d\n", GetLastError());
 
     SetLastError(0xdeadbeef);
+    hMod = (void *)0xdeadbeef;
     ret = pEnumProcessModules(hpQI, &hMod, sizeof(HMODULE), NULL);
     ok(!ret, "succeeded\n");
     ok(GetLastError() == ERROR_ACCESS_DENIED, "expected 
error=ERROR_ACCESS_DENIED but got %d\n", GetLastError());
 
     SetLastError(0xdeadbeef);
+    hMod = (void *)0xdeadbeef;
     ret = pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), NULL);
     ok(!ret, "succeeded\n");
     ok(GetLastError() == ERROR_NOACCESS, "expected error=ERROR_NOACCESS but 
got %d\n", GetLastError());
+    todo_wine ok(hMod == GetModuleHandleA(NULL),
+       "hMod=%p GetModuleHandleA(NULL)=%p\n", hMod, GetModuleHandleA(NULL));
 
     SetLastError(0xdeadbeef);
     ret = pEnumProcessModules(hpQV, NULL, 0, &cbNeeded);
@@ -138,9 +142,9 @@ static void test_EnumProcessModules(void)
     ok(GetLastError() == ERROR_NOACCESS, "expected error=ERROR_NOACCESS but 
got %d\n", GetLastError());
 
     SetLastError(0xdeadbeef);
+    hMod = (void *)0xdeadbeef;
     ret = pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), &cbNeeded);
-    if(ret != 1)
-        return;
+    ok(ret == 1, "got %d, failed with %d\n", ret, GetLastError());
     ok(hMod == GetModuleHandleA(NULL),
        "hMod=%p GetModuleHandleA(NULL)=%p\n", hMod, GetModuleHandleA(NULL));
     ok(cbNeeded % sizeof(hMod) == 0, "not a multiple of sizeof(HMODULE) 
cbNeeded=%d\n", cbNeeded);
@@ -149,7 +153,6 @@ static void test_EnumProcessModules(void)
 static void test_GetModuleInformation(void)
 {
     HMODULE hMod = GetModuleHandleA(NULL);
-    DWORD *tmp, counter = 0;
     MODULEINFO info;
     DWORD ret;
 
@@ -169,21 +172,10 @@ static void test_GetModuleInformation(void)
     pGetModuleInformation(hpQV, hMod, &info, sizeof(info)-1);
     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected 
error=ERROR_INSUFFICIENT_BUFFER but got %d\n", GetLastError());
 
+    SetLastError(0xdeadbeef);
     ret = pGetModuleInformation(hpQV, hMod, &info, sizeof(info));
     ok(ret == 1, "failed with %d\n", GetLastError());
     ok(info.lpBaseOfDll == hMod, "lpBaseOfDll=%p hMod=%p\n", info.lpBaseOfDll, 
hMod);
-
-    hMod = LoadLibraryA("shell32.dll");
-    ok(hMod != NULL, "Failed to load shell32.dll, error: %u\n", 
GetLastError());
-
-    ret = pGetModuleInformation(hpQV, hMod, &info, sizeof(info));
-    ok(ret == 1, "failed with %d\n", GetLastError());
-    info.SizeOfImage /= sizeof(DWORD);
-    for (tmp = (DWORD *)hMod; info.SizeOfImage; info.SizeOfImage--)
-        counter ^= *tmp++;
-    trace("xor of shell32: %08x\n", counter);
-
-    FreeLibrary(hMod);
 }
 
 static BOOL check_with_margin(SIZE_T perf, SIZE_T sysperf, int margin)
@@ -234,19 +226,19 @@ static void test_GetPerformanceInfo(void)
         ok(check_with_margin(info.CommitPeak,           
sys_performance_info->PeakCommitment,       32),
            "expected approximately %ld but got %d\n", info.CommitPeak, 
sys_performance_info->PeakCommitment);
 
-        ok(check_with_margin(info.PhysicalAvailable,    
sys_performance_info->AvailablePages,       128),
+        ok(check_with_margin(info.PhysicalAvailable,    
sys_performance_info->AvailablePages,       512),
            "expected approximately %ld but got %d\n", info.PhysicalAvailable, 
sys_performance_info->AvailablePages);
 
         /* TODO: info.SystemCache not checked yet - to which field(s) does 
this value correspond to? */
 
-        ok(check_with_margin(info.KernelTotal, 
sys_performance_info->PagedPoolUsage + sys_performance_info->NonPagedPoolUsage, 
64),
+        ok(check_with_margin(info.KernelTotal, 
sys_performance_info->PagedPoolUsage + sys_performance_info->NonPagedPoolUsage, 
256),
            "expected approximately %ld but got %d\n", info.KernelTotal,
            sys_performance_info->PagedPoolUsage + 
sys_performance_info->NonPagedPoolUsage);
 
-        ok(check_with_margin(info.KernelPaged,          
sys_performance_info->PagedPoolUsage,       64),
+        ok(check_with_margin(info.KernelPaged,          
sys_performance_info->PagedPoolUsage,       256),
            "expected approximately %ld but got %d\n", info.KernelPaged, 
sys_performance_info->PagedPoolUsage);
 
-        ok(check_with_margin(info.KernelNonpaged,       
sys_performance_info->NonPagedPoolUsage,    8),
+        ok(check_with_margin(info.KernelNonpaged,       
sys_performance_info->NonPagedPoolUsage,    16),
            "expected approximately %ld but got %d\n", info.KernelNonpaged, 
sys_performance_info->NonPagedPoolUsage);
 
         /* compare with values from SYSTEM_BASIC_INFORMATION */
@@ -339,7 +331,14 @@ static BOOL nt_get_mapped_file_name(HANDLE process, LPVOID 
addr, LPWSTR name, DW
 
     ret_len = 0xdeadbeef;
     status = pNtQueryVirtualMemory(process, addr, MemorySectionName, buf, 
buf_len, &ret_len);
+todo_wine
     ok(!status, "NtQueryVirtualMemory error %x\n", status);
+    /* FIXME: remove once Wine is fixed */
+    if (status)
+    {
+        HeapFree(GetProcessHeap(), 0, buf);
+        return FALSE;
+    }
 
     section_name = (MEMORY_SECTION_NAME *)buf;
     ok(ret_len == section_name->SectionFileName.MaximumLength + 
sizeof(*section_name), "got %lu, %u\n",
@@ -365,30 +364,31 @@ static void test_GetMappedFileName(void)
     char temp_path[MAX_PATH], file_name[MAX_PATH], map_name[MAX_PATH], 
device_name[MAX_PATH], drive[3];
     WCHAR map_nameW[MAX_PATH], nt_map_name[MAX_PATH];
     HANDLE hfile, hmap;
-    HANDLE current_process;
-
-    DuplicateHandle( GetCurrentProcess(), GetCurrentProcess(),
-                     GetCurrentProcess(), &current_process, 0, 0, 
DUPLICATE_SAME_ACCESS );
 
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(NULL, hMod, szMapPath, sizeof(szMapPath));
     ok(!ret, "GetMappedFileName should fail\n");
+todo_wine
     ok(GetLastError() == ERROR_INVALID_HANDLE, "expected 
error=ERROR_INVALID_HANDLE but got %d\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(hpSR, hMod, szMapPath, sizeof(szMapPath));
     ok(!ret, "GetMappedFileName should fail\n");
+todo_wine
     ok(GetLastError() == ERROR_ACCESS_DENIED, "expected 
error=ERROR_ACCESS_DENIED but got %d\n", GetLastError());
 
     SetLastError( 0xdeadbeef );
     ret = pGetMappedFileNameA(hpQI, hMod, szMapPath, sizeof(szMapPath));
+todo_wine
     ok( ret || broken(GetLastError() == ERROR_UNEXP_NET_ERR), /* win2k */
         "GetMappedFileNameA failed with error %u\n", GetLastError() );
     if (ret)
     {
         ok(ret == strlen(szMapPath), "szMapPath=\"%s\" ret=%d\n", szMapPath, 
ret);
+        todo_wine
         ok(szMapPath[0] == '\\', "szMapPath=\"%s\"\n", szMapPath);
         szMapBaseName = strrchr(szMapPath, '\\'); /* That's close enough for 
us */
+        todo_wine
         ok(szMapBaseName && *szMapBaseName, "szMapPath=\"%s\"\n", szMapPath);
         if (szMapBaseName)
         {
@@ -426,30 +426,36 @@ static void test_GetMappedFileName(void)
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, 0);
     ok(!ret, "GetMappedFileName should fail\n");
+todo_wine
     ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == 
ERROR_INSUFFICIENT_BUFFER,
        "wrong error %d\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(GetCurrentProcess(), base, 0, sizeof(map_name));
     ok(!ret, "GetMappedFileName should fail\n");
+todo_wine
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected 
ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
 
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, 1);
+todo_wine
     ok(ret == 1, "GetMappedFileName error %d\n", GetLastError());
     ok(!map_name[0] || broken(map_name[0] == device_name[0]) /* before win2k 
*/, "expected 0, got %c\n", map_name[0]);
 
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, 
sizeof(map_name));
+todo_wine {
     ok(ret, "GetMappedFileName error %d\n", GetLastError());
     ok(ret > strlen(device_name), "map_name should be longer than 
device_name\n");
     ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does 
not start with a device name: %s\n", map_name);
+}
 
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameW(GetCurrentProcess(), base, map_nameW, 
sizeof(map_nameW)/sizeof(map_nameW[0]));
+todo_wine {
     ok(ret, "GetMappedFileNameW error %d\n", GetLastError());
     ok(ret > strlen(device_name), "map_name should be longer than 
device_name\n");
-
+}
     if (nt_get_mapped_file_name(GetCurrentProcess(), base, nt_map_name, 
sizeof(nt_map_name)/sizeof(nt_map_name[0])))
     {
         ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name 
does not start with a device name: %s\n", map_name);
@@ -457,27 +463,18 @@ static void test_GetMappedFileName(void)
         ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name 
does not start with a device name: %s\n", map_name);
     }
 
-    SetLastError(0xdeadbeef);
-    ret = pGetMappedFileNameW(current_process, base, map_nameW, 
sizeof(map_nameW)/sizeof(map_nameW[0]));
-    ok(ret, "GetMappedFileNameW error %d\n", GetLastError());
-    ok(ret > strlen(device_name), "map_name should be longer than 
device_name\n");
-
-    if (nt_get_mapped_file_name(current_process, base, nt_map_name, 
sizeof(nt_map_name)/sizeof(nt_map_name[0])))
-    {
-        ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name 
does not start with a device name: %s\n", map_name);
-        WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, 
NULL, NULL);
-        ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name 
does not start with a device name: %s\n", map_name);
-    }
-
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(GetCurrentProcess(), base + 0x2000, map_name, 
sizeof(map_name));
+todo_wine {
     ok(ret, "GetMappedFileName error %d\n", GetLastError());
     ok(ret > strlen(device_name), "map_name should be longer than 
device_name\n");
     ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does 
not start with a device name: %s\n", map_name);
+}
 
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(GetCurrentProcess(), base + 0x4000, map_name, 
sizeof(map_name));
     ok(!ret, "GetMappedFileName should fail\n");
+todo_wine
     ok(GetLastError() == ERROR_UNEXP_NET_ERR, "expected ERROR_UNEXP_NET_ERR, 
got %d\n", GetLastError());
 
     SetLastError(0xdeadbeef);
@@ -489,6 +486,7 @@ todo_wine
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(0, base, map_name, sizeof(map_name));
     ok(!ret, "GetMappedFileName should fail\n");
+todo_wine
     ok(GetLastError() == ERROR_INVALID_HANDLE, "expected ERROR_INVALID_HANDLE, 
got %d\n", GetLastError());
 
     UnmapViewOfFile(base);
@@ -507,9 +505,9 @@ todo_wine
     SetLastError(0xdeadbeef);
     ret = pGetMappedFileNameA(GetCurrentProcess(), base, map_name, 
sizeof(map_name));
     ok(!ret, "GetMappedFileName should fail\n");
+todo_wine
     ok(GetLastError() == ERROR_FILE_INVALID, "expected ERROR_FILE_INVALID, got 
%d\n", GetLastError());
 
-    CloseHandle(current_process);
     UnmapViewOfFile(base);
     CloseHandle(hmap);
 }
@@ -556,8 +554,8 @@ static void test_GetProcessImageFileName(void)
     if(ret && ret1)
     {
         /* Windows returns 2*strlen-1 */
-        ok(ret >= strlen(szImgPath), "szImgPath=\"%s\" ret=%d\n", szImgPath, 
ret);
-        ok(!strcmp(szImgPath, szMapPath), "szImgPath=\"%s\" 
szMapPath=\"%s\"\n", szImgPath, szMapPath);
+        todo_wine ok(ret >= strlen(szImgPath), "szImgPath=\"%s\" ret=%d\n", 
szImgPath, ret);
+        todo_wine ok(!strcmp(szImgPath, szMapPath), "szImgPath=\"%s\" 
szMapPath=\"%s\"\n", szImgPath, szMapPath);
     }
 
     SetLastError(0xdeadbeef);

Reply via email to