Author: pschweitzer Date: Fri Sep 25 14:44:38 2015 New Revision: 69351 URL: http://svn.reactos.org/svn/reactos?rev=69351&view=rev Log: [KERNEL32_APITEST] Add a test for CORE-10188 (which was fixed by Thomas in r69236). It is based on Nikita Pechenkin's patch with a few modifications by me to avoid race condition on start (and avoid flappy test) and to match more closely our coding style
ROSTESTS-190 #resolve #comment Committed in r69351. Thanks! Added: trunk/rostests/apitests/kernel32/Mailslot.c (with props) Modified: trunk/rostests/apitests/kernel32/CMakeLists.txt trunk/rostests/apitests/kernel32/testlist.c Modified: trunk/rostests/apitests/kernel32/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/CMakeLists.txt?rev=69351&r1=69350&r2=69351&view=diff ============================================================================== --- trunk/rostests/apitests/kernel32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/kernel32/CMakeLists.txt [iso-8859-1] Fri Sep 25 14:44:38 2015 @@ -13,7 +13,8 @@ SetUnhandledExceptionFilter.c TerminateProcess.c TunnelCache.c - testlist.c) + testlist.c + Mailslot.c) add_executable(kernel32_apitest ${SOURCE}) target_link_libraries(kernel32_apitest wine ${PSEH_LIB}) Added: trunk/rostests/apitests/kernel32/Mailslot.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/Mailslot.c?rev=69351 ============================================================================== --- trunk/rostests/apitests/kernel32/Mailslot.c (added) +++ trunk/rostests/apitests/kernel32/Mailslot.c [iso-8859-1] Fri Sep 25 14:44:38 2015 @@ -0,0 +1,83 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GNU GPLv2 only as published by the Free Software Foundation + * PURPOSE: Test for mailslot (CORE-10188) + * PROGRAMMER: Nikita Pechenkin (n.pechen...@mail.ru) + */ + +#include <apitest.h> + +#define WIN32_NO_STATUS +#include <stdio.h> + +#define LMS TEXT("\\\\.\\mailslot\\rostest_slot") +#define MSG (0x50DA) + +static DWORD dInMsg = MSG; +static DWORD dOutMsg = 0x0; + +DWORD +WINAPI +MailSlotWriter( + LPVOID lpParam) +{ + DWORD cbWritten; + HANDLE hMailslot; + + hMailslot = CreateFile(LMS, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + ok(hMailslot != INVALID_HANDLE_VALUE, "CreateFile failed, results might not be accurate\n"); + if (hMailslot != INVALID_HANDLE_VALUE) + { + Sleep(1000); + ok(WriteFile(hMailslot, &dInMsg, sizeof(dInMsg), &cbWritten, (LPOVERLAPPED) NULL), "Slot write failed\n"); + CloseHandle(hMailslot); + } + return 0; +} + +DWORD +WINAPI +MailSlotReader( + LPVOID lpParam) +{ + HANDLE hMailslotClient; + DWORD cbRead; + HANDLE hThread; + + hMailslotClient = CreateMailslot(LMS, 0L, MAILSLOT_WAIT_FOREVER, (LPSECURITY_ATTRIBUTES) NULL); + ok(hMailslotClient != INVALID_HANDLE_VALUE, "CreateMailslot failed\n"); + if (hMailslotClient != INVALID_HANDLE_VALUE) + { + hThread = CreateThread(NULL,0, MailSlotWriter, NULL, 0, NULL); + ok(hThread != INVALID_HANDLE_VALUE, "CreateThread failed\n"); + if (hThread != INVALID_HANDLE_VALUE) + { + ok(ReadFile(hMailslotClient, &dOutMsg, sizeof(dOutMsg), &cbRead, NULL), "Slot read failed\n"); + WaitForSingleObject(hThread, INFINITE); + CloseHandle(hThread); + } + CloseHandle(hMailslotClient); + } + return 0; +} + +VOID +StartTestCORE10188(VOID) +{ + HANDLE hThread; + + hThread = CreateThread(NULL,0, MailSlotReader, NULL, 0, NULL); + ok(hThread != INVALID_HANDLE_VALUE, "CreateThread failed\n"); + if (hThread != INVALID_HANDLE_VALUE) + { + WaitForSingleObject(hThread, INFINITE); + CloseHandle(hThread); + } + ok(dInMsg == dOutMsg, "Transfer data failed\n"); +} + +START_TEST(Mailslot) +{ + StartTestCORE10188(); +} Propchange: trunk/rostests/apitests/kernel32/Mailslot.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/kernel32/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/testlist.c?rev=69351&r1=69350&r2=69351&view=diff ============================================================================== --- trunk/rostests/apitests/kernel32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/kernel32/testlist.c [iso-8859-1] Fri Sep 25 14:44:38 2015 @@ -10,6 +10,7 @@ extern void func_GetModuleFileName(void); extern void func_interlck(void); extern void func_lstrcpynW(void); +extern void func_Mailslot(void); extern void func_MultiByteToWideChar(void); extern void func_PrivMoveFileIdentityW(void); extern void func_SetCurrentDirectory(void); @@ -26,6 +27,7 @@ { "GetModuleFileName", func_GetModuleFileName }, { "interlck", func_interlck }, { "lstrcpynW", func_lstrcpynW }, + { "Mailslot", func_Mailslot }, { "MultiByteToWideChar", func_MultiByteToWideChar }, { "PrivMoveFileIdentityW", func_PrivMoveFileIdentityW }, { "SetCurrentDirectory", func_SetCurrentDirectory },