kernel32: Add some simple tests for GetVersionExA.

This commit is contained in:
Paul Vriens 2007-11-30 17:52:44 +01:00 committed by Alexandre Julliard
parent 29d66b48ef
commit b3a85a3fc4
2 changed files with 53 additions and 0 deletions

View File

@ -43,12 +43,64 @@ static void init_function_pointers(void)
KERNEL32_GET_PROC(VerSetConditionMask);
}
static void test_GetVersionEx(void)
{
OSVERSIONINFOA infoA;
OSVERSIONINFOEXA infoExA;
BOOL ret;
if (0)
{
/* Silently crashes on XP */
ret = GetVersionExA(NULL);
}
SetLastError(0xdeadbeef);
memset(&infoA,0,sizeof infoA);
ret = GetVersionExA(&infoA);
ok(!ret, "Expected GetVersionExA to fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
SetLastError(0xdeadbeef);
infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA) / 2;
ret = GetVersionExA(&infoA);
ok(!ret, "Expected GetVersionExA to fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
SetLastError(0xdeadbeef);
infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA) * 2;
ret = GetVersionExA(&infoA);
ok(!ret, "Expected GetVersionExA to fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
SetLastError(0xdeadbeef);
infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
ret = GetVersionExA(&infoA);
ok(ret, "Expected GetVersionExA to succeed\n");
ok(GetLastError() == 0xdeadbeef,
"Expected 0xdeadbeef, got %d\n", GetLastError());
SetLastError(0xdeadbeef);
infoExA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
ret = GetVersionExA((OSVERSIONINFOA *)&infoExA);
ok(ret, "Expected GetVersionExA to succeed\n");
ok(GetLastError() == 0xdeadbeef,
"Expected 0xdeadbeef, got %d\n", GetLastError());
}
START_TEST(version)
{
OSVERSIONINFOEX info = { sizeof(info) };
BOOL ret;
init_function_pointers();
test_GetVersionEx();
if(!pVerifyVersionInfoA || !pVerSetConditionMask)
{
skip("Needed functions not available\n");

View File

@ -154,6 +154,7 @@ BOOL WINAPI GetVersionExA(OSVERSIONINFOA *v)
{
WARN("wrong OSVERSIONINFO size from app (got: %d)\n",
v->dwOSVersionInfoSize );
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}