ReactOS 0.4.15-dev-8109-gd7be748
rasapi.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <wine/test.h>
#include <windef.h>
#include <winbase.h>
#include "ras.h"
#include "raserror.h"
Include dependency graph for rasapi.c:

Go to the source code of this file.

Macros

#define RASAPI32_GET_PROC(func)
 

Functions

static DWORD (WINAPI *pRasEnumDevicesA)(LPRASDEVINFOA
 
static void InitFunctionPtrs (void)
 
static void test_rasenum (void)
 
 START_TEST (rasapi)
 

Variables

static HMODULE hmodule
 
static LPDWORD
 

Macro Definition Documentation

◆ RASAPI32_GET_PROC

#define RASAPI32_GET_PROC (   func)
Value:
p ## func = (void*)GetProcAddress(hmodule, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
#define GetProcAddress(x, y)
Definition: compat.h:753
GLenum func
Definition: glext.h:6028
GLfloat GLfloat p
Definition: glext.h:8902
static HMODULE hmodule
Definition: rasapi.c:29

Definition at line 32 of file rasapi.c.

Function Documentation

◆ DWORD()

static DWORD ( WINAPI pRasEnumDevicesA)
static

◆ InitFunctionPtrs()

static void InitFunctionPtrs ( void  )
static

Definition at line 37 of file rasapi.c.

38{
39 hmodule = LoadLibraryA("rasapi32.dll");
40
42}
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI RasEnumDevicesA(LPRASDEVINFOA lpRasDevinfo, LPDWORD lpcb, LPDWORD lpcDevices)
Definition: rasapi.c:247
#define RASAPI32_GET_PROC(func)
Definition: rasapi.c:32

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( rasapi  )

Definition at line 179 of file rasapi.c.

180{
182
183 test_rasenum();
184
186}
#define FreeLibrary(x)
Definition: compat.h:748
static void test_rasenum(void)
Definition: rasapi.c:44
static void InitFunctionPtrs(void)
Definition: rasapi.c:37

◆ test_rasenum()

static void test_rasenum ( void  )
static

Definition at line 44 of file rasapi.c.

45{
47 DWORD cDevices = 0;
48 DWORD bufsize = 0, cb = 0;
49 LPRASDEVINFOA rasDevInfo;
50
51 if(!pRasEnumDevicesA) {
52 win_skip("Skipping RasEnumDevicesA tests, function not present\n");
53 return;
54 }
55
56 /* create the return buffer */
57 result = pRasEnumDevicesA(NULL, &bufsize, &cDevices);
60 win_skip("RAS configuration problem\n");
61 return;
62 }
63 if(ERROR_SUCCESS == result) {
64 win_skip("RasEnumDevicesA found nothing to enumerate\n");
65 return;
66 }
67 trace("RasEnumDevicesA: returned %d buffersize %d\n", result, bufsize);
69 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
70
72 max(bufsize,sizeof(RASDEVINFOA)));
73 if(!rasDevInfo) {
74 win_skip("failed to allocate buffer for RasEnumDevicesA tests\n");
75 return;
76 }
77
78 /* test first parameter */
79 cb = bufsize;
80 cDevices = 0xdeadbeef;
81 result = pRasEnumDevicesA(NULL, &cb, &cDevices);
82 ok(0 < cDevices && cDevices < 32, "expected 0 < cDevices < 32, got %u\n", cDevices);
84 result == ERROR_INVALID_USER_BUFFER, /* win98 */
85 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
86
87 rasDevInfo[0].dwSize = 0;
88 cb = bufsize;
89 cDevices = 0xdeadbeef;
90 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
91 ok(cDevices == 0xdeadbeef, "expected cDevices = 0xdeadbeef, got %u\n", cDevices);
93 result == ERROR_INVALID_USER_BUFFER, /* win98 */
94 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
95
96 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) -1;
97 cb = bufsize;
98 cDevices = 0xdeadbeef;
99 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
100 ok(cDevices == 0xdeadbeef, "expected cDevices = 0xdeadbeef, got %u\n", cDevices);
102 result == ERROR_INVALID_USER_BUFFER, /* win98 */
103 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
104
105 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) +1;
106 cb = bufsize;
107 cDevices = 0xdeadbeef;
108 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
109 ok(cDevices == 0xdeadbeef, "expected cDevices = 0xdeadbeef, got %u\n", cDevices);
111 result == ERROR_INVALID_USER_BUFFER, /* win98 */
112 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
113
114 /* test second parameter */
115 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
116 cDevices = 0xdeadbeef;
117 result = pRasEnumDevicesA(rasDevInfo, NULL, &cDevices);
118 ok(cDevices == 0xdeadbeef, "expected cDevices = 0xdeadbeef, got %u\n", cDevices);
120 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
121
122 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
123 cb = 0;
124 cDevices = 0xdeadbeef;
125 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
127 ok(cDevices == 0xdeadbeef, "expected cDevices = 0xdeadbeef, got %u\n", cDevices);
129 result == ERROR_INVALID_SIZE, /* vista, 2k8 */
130 "Expected ERROR_BUFFER_TOO_SMALL/ERROR_INVALID_SIZE, got %08d\n", result);
131
132 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
133 cb = bufsize -1;
134 cDevices = 0xdeadbeef;
135 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
136 ok(0 < cDevices && cDevices < 32, "expected 0 < cDevices < 32, got %u\n", cDevices);
138 "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
139
140 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
141 cb = bufsize +1;
142 cDevices = 0xdeadbeef;
143 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
144 ok(0 < cDevices && cDevices < 32, "expected 0 < cDevices < 32, got %u\n", cDevices);
146 "Expected ERROR_SUCCESS, got %08d\n", result);
147
148 /* test third parameter */
149 rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
150 cb = bufsize;
151 result = pRasEnumDevicesA(rasDevInfo, &cb, NULL);
153 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
154
155 /* test combinations of invalid parameters */
156 cDevices = 0xdeadbeef;
157 result = pRasEnumDevicesA(NULL, NULL, &cDevices);
158 ok(cDevices == 0xdeadbeef, "expected cDevices = 0xdeadbeef, got %u\n", cDevices);
160 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
161
162 result = pRasEnumDevicesA(NULL, &cb, NULL);
164 result == ERROR_INVALID_USER_BUFFER, /* win98 */
165 "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
166
167 cb = 0;
168 rasDevInfo[0].dwSize = 0;
169 cDevices = 0xdeadbeef;
170 result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
171 ok(cDevices == 0xdeadbeef, "expected cDevices = 0xdeadbeef, got %u\n", cDevices);
173 broken(result == ERROR_BUFFER_TOO_SMALL), /* win98 */
174 "Expected ERROR_INVALID_SIZE, got %08d\n", result);
175
176 HeapFree(GetProcessHeap(), 0, rasDevInfo);
177}
#define broken(x)
Definition: _sntprintf.h:21
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
GLuint64EXT * result
Definition: glext.h:11304
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define todo_wine
Definition: custom.c:79
struct tagRASDEVINFOA RASDEVINFOA
#define ERROR_STATE_MACHINES_NOT_STARTED
Definition: raserror.h:101
#define ERROR_INVALID_SIZE
Definition: raserror.h:38
#define ERROR_RASMAN_CANNOT_INITIALIZE
Definition: raserror.h:117
#define ERROR_BUFFER_TOO_SMALL
Definition: raserror.h:9
#define win_skip
Definition: test.h:163
DWORD dwSize
Definition: ras.h:509
#define max(a, b)
Definition: svc.c:63
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091

Referenced by START_TEST().

Variable Documentation

◆ hmodule

◆ LPDWORD

Definition at line 30 of file rasapi.c.