ReactOS 0.4.15-dev-7842-g558ab78
Example_user.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Kernel-Mode Test Suite Example user-mode test part
5 * COPYRIGHT: Copyright 2011-2018 Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include <kmt_test.h>
9
10#include "Example.h"
11
12START_TEST(Example)
13{
14 /* do some user-mode stuff */
15 SYSTEM_INFO SystemInfo;
16 MY_STRUCT MyStruct[2] = { { 123, ":D" }, { 0 } };
17 DWORD Length = sizeof MyStruct;
19
20 trace("Message from user-mode\n");
21
22 GetSystemInfo(&SystemInfo);
23 ok(SystemInfo.dwActiveProcessorMask != 0, "No active processors?!\n");
24
25 /* now run the kernel-mode part (see Example.c).
26 * If no user-mode part exists, this is what's done automatically */
27 KmtRunKernelTest("Example");
28
29 /* now start the special-purpose driver */
30 Error = KmtLoadAndOpenDriver(L"Example", FALSE);
32 if (Error)
33 return;
34 trace("After Create\n");
35
38 ok(KmtSendBufferToDriver(IOCTL_SEND_MYSTRUCT, MyStruct, sizeof MyStruct[0], &Length) == ERROR_SUCCESS, "\n");
39 ok_eq_int(MyStruct[1].a, 456);
40 ok_eq_str(MyStruct[1].b, "!!!");
41
43 trace("After Close\n");
45 trace("After Unload\n");
46}
#define IOCTL_NOTIFY
Definition: Example.h:17
#define IOCTL_SEND_MYSTRUCT
Definition: Example.h:19
#define IOCTL_SEND_STRING
Definition: Example.h:18
#define ok_eq_str(value, expected)
Definition: apitest.h:82
#define ok_eq_int(value, expected)
Definition: apitest.h:59
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
BOOL Error
Definition: chkdsk.c:66
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
unsigned long DWORD
Definition: ntddk_ex.h:95
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
DWORD_PTR dwActiveProcessorMask
Definition: winbase.h:1176
DWORD KmtRunKernelTest(IN PCSTR TestName)
Definition: support.c:95
DWORD KmtLoadAndOpenDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning)
Definition: support.c:213
VOID KmtCloseDriver(VOID)
Definition: support.c:236
DWORD KmtSendBufferToDriver(IN DWORD ControlCode, IN OUT PVOID Buffer OPTIONAL, IN DWORD InLength, IN OUT PDWORD OutLength)
Definition: support.c:360
DWORD KmtSendStringToDriver(IN DWORD ControlCode, IN PCSTR String)
Definition: support.c:283
DWORD KmtSendToDriver(IN DWORD ControlCode)
Definition: support.c:259
VOID KmtUnloadDriver(VOID)
Definition: support.c:167