ReactOS  0.4.13-dev-99-g7e18b6d
Mailslot.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GNU GPLv2 only as published by the Free Software Foundation
4  * PURPOSE: Test for mailslot (CORE-10188)
5  * PROGRAMMER: Nikita Pechenkin (n.pechenkin@mail.ru)
6  */
7 
8 #include "precomp.h"
9 
10 #define LMS TEXT("\\\\.\\mailslot\\rostest_slot")
11 #define MSG (0x50DA)
12 
13 static DWORD dInMsg = MSG;
14 static DWORD dOutMsg = 0x0;
15 
16 DWORD
17 WINAPI
19  LPVOID lpParam)
20 {
21  DWORD cbWritten;
22  HANDLE hMailslot;
23 
26  ok(hMailslot != INVALID_HANDLE_VALUE, "CreateFile failed, results might not be accurate\n");
27  if (hMailslot != INVALID_HANDLE_VALUE)
28  {
29  Sleep(1000);
30  ok(WriteFile(hMailslot, &dInMsg, sizeof(dInMsg), &cbWritten, (LPOVERLAPPED) NULL), "Slot write failed\n");
31  CloseHandle(hMailslot);
32  }
33  return 0;
34 }
35 
36 DWORD
37 WINAPI
39  LPVOID lpParam)
40 {
41  HANDLE hMailslotClient;
42  DWORD cbRead;
44 
46  ok(hMailslotClient != INVALID_HANDLE_VALUE, "CreateMailslot failed\n");
47  if (hMailslotClient != INVALID_HANDLE_VALUE)
48  {
50  ok(hThread != INVALID_HANDLE_VALUE, "CreateThread failed\n");
52  {
53  ok(ReadFile(hMailslotClient, &dOutMsg, sizeof(dOutMsg), &cbRead, NULL), "Slot read failed\n");
56  }
57  CloseHandle(hMailslotClient);
58  }
59  return 0;
60 }
61 
62 VOID
64 {
66 
68  ok(hThread != INVALID_HANDLE_VALUE, "CreateThread failed\n");
70  {
73  }
74  ok(dInMsg == dOutMsg, "Transfer data failed\n");
75 }
76 
77 START_TEST(Mailslot)
78 {
80 }
static DWORD dInMsg
Definition: Mailslot.c:13
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define LMS
Definition: Mailslot.c:10
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
DWORD WINAPI MailSlotReader(LPVOID lpParam)
Definition: Mailslot.c:38
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
VOID StartTestCORE10188(VOID)
Definition: Mailslot.c:63
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ok(value,...)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#define WINAPI
Definition: msvc.h:8
DWORD WINAPI MailSlotWriter(LPVOID lpParam)
Definition: Mailslot.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD dOutMsg
Definition: Mailslot.c:14
#define MSG
Definition: Mailslot.c:11
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
#define CreateMailslot
Definition: winbase.h:3569
#define MAILSLOT_WAIT_FOREVER
Definition: finfo.c:19
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
HANDLE hThread
Definition: wizard.c:27
#define INFINITE
Definition: serial.h:102
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
START_TEST(Mailslot)
Definition: Mailslot.c:77