ntdll/tests: Create the server port before starting the client thread.
Print status values in hex.
This commit is contained in:
parent
320286af69
commit
44d2277acd
|
@ -90,10 +90,7 @@ static const WCHAR PORTNAME[] = {'\\','M','y','P','o','r','t',0};
|
||||||
|
|
||||||
#define MAX_MESSAGE_LEN 30
|
#define MAX_MESSAGE_LEN 30
|
||||||
|
|
||||||
UNICODE_STRING port;
|
static UNICODE_STRING port;
|
||||||
static char selfname[MAX_PATH];
|
|
||||||
static int myARGC;
|
|
||||||
static char** myARGV;
|
|
||||||
|
|
||||||
/* Function pointers for ntdll calls */
|
/* Function pointers for ntdll calls */
|
||||||
static HMODULE hntdll = 0;
|
static HMODULE hntdll = 0;
|
||||||
|
@ -155,10 +152,10 @@ static void ProcessConnectionRequest(PLPC_MESSAGE LpcMessage, PHANDLE pAcceptPor
|
||||||
ok(!*LpcMessage->Data, "Expected empty string!\n");
|
ok(!*LpcMessage->Data, "Expected empty string!\n");
|
||||||
|
|
||||||
status = pNtAcceptConnectPort(pAcceptPortHandle, 0, LpcMessage, 1, 0, NULL);
|
status = pNtAcceptConnectPort(pAcceptPortHandle, 0, LpcMessage, 1, 0, NULL);
|
||||||
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
||||||
|
|
||||||
status = pNtCompleteConnectPort(*pAcceptPortHandle);
|
status = pNtCompleteConnectPort(*pAcceptPortHandle);
|
||||||
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessLpcRequest(HANDLE PortHandle, PLPC_MESSAGE LpcMessage)
|
static void ProcessLpcRequest(HANDLE PortHandle, PLPC_MESSAGE LpcMessage)
|
||||||
|
@ -173,7 +170,7 @@ static void ProcessLpcRequest(HANDLE PortHandle, PLPC_MESSAGE LpcMessage)
|
||||||
lstrcpy((LPSTR)LpcMessage->Data, REPLY);
|
lstrcpy((LPSTR)LpcMessage->Data, REPLY);
|
||||||
|
|
||||||
status = pNtReplyPort(PortHandle, LpcMessage);
|
status = pNtReplyPort(PortHandle, LpcMessage);
|
||||||
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
||||||
ok(LpcMessage->MessageType == LPC_REQUEST,
|
ok(LpcMessage->MessageType == LPC_REQUEST,
|
||||||
"Expected LPC_REQUEST, got %d\n", LpcMessage->MessageType);
|
"Expected LPC_REQUEST, got %d\n", LpcMessage->MessageType);
|
||||||
ok(!lstrcmp((LPSTR)LpcMessage->Data, REPLY),
|
ok(!lstrcmp((LPSTR)LpcMessage->Data, REPLY),
|
||||||
|
@ -194,11 +191,11 @@ static DWORD WINAPI test_ports_client(LPVOID arg)
|
||||||
sqos.EffectiveOnly = TRUE;
|
sqos.EffectiveOnly = TRUE;
|
||||||
|
|
||||||
status = pNtConnectPort(&PortHandle, &port, &sqos, 0, 0, &len, NULL, NULL);
|
status = pNtConnectPort(&PortHandle, &port, &sqos, 0, 0, &len, NULL, NULL);
|
||||||
todo_wine ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
todo_wine ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
||||||
if (status != STATUS_SUCCESS) return 1;
|
if (status != STATUS_SUCCESS) return 1;
|
||||||
|
|
||||||
status = pNtRegisterThreadTerminatePort(PortHandle);
|
status = pNtRegisterThreadTerminatePort(PortHandle);
|
||||||
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
||||||
|
|
||||||
size = FIELD_OFFSET(LPC_MESSAGE, Data) + MAX_MESSAGE_LEN;
|
size = FIELD_OFFSET(LPC_MESSAGE, Data) + MAX_MESSAGE_LEN;
|
||||||
LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
||||||
|
@ -209,7 +206,7 @@ static DWORD WINAPI test_ports_client(LPVOID arg)
|
||||||
lstrcpy((LPSTR)LpcMessage->Data, REQUEST1);
|
lstrcpy((LPSTR)LpcMessage->Data, REQUEST1);
|
||||||
|
|
||||||
status = pNtRequestPort(PortHandle, LpcMessage);
|
status = pNtRequestPort(PortHandle, LpcMessage);
|
||||||
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
||||||
ok(LpcMessage->MessageType == 0, "Expected 0, got %d\n", LpcMessage->MessageType);
|
ok(LpcMessage->MessageType == 0, "Expected 0, got %d\n", LpcMessage->MessageType);
|
||||||
ok(!lstrcmp((LPSTR)LpcMessage->Data, REQUEST1),
|
ok(!lstrcmp((LPSTR)LpcMessage->Data, REQUEST1),
|
||||||
"Expected %s, got %s\n", REQUEST1, LpcMessage->Data);
|
"Expected %s, got %s\n", REQUEST1, LpcMessage->Data);
|
||||||
|
@ -222,7 +219,7 @@ static DWORD WINAPI test_ports_client(LPVOID arg)
|
||||||
|
|
||||||
/* Send the message and wait for the reply */
|
/* Send the message and wait for the reply */
|
||||||
status = pNtRequestWaitReplyPort(PortHandle, LpcMessage, out);
|
status = pNtRequestWaitReplyPort(PortHandle, LpcMessage, out);
|
||||||
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %x\n", status);
|
||||||
ok(!lstrcmp((LPSTR)out->Data, REPLY), "Expected %s, got %s\n", REPLY, out->Data);
|
ok(!lstrcmp((LPSTR)out->Data, REPLY), "Expected %s, got %s\n", REPLY, out->Data);
|
||||||
ok(out->MessageType == LPC_REPLY, "Expected LPC_REPLY, got %d\n", out->MessageType);
|
ok(out->MessageType == LPC_REPLY, "Expected LPC_REPLY, got %d\n", out->MessageType);
|
||||||
|
|
||||||
|
@ -232,34 +229,14 @@ static DWORD WINAPI test_ports_client(LPVOID arg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_ports_server(void)
|
static void test_ports_server( HANDLE PortHandle )
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES obj;
|
|
||||||
HANDLE PortHandle;
|
|
||||||
HANDLE AcceptPortHandle;
|
HANDLE AcceptPortHandle;
|
||||||
PLPC_MESSAGE LpcMessage;
|
PLPC_MESSAGE LpcMessage;
|
||||||
ULONG size;
|
ULONG size;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
BOOL done = FALSE;
|
BOOL done = FALSE;
|
||||||
|
|
||||||
pRtlInitUnicodeString(&port, PORTNAME);
|
|
||||||
|
|
||||||
memset(&obj, 0, sizeof(OBJECT_ATTRIBUTES));
|
|
||||||
obj.Length = sizeof(OBJECT_ATTRIBUTES);
|
|
||||||
obj.ObjectName = &port;
|
|
||||||
|
|
||||||
status = pNtCreatePort(&PortHandle, &obj, 100, 100, 0);
|
|
||||||
if (status == STATUS_ACCESS_DENIED)
|
|
||||||
{
|
|
||||||
skip("Not enough rights\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
todo_wine
|
|
||||||
{
|
|
||||||
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
|
||||||
}
|
|
||||||
if (status != STATUS_SUCCESS) return;
|
|
||||||
|
|
||||||
size = FIELD_OFFSET(LPC_MESSAGE, Data) + MAX_MESSAGE_LEN;
|
size = FIELD_OFFSET(LPC_MESSAGE, Data) + MAX_MESSAGE_LEN;
|
||||||
LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
LpcMessage = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
||||||
|
|
||||||
|
@ -308,20 +285,32 @@ static void test_ports_server(void)
|
||||||
|
|
||||||
START_TEST(port)
|
START_TEST(port)
|
||||||
{
|
{
|
||||||
HANDLE thread;
|
OBJECT_ATTRIBUTES obj;
|
||||||
DWORD id;
|
HANDLE port_handle;
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
if (!init_function_ptrs())
|
if (!init_function_ptrs())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myARGC = winetest_get_mainargs(&myARGV);
|
pRtlInitUnicodeString(&port, PORTNAME);
|
||||||
strcpy(selfname, myARGV[0]);
|
|
||||||
|
|
||||||
thread = CreateThread(NULL, 0, test_ports_client, NULL, 0, &id);
|
memset(&obj, 0, sizeof(OBJECT_ATTRIBUTES));
|
||||||
ok(thread != NULL, "Expected non-NULL thread handle!\n");
|
obj.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||||
|
obj.ObjectName = &port;
|
||||||
|
|
||||||
test_ports_server();
|
status = pNtCreatePort(&port_handle, &obj, 100, 100, 0);
|
||||||
CloseHandle(thread);
|
if (status == STATUS_ACCESS_DENIED) skip("Not enough rights\n");
|
||||||
|
else todo_wine ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %d\n", status);
|
||||||
|
|
||||||
|
if (status == STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
DWORD id;
|
||||||
|
HANDLE thread = CreateThread(NULL, 0, test_ports_client, NULL, 0, &id);
|
||||||
|
ok(thread != NULL, "Expected non-NULL thread handle!\n");
|
||||||
|
|
||||||
|
test_ports_server( port_handle );
|
||||||
|
ok( WaitForSingleObject( thread, 10000 ) == 0, "thread didn't exit\n" );
|
||||||
|
CloseHandle(thread);
|
||||||
|
}
|
||||||
FreeLibrary(hntdll);
|
FreeLibrary(hntdll);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue