wine-staging/patches/ntdll-WRITECOPY/0010-kernel32-tests-psapi-tests-Update-tests.patch
Paul Gofman d33cdb84fd Updated ntdll-WRITECOPY patchset.
Added patches by Andrew Wesie which complete the implementation
and remove the configuration option that was previously
disabled by default.
2020-04-28 14:55:04 +03:00

200 lines
11 KiB
Diff

From 8cfae1d0d5b68675169704db7d752801a3a83d09 Mon Sep 17 00:00:00 2001
From: Andrew Wesie <awesie@gmail.com>
Date: Mon, 27 Apr 2020 15:32:22 +0300
Subject: [PATCH] kernel32/tests, psapi/tests: Update tests.
---
dlls/kernel32/tests/virtual.c | 19 ++----------------
dlls/psapi/tests/psapi_main.c | 38 +++++++++++++++++++++++------------
2 files changed, 27 insertions(+), 30 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 2b7c8c6ef87..0852fe36d18 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -3589,9 +3589,7 @@ static void test_CreateFileMapping_protection(void)
SetLastError(0xdeadbeef);
ret = VirtualQuery(base, &info, sizeof(info));
ok(ret, "VirtualQuery failed %d\n", GetLastError());
- /* FIXME: remove the condition below once Wine is fixed */
- todo_wine_if (td[i].prot == PAGE_WRITECOPY || td[i].prot == PAGE_EXECUTE_WRITECOPY)
- ok(info.Protect == td[i].prot_after_write, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot_after_write);
+ ok(info.Protect == td[i].prot_after_write, "%d: got %#x != expected %#x\n", i, info.Protect, td[i].prot_after_write);
}
}
else
@@ -3605,9 +3603,7 @@ static void test_CreateFileMapping_protection(void)
SetLastError(0xdeadbeef);
ret = VirtualProtect(base, si.dwPageSize, PAGE_NOACCESS, &old_prot);
ok(ret, "%d: VirtualProtect error %d\n", i, GetLastError());
- /* FIXME: remove the condition below once Wine is fixed */
- todo_wine_if (td[i].prot == PAGE_WRITECOPY || td[i].prot == PAGE_EXECUTE_WRITECOPY)
- ok(old_prot == td[i].prot_after_write, "%d: got %#x != expected %#x\n", i, old_prot, td[i].prot_after_write);
+ ok(old_prot == td[i].prot_after_write, "%d: got %#x != expected %#x\n", i, old_prot, td[i].prot_after_write);
UnmapViewOfFile(base);
}
@@ -3960,15 +3956,12 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
continue;
}
- todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
ok(ret, "VirtualProtect error %d, map %#x, view %#x, requested prot %#x\n", GetLastError(), page_prot[i], view[j].prot, page_prot[k]);
- todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
ok(old_prot == prev_prot, "got %#x, expected %#x\n", old_prot, prev_prot);
prev_prot = actual_prot;
ret = VirtualQuery(base, &info, sizeof(info));
ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
- todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
ok(info.Protect == actual_prot,
"VirtualProtect wrong prot, map %#x, view %#x, requested prot %#x got %#x\n",
page_prot[i], view[j].prot, page_prot[k], info.Protect );
@@ -4023,15 +4016,12 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
if (!anon_mapping && is_compatible_protection(alloc_prot, PAGE_WRITECOPY))
{
ret = VirtualProtect(base, sec_flags & SEC_IMAGE ? si.dwPageSize : 2*si.dwPageSize, PAGE_WRITECOPY, &old_prot);
- todo_wine_if(readonly && view[j].prot != PAGE_WRITECOPY)
ok(ret, "VirtualProtect error %d, map %#x, view %#x\n", GetLastError(), page_prot[i], view[j].prot);
if (ret) *(DWORD*)base = 0xdeadbeef;
ret = VirtualQuery(base, &info, sizeof(info));
ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
- todo_wine
ok(info.Protect == PAGE_READWRITE, "VirtualProtect wrong prot, map %#x, view %#x got %#x\n",
page_prot[i], view[j].prot, info.Protect );
- todo_wine_if (!(sec_flags & SEC_IMAGE))
ok(info.RegionSize == si.dwPageSize, "wrong region size %#lx after write, map %#x, view %#x got %#x\n",
info.RegionSize, page_prot[i], view[j].prot, info.Protect );
@@ -4042,7 +4032,6 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
{
ret = VirtualQuery((char*)base + si.dwPageSize, &info, sizeof(info));
ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
- todo_wine_if(readonly && view[j].prot != PAGE_WRITECOPY)
ok(info.Protect == PAGE_WRITECOPY, "wrong prot, map %#x, view %#x got %#x\n",
page_prot[i], view[j].prot, info.Protect);
}
@@ -4062,14 +4051,11 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags, BOOL readonly )
continue;
}
- todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
ok(ret, "VirtualProtect error %d, map %#x, view %#x, requested prot %#x\n", GetLastError(), page_prot[i], view[j].prot, page_prot[k]);
- todo_wine_if(readonly && page_prot[k] == PAGE_WRITECOPY && view[j].prot != PAGE_WRITECOPY)
ok(old_prot == prev_prot, "got %#x, expected %#x\n", old_prot, prev_prot);
ret = VirtualQuery(base, &info, sizeof(info));
ok(ret, "%d: VirtualQuery failed %d\n", j, GetLastError());
- todo_wine_if( map_prot_written( page_prot[k] ) != actual_prot )
ok(info.Protect == map_prot_written( page_prot[k] ),
"VirtualProtect wrong prot, map %#x, view %#x, requested prot %#x got %#x\n",
page_prot[i], view[j].prot, page_prot[k], info.Protect );
@@ -4110,7 +4096,6 @@ static void test_mappings(void)
SetFilePointer(hfile, 0, NULL, FILE_BEGIN);
ok(ReadFile(hfile, &data, sizeof(data), &num_bytes, NULL), "ReadFile failed\n");
ok(num_bytes == sizeof(data), "num_bytes = %d\n", num_bytes);
- todo_wine
ok(!data, "data = %x\n", data);
CloseHandle( hfile );
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index d3714a654ec..3984805d2b9 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -798,7 +798,7 @@ free_page:
}
static void check_QueryWorkingSetEx(PVOID addr, const char *desc, DWORD expected_valid,
- DWORD expected_protection, DWORD expected_shared, BOOL todo, BOOL todo_shared)
+ DWORD expected_protection, DWORD expected_shared, BOOL todo)
{
PSAPI_WORKING_SET_EX_INFORMATION info;
BOOL ret;
@@ -821,7 +821,6 @@ static void check_QueryWorkingSetEx(PVOID addr, const char *desc, DWORD expected
ok(info.VirtualAttributes.LargePage == 0, "%s expected LargePage=0 but got %u\n",
desc, info.VirtualAttributes.LargePage);
- todo_wine_if(todo_shared)
ok(info.VirtualAttributes.Shared == expected_shared || broken(!info.VirtualAttributes.Valid) /* w2003 */,
"%s expected Shared=%u but got %u\n", desc, expected_shared, info.VirtualAttributes.Shared);
if (info.VirtualAttributes.Valid && info.VirtualAttributes.Shared)
@@ -838,6 +837,8 @@ static void test_QueryWorkingSetEx(void)
DWORD prot;
BOOL ret;
+ static char tmp_data[0x2000] = { 0x41 };
+
if (pQueryWorkingSetEx == NULL)
{
win_skip("QueryWorkingSetEx not found, skipping tests\n");
@@ -845,44 +846,55 @@ static void test_QueryWorkingSetEx(void)
}
addr = GetModuleHandleA(NULL);
- check_QueryWorkingSetEx(addr, "exe", 1, PAGE_READONLY, 1, FALSE, TRUE);
+ check_QueryWorkingSetEx(addr, "exe", 1, PAGE_READONLY, 1, FALSE);
ret = VirtualProtect(addr, 0x1000, PAGE_NOACCESS, &prot);
ok(ret, "VirtualProtect failed with %d\n", GetLastError());
- check_QueryWorkingSetEx(addr, "exe,noaccess", 0, 0, 1, FALSE, TRUE);
+ check_QueryWorkingSetEx(addr, "exe,noaccess", 0, 0, 1, FALSE);
ret = VirtualProtect(addr, 0x1000, prot, &prot);
ok(ret, "VirtualProtect failed with %d\n", GetLastError());
- check_QueryWorkingSetEx(addr, "exe,readonly1", 0, 0, 1, TRUE, TRUE);
+ check_QueryWorkingSetEx(addr, "exe,readonly1", 0, 0, 1, TRUE);
*(volatile char *)addr;
+ check_QueryWorkingSetEx(addr, "exe,readonly2", 1, PAGE_READONLY, 1, FALSE);
+
+ ret = VirtualProtect(addr, 0x1000, PAGE_EXECUTE_READWRITE, &prot);
ok(ret, "VirtualProtect failed with %d\n", GetLastError());
- check_QueryWorkingSetEx(addr, "exe,readonly2", 1, PAGE_READONLY, 1, FALSE, TRUE);
+ check_QueryWorkingSetEx(addr, "exe,readwrite1", 1, PAGE_EXECUTE_WRITECOPY, 1, FALSE);
+
+ *(volatile char *)addr = 1;
+ check_QueryWorkingSetEx(addr, "exe,readwrite2", 1, PAGE_EXECUTE_READWRITE, 0, FALSE);
+
+ *(volatile char *)&tmp_data[0x1000];
+ check_QueryWorkingSetEx(tmp_data + 0x1000, "exe,data1", 1, PAGE_WRITECOPY, 1, FALSE);
+ tmp_data[0x1000] = 1;
+ check_QueryWorkingSetEx(tmp_data + 0x1000, "exe,data2", 1, PAGE_READWRITE, 0, FALSE);
addr = VirtualAlloc(NULL, 0x1000, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
ok(addr != NULL, "VirtualAlloc failed with %d\n", GetLastError());
- check_QueryWorkingSetEx(addr, "valloc", 0, 0, 0, FALSE, FALSE);
+ check_QueryWorkingSetEx(addr, "valloc", 0, 0, 0, FALSE);
*(volatile char *)addr;
- check_QueryWorkingSetEx(addr, "valloc,read", 1, PAGE_READWRITE, 0, FALSE, FALSE);
+ check_QueryWorkingSetEx(addr, "valloc,read", 1, PAGE_READWRITE, 0, FALSE);
*(volatile char *)addr = 0x42;
- check_QueryWorkingSetEx(addr, "valloc,write", 1, PAGE_READWRITE, 0, FALSE, FALSE);
+ check_QueryWorkingSetEx(addr, "valloc,write", 1, PAGE_READWRITE, 0, FALSE);
ret = VirtualProtect(addr, 0x1000, PAGE_NOACCESS, &prot);
ok(ret, "VirtualProtect failed with %d\n", GetLastError());
- check_QueryWorkingSetEx(addr, "valloc,noaccess", 0, 0, 0, FALSE, FALSE);
+ check_QueryWorkingSetEx(addr, "valloc,noaccess", 0, 0, 0, FALSE);
ret = VirtualProtect(addr, 0x1000, prot, &prot);
ok(ret, "VirtualProtect failed with %d\n", GetLastError());
- check_QueryWorkingSetEx(addr, "valloc,readwrite1", 0, 0, 0, TRUE, FALSE);
+ check_QueryWorkingSetEx(addr, "valloc,readwrite1", 0, 0, 0, TRUE);
*(volatile char *)addr;
- check_QueryWorkingSetEx(addr, "valloc,readwrite2", 1, PAGE_READWRITE, 0, FALSE, FALSE);
+ check_QueryWorkingSetEx(addr, "valloc,readwrite2", 1, PAGE_READWRITE, 0, FALSE);
ret = VirtualFree(addr, 0, MEM_RELEASE);
ok(ret, "VirtualFree failed with %d\n", GetLastError());
- check_QueryWorkingSetEx(addr, "valloc,free", FALSE, 0, 0, FALSE, FALSE);
+ check_QueryWorkingSetEx(addr, "valloc,free", FALSE, 0, 0, FALSE);
}
START_TEST(psapi_main)
--
2.25.4