mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 13:33:04 +00:00
[ADVAPI32_APITEST]: Add some supplemental tests for Winetests' Event Logging functions, testing different RPC limits related to the maximum size of the data buffer in events.
CORE-11838 CORE-11839 svn path=/trunk/; revision=72207
This commit is contained in:
parent
87bf08acdb
commit
b3195b9538
3 changed files with 94 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
CreateService.c
|
CreateService.c
|
||||||
DuplicateTokenEx.c
|
DuplicateTokenEx.c
|
||||||
|
eventlog.c
|
||||||
HKEY_CLASSES_ROOT.c
|
HKEY_CLASSES_ROOT.c
|
||||||
IsTextUnicode.c
|
IsTextUnicode.c
|
||||||
LockDatabase.c
|
LockDatabase.c
|
||||||
|
|
91
rostests/apitests/advapi32/eventlog.c
Normal file
91
rostests/apitests/advapi32/eventlog.c
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS api tests
|
||||||
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||||
|
* PURPOSE: Supplemental tests for Winetests' Event Logging functions
|
||||||
|
* PROGRAMMER: Hermes Belusca-Maito
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <apitest.h>
|
||||||
|
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
|
#include <winbase.h>
|
||||||
|
|
||||||
|
START_TEST(eventlog)
|
||||||
|
{
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
/* Input */
|
||||||
|
ULONG MaxDataSize;
|
||||||
|
|
||||||
|
/* Output for Windows <= 2k3 / Windows Vista+ */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
BOOL Success;
|
||||||
|
DWORD LastError;
|
||||||
|
} Result[2];
|
||||||
|
} Tests[] =
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Tests for the different RPC boundaries on Windows.
|
||||||
|
* See also the "ReportEvent" API on MSDN, section "Return value", at:
|
||||||
|
* https://msdn.microsoft.com/en-us/library/windows/desktop/aa363679(v=vs.85).aspx
|
||||||
|
* for more details.
|
||||||
|
*/
|
||||||
|
{ 0xF000, { {TRUE, ERROR_SUCCESS}, {TRUE , ERROR_SUCCESS} } },
|
||||||
|
{ 0xF001, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } },
|
||||||
|
|
||||||
|
{ 0x3FF66, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } },
|
||||||
|
{ 0x3FF67, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } },
|
||||||
|
{ 0x3FF68, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } },
|
||||||
|
|
||||||
|
/* Show that the maximum data size for an event can be as big as 0x3FFFF */
|
||||||
|
{ 0x3FFFE, { {TRUE, ERROR_SUCCESS /* or ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } },
|
||||||
|
{ 0x3FFFF, { {TRUE, ERROR_SUCCESS /* or ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } },
|
||||||
|
{ 0x40000, { {FALSE, RPC_X_BAD_STUB_DATA}, {FALSE, RPC_S_INVALID_BOUND} } },
|
||||||
|
};
|
||||||
|
|
||||||
|
UINT i;
|
||||||
|
BOOL Success;
|
||||||
|
DWORD LastError;
|
||||||
|
HANDLE hEventLog;
|
||||||
|
PVOID Data;
|
||||||
|
|
||||||
|
/* We use the "Application" log for the different tests! */
|
||||||
|
hEventLog = OpenEventLogW(NULL, L"Application");
|
||||||
|
ok(hEventLog != NULL, "OpenEventLogW(NULL, L\"Application\") failed with error %lu\n", GetLastError());
|
||||||
|
if (!hEventLog)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAYSIZE(Tests); ++i)
|
||||||
|
{
|
||||||
|
Data = HeapAlloc(GetProcessHeap(), 0, Tests[i].MaxDataSize);
|
||||||
|
ok(Data != NULL, "Failed to allocate memory for data of size %lu\n", Tests[i].MaxDataSize);
|
||||||
|
if (Data)
|
||||||
|
{
|
||||||
|
RtlFillMemory(Data, Tests[i].MaxDataSize, 0xCA);
|
||||||
|
|
||||||
|
ClearEventLog(hEventLog, NULL);
|
||||||
|
|
||||||
|
SetLastError(ERROR_SUCCESS);
|
||||||
|
Success = ReportEventW(hEventLog, EVENTLOG_INFORMATION_TYPE, 1, 1, NULL, 0, Tests[i].MaxDataSize, NULL, Data);
|
||||||
|
LastError = GetLastError();
|
||||||
|
/* Small adjustment */
|
||||||
|
if (LastError == ERROR_ENVVAR_NOT_FOUND)
|
||||||
|
LastError = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
ok((LastError == Tests[i].Result[0].LastError) ||
|
||||||
|
broken(LastError == ERROR_INVALID_PARAMETER /* For Win2k3, see above */) ||
|
||||||
|
broken(LastError == Tests[i].Result[1].LastError /* For Vista+ */),
|
||||||
|
"ReportEventW(%u) last error was %lu, expected %lu\n", i, LastError, Tests[i].Result[0].LastError);
|
||||||
|
|
||||||
|
ok((Success == Tests[i].Result[0].Success) || broken(Success == Tests[i].Result[1].Success /* For Vista+ */),
|
||||||
|
"ReportEventW(%u) returned 0x%x, expected %s\n", i, Success, (Tests[i].Result[0].Success ? "TRUE" : "FALSE"));
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, Data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearEventLog(hEventLog, NULL);
|
||||||
|
|
||||||
|
CloseEventLog(hEventLog);
|
||||||
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
extern void func_CreateService(void);
|
extern void func_CreateService(void);
|
||||||
extern void func_DuplicateTokenEx(void);
|
extern void func_DuplicateTokenEx(void);
|
||||||
|
extern void func_eventlog(void);
|
||||||
extern void func_HKEY_CLASSES_ROOT(void);
|
extern void func_HKEY_CLASSES_ROOT(void);
|
||||||
extern void func_IsTextUnicode(void);
|
extern void func_IsTextUnicode(void);
|
||||||
extern void func_LockDatabase(void);
|
extern void func_LockDatabase(void);
|
||||||
|
@ -18,6 +19,7 @@ const struct test winetest_testlist[] =
|
||||||
{
|
{
|
||||||
{ "CreateService", func_CreateService },
|
{ "CreateService", func_CreateService },
|
||||||
{ "DuplicateTokenEx", func_DuplicateTokenEx },
|
{ "DuplicateTokenEx", func_DuplicateTokenEx },
|
||||||
|
{ "eventlog", func_eventlog },
|
||||||
{ "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT },
|
{ "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT },
|
||||||
{ "IsTextUnicode" , func_IsTextUnicode },
|
{ "IsTextUnicode" , func_IsTextUnicode },
|
||||||
{ "LockDatabase" , func_LockDatabase },
|
{ "LockDatabase" , func_LockDatabase },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue