ReactOS 0.4.16-dev-106-g10b08aa
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
13static DWORD dInMsg = MSG;
14static DWORD dOutMsg = 0x0;
15
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
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
62VOID
64{
66
68 ok(hThread != INVALID_HANDLE_VALUE, "CreateThread failed\n");
70 {
73 }
74 ok(dInMsg == dOutMsg, "Transfer data failed\n");
75}
76
77START_TEST(Mailslot)
78{
80}
DWORD WINAPI MailSlotReader(LPVOID lpParam)
Definition: Mailslot.c:38
#define MSG
Definition: Mailslot.c:11
DWORD WINAPI MailSlotWriter(LPVOID lpParam)
Definition: Mailslot.c:18
static DWORD dOutMsg
Definition: Mailslot.c:14
static DWORD dInMsg
Definition: Mailslot.c:13
VOID StartTestCORE10188(VOID)
Definition: Mailslot.c:63
#define LMS
Definition: Mailslot.c:10
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
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:137
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MAILSLOT_WAIT_FOREVER
Definition: finfo.c:19
HANDLE hThread
Definition: wizard.c:28
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define CreateMailslot
Definition: winbase.h:3755
#define CreateFile
Definition: winbase.h:3749
#define WINAPI
Definition: msvc.h:6