Dmitry Timoshkov : kernel32: Add a shared memory test.
Alexandre Julliard
julliard at winehq.org
Fri Apr 12 10:40:35 CDT 2013
Module: wine
Branch: master
Commit: 54e2211db07d4036121a397040bb2b8c9177977b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=54e2211db07d4036121a397040bb2b8c9177977b
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Fri Apr 12 18:00:10 2013 +0900
kernel32: Add a shared memory test.
---
dlls/kernel32/tests/virtual.c | 48 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index d02ca34..c0c1a89 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -2386,6 +2386,48 @@ static void test_mapping(void)
DeleteFile(file_name);
}
+static void test_shared_memory(int is_child)
+{
+ HANDLE mapping;
+ LONG *p;
+
+ SetLastError(0xdeadbef);
+ mapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, "winetest_virtual.c");
+ 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|FILE_MAP_WRITE, 0, 0, 4096);
+ ok(p != NULL, "MapViewOfFile error %d\n", GetLastError());
+
+ if (is_child)
+ {
+ ok(*p == 0x1a2b3c4d, "expected 0x1a2b3c4d in child, got %#x\n", *p);
+ }
+ else
+ {
+ char **argv;
+ char cmdline[MAX_PATH];
+ PROCESS_INFORMATION pi;
+ STARTUPINFO si = { sizeof(si) };
+ DWORD ret;
+
+ *p = 0x1a2b3c4d;
+
+ winetest_get_mainargs(&argv);
+ sprintf(cmdline, "\"%s\" virtual sharedmem", argv[0]);
+ ret = CreateProcess(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);
+ }
+
+ UnmapViewOfFile(p);
+ CloseHandle(mapping);
+}
+
START_TEST(virtual)
{
int argc;
@@ -2399,6 +2441,11 @@ START_TEST(virtual)
Sleep(5000); /* spawned process runs for at most 5 seconds */
return;
}
+ if (!strcmp(argv[2], "sharedmem"))
+ {
+ test_shared_memory(1);
+ return;
+ }
while (1)
{
void *mem;
@@ -2424,6 +2471,7 @@ START_TEST(virtual)
pNtMapViewOfSection = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtMapViewOfSection");
pNtUnmapViewOfSection = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtUnmapViewOfSection");
+ test_shared_memory(0);
test_mapping();
test_CreateFileMapping_protection();
test_VirtualAlloc_protection();
More information about the wine-cvs
mailing list