Commit ea950ac7 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

kernel32/tests: Added more shared memory tests, exposing MAP_PRIVATE mapping for…

kernel32/tests: Added more shared memory tests, exposing MAP_PRIVATE mapping for read only mapping problem.
parent 4792cf31
......@@ -2447,7 +2447,7 @@ todo_wine
DeleteFileA(file_name);
}
static void test_shared_memory(int is_child)
static void test_shared_memory(BOOL is_child)
{
HANDLE mapping;
LONG *p;
......@@ -2489,6 +2489,48 @@ static void test_shared_memory(int is_child)
CloseHandle(mapping);
}
static void test_shared_memory_ro(BOOL is_child)
{
HANDLE mapping;
LONG *p;
SetLastError(0xdeadbef);
mapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, "winetest_virtual.c_ro");
ok(mapping != 0, "CreateFileMapping error %d\n", GetLastError());
if (is_child)
ok(GetLastError() == ERROR_ALREADY_EXISTS, "expected ERROR_ALREADY_EXISTS, got %d\n", GetLastError());
SetLastError(0xdeadbef);
p = MapViewOfFile(mapping, FILE_MAP_READ | (is_child ? FILE_MAP_WRITE : 0), 0, 0, 4096);
ok(p != NULL, "MapViewOfFile error %d\n", GetLastError());
if (is_child)
{
*p = 0xdeadbeef;
}
else
{
char **argv;
char cmdline[MAX_PATH];
PROCESS_INFORMATION pi;
STARTUPINFOA si = { sizeof(si) };
DWORD ret;
winetest_get_mainargs(&argv);
sprintf(cmdline, "\"%s\" virtual sharedmemro", argv[0]);
ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
winetest_wait_child_process(pi.hProcess);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
ok(*p == 0xdeadbeef, "*p = %x, expected 0xdeadbeef\n", *p);
}
UnmapViewOfFile(p);
CloseHandle(mapping);
}
START_TEST(virtual)
{
int argc;
......@@ -2504,7 +2546,12 @@ START_TEST(virtual)
}
if (!strcmp(argv[2], "sharedmem"))
{
test_shared_memory(1);
test_shared_memory(TRUE);
return;
}
if (!strcmp(argv[2], "sharedmemro"))
{
test_shared_memory_ro(TRUE);
return;
}
while (1)
......@@ -2532,7 +2579,8 @@ START_TEST(virtual)
pNtMapViewOfSection = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtMapViewOfSection");
pNtUnmapViewOfSection = (void *)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtUnmapViewOfSection");
test_shared_memory(0);
test_shared_memory(FALSE);
test_shared_memory_ro(FALSE);
test_mapping();
test_CreateFileMapping_protection();
test_VirtualAlloc_protection();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment