Commit 67201a14 authored by Stefan Leichter's avatar Stefan Leichter Committed by Alexandre Julliard

rasapi32: RasEnumDevicesA test: initialize the input parameters before each…

rasapi32: RasEnumDevicesA test: initialize the input parameters before each call, make sure the return buffer is big enough.
parent b54b282a
...@@ -44,69 +44,82 @@ static void test_rasenum(void) ...@@ -44,69 +44,82 @@ static void test_rasenum(void)
{ {
DWORD result; DWORD result;
DWORD cDevices = 0; DWORD cDevices = 0;
DWORD cb = 0; DWORD bufsize = 0, cb = 0;
RASDEVINFOA rasDevInfo; LPRASDEVINFOA rasDevInfo;
rasDevInfo.dwSize = sizeof(rasDevInfo);
if(!pRasEnumDevicesA) { if(!pRasEnumDevicesA) {
win_skip("Skipping RasEnumDevicesA tests, function not present\n"); win_skip("Skipping RasEnumDevicesA tests, function not present\n");
return; return;
} }
/* test first parameter */ /* create the return buffer */
result = pRasEnumDevicesA(NULL, &cb, &cDevices); result = pRasEnumDevicesA(NULL, &bufsize, &cDevices);
trace("RasEnumDevicesA: buffersize %d\n", cb); trace("RasEnumDevicesA: buffersize %d\n", cb);
ok(result == ERROR_BUFFER_TOO_SMALL, ok(result == ERROR_BUFFER_TOO_SMALL,
"Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result); "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
cb = sizeof(rasDevInfo); rasDevInfo = (LPRASDEVINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
max(bufsize,sizeof(RASDEVINFOA)));
if(!rasDevInfo) {
win_skip("failed to allocate buffer for RasEnumDevicesA tests\n");
return;
}
/* test first parameter */
cb = bufsize;
result = pRasEnumDevicesA(NULL, &cb, &cDevices); result = pRasEnumDevicesA(NULL, &cb, &cDevices);
ok(result == ERROR_BUFFER_TOO_SMALL, ok(result == ERROR_BUFFER_TOO_SMALL,
"Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result); "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
rasDevInfo.dwSize = 0; rasDevInfo[0].dwSize = 0;
result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices); cb = bufsize;
result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
todo_wine todo_wine
ok(result == ERROR_INVALID_SIZE, ok(result == ERROR_INVALID_SIZE,
"Expected ERROR_INVALID_SIZE, got %08d\n", result); "Expected ERROR_INVALID_SIZE, got %08d\n", result);
rasDevInfo.dwSize = sizeof(rasDevInfo) -1; rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) -1;
result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices); cb = bufsize;
result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
todo_wine todo_wine
ok(result == ERROR_INVALID_SIZE, ok(result == ERROR_INVALID_SIZE,
"Expected ERROR_INVALID_SIZE, got %08d\n", result); "Expected ERROR_INVALID_SIZE, got %08d\n", result);
rasDevInfo.dwSize = sizeof(rasDevInfo) +1; rasDevInfo[0].dwSize = sizeof(RASDEVINFOA) +1;
result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices); cb = bufsize;
result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
todo_wine todo_wine
ok(result == ERROR_INVALID_SIZE, ok(result == ERROR_INVALID_SIZE,
"Expected ERROR_INVALID_SIZE, got %08d\n", result); "Expected ERROR_INVALID_SIZE, got %08d\n", result);
/* test second parameter */ /* test second parameter */
rasDevInfo.dwSize = sizeof(rasDevInfo); rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
result = pRasEnumDevicesA(&rasDevInfo, NULL, &cDevices); result = pRasEnumDevicesA(rasDevInfo, NULL, &cDevices);
ok(result == ERROR_INVALID_PARAMETER, ok(result == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %08d\n", result); "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
cb = 0; cb = 0;
result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices); result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
ok(result == ERROR_BUFFER_TOO_SMALL, ok(result == ERROR_BUFFER_TOO_SMALL,
"Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result); "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
cb = sizeof(rasDevInfo) -1; rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices); cb = bufsize -1;
result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
ok(result == ERROR_BUFFER_TOO_SMALL, ok(result == ERROR_BUFFER_TOO_SMALL,
"Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result); "Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result);
cb = sizeof(rasDevInfo) +1; rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices); cb = bufsize +1;
todo_wine result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
ok(result == ERROR_BUFFER_TOO_SMALL, ok(result == ERROR_SUCCESS,
"Expected ERROR_BUFFER_TOO_SMALL, got %08d\n", result); "Expected ERROR_SUCCESS, got %08d\n", result);
/* test third parameter */ /* test third parameter */
cb = sizeof(rasDevInfo); rasDevInfo[0].dwSize = sizeof(RASDEVINFOA);
result = pRasEnumDevicesA(&rasDevInfo, &cb, NULL); cb = bufsize;
result = pRasEnumDevicesA(rasDevInfo, &cb, NULL);
ok(result == ERROR_INVALID_PARAMETER, ok(result == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %08d\n", result); "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
...@@ -120,11 +133,13 @@ static void test_rasenum(void) ...@@ -120,11 +133,13 @@ static void test_rasenum(void)
"Expected ERROR_INVALID_PARAMETER, got %08d\n", result); "Expected ERROR_INVALID_PARAMETER, got %08d\n", result);
cb = 0; cb = 0;
rasDevInfo.dwSize = 0; rasDevInfo[0].dwSize = 0;
result = pRasEnumDevicesA(&rasDevInfo, &cb, &cDevices); result = pRasEnumDevicesA(rasDevInfo, &cb, &cDevices);
todo_wine todo_wine
ok(result == ERROR_INVALID_SIZE, ok(result == ERROR_INVALID_SIZE,
"Expected ERROR_INVALID_SIZE, got %08d\n", result); "Expected ERROR_INVALID_SIZE, got %08d\n", result);
HeapFree(GetProcessHeap(), 0, rasDevInfo);
} }
START_TEST(rasapi) START_TEST(rasapi)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment