2006-06-14 14:19:50 +02:00
|
|
|
/*
|
|
|
|
* Unit test suite for version functions
|
|
|
|
*
|
|
|
|
* Copyright 2006 Robert Shearman
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2006-06-28 18:57:37 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
2006-06-14 14:19:50 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
|
2006-06-28 18:57:37 +02:00
|
|
|
static BOOL (WINAPI * pVerifyVersionInfoA)(LPOSVERSIONINFOEXA, DWORD, DWORDLONG);
|
|
|
|
static ULONGLONG (WINAPI * pVerSetConditionMask)(ULONGLONG, DWORD, BYTE);
|
|
|
|
|
|
|
|
#define KERNEL32_GET_PROC(func) \
|
|
|
|
p##func = (void *)GetProcAddress(hKernel32, #func); \
|
|
|
|
if(!p##func) trace("GetProcAddress(hKernel32, '%s') failed\n", #func);
|
|
|
|
|
|
|
|
static void init_function_pointers(void)
|
|
|
|
{
|
|
|
|
HMODULE hKernel32;
|
|
|
|
|
|
|
|
pVerifyVersionInfoA = NULL;
|
|
|
|
pVerSetConditionMask = NULL;
|
|
|
|
|
|
|
|
hKernel32 = GetModuleHandleA("kernel32.dll");
|
|
|
|
assert(hKernel32);
|
|
|
|
KERNEL32_GET_PROC(VerifyVersionInfoA);
|
|
|
|
KERNEL32_GET_PROC(VerSetConditionMask);
|
|
|
|
}
|
|
|
|
|
2006-06-14 14:19:50 +02:00
|
|
|
START_TEST(version)
|
|
|
|
{
|
|
|
|
OSVERSIONINFOEX info = { sizeof(info) };
|
|
|
|
BOOL ret;
|
|
|
|
|
2006-06-28 18:57:37 +02:00
|
|
|
init_function_pointers();
|
|
|
|
if(!pVerifyVersionInfoA || !pVerSetConditionMask) return;
|
|
|
|
|
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION,
|
|
|
|
pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
|
2006-07-17 13:09:27 +02:00
|
|
|
ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_BUILDNUMBER | VER_MAJORVERSION |
|
2006-06-14 14:19:50 +02:00
|
|
|
VER_MINORVERSION/* | VER_PLATFORMID | VER_SERVICEPACKMAJOR |
|
|
|
|
VER_SERVICEPACKMINOR | VER_SUITENAME | VER_PRODUCT_TYPE */,
|
2006-06-28 18:57:37 +02:00
|
|
|
pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
|
2006-06-14 14:19:50 +02:00
|
|
|
todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
|
2006-06-28 18:57:37 +02:00
|
|
|
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
/* tests special handling of VER_SUITENAME */
|
|
|
|
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_SUITENAME,
|
|
|
|
pVerSetConditionMask(0, VER_SUITENAME, VER_AND));
|
|
|
|
ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_SUITENAME,
|
|
|
|
pVerSetConditionMask(0, VER_SUITENAME, VER_OR));
|
|
|
|
ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
/* test handling of version numbers */
|
|
|
|
|
|
|
|
/* v3.10 is always less than v4.x even
|
|
|
|
* if the minor version is tested */
|
|
|
|
info.dwMajorVersion = 3;
|
|
|
|
info.dwMinorVersion = 10;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
|
2006-06-14 14:19:50 +02:00
|
|
|
VER_MAJORVERSION, VER_GREATER_EQUAL));
|
2006-06-28 18:57:37 +02:00
|
|
|
todo_wine ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
info.dwMinorVersion = 0;
|
|
|
|
info.wServicePackMajor = 10;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
|
2006-06-14 14:19:50 +02:00
|
|
|
VER_MAJORVERSION, VER_GREATER_EQUAL));
|
2006-06-28 18:57:37 +02:00
|
|
|
todo_wine ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
info.wServicePackMajor = 0;
|
|
|
|
info.wServicePackMinor = 10;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
|
2006-06-14 14:19:50 +02:00
|
|
|
VER_MAJORVERSION, VER_GREATER_EQUAL));
|
2006-06-28 18:57:37 +02:00
|
|
|
todo_wine ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
GetVersionEx((OSVERSIONINFO *)&info);
|
|
|
|
info.wServicePackMinor++;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
|
2006-07-17 13:09:27 +02:00
|
|
|
ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
|
2006-06-28 18:57:37 +02:00
|
|
|
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
/* test the failure hierarchy for the four version fields */
|
|
|
|
|
|
|
|
GetVersionEx((OSVERSIONINFO *)&info);
|
|
|
|
info.wServicePackMajor++;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
|
2006-07-17 13:09:27 +02:00
|
|
|
ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
|
2006-06-28 18:57:37 +02:00
|
|
|
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
GetVersionEx((OSVERSIONINFO *)&info);
|
|
|
|
info.dwMinorVersion++;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
|
2006-06-14 14:19:50 +02:00
|
|
|
ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
|
2006-06-28 18:57:37 +02:00
|
|
|
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
GetVersionEx((OSVERSIONINFO *)&info);
|
|
|
|
info.dwMajorVersion++;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
|
2006-06-14 14:19:50 +02:00
|
|
|
todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
|
2006-06-28 18:57:37 +02:00
|
|
|
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
|
2006-07-17 13:09:27 +02:00
|
|
|
ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
GetVersionEx((OSVERSIONINFO *)&info);
|
|
|
|
info.dwBuildNumber++;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
|
2006-06-14 14:19:50 +02:00
|
|
|
todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
|
2006-06-28 18:57:37 +02:00
|
|
|
"VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
|
|
|
pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
|
2006-07-17 13:09:27 +02:00
|
|
|
ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
|
|
|
|
/* test bad dwOSVersionInfoSize */
|
|
|
|
GetVersionEx((OSVERSIONINFO *)&info);
|
|
|
|
info.dwOSVersionInfoSize = 0;
|
2006-06-28 18:57:37 +02:00
|
|
|
ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
|
2006-07-17 13:09:27 +02:00
|
|
|
pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
|
|
|
|
ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
|
2006-06-14 14:19:50 +02:00
|
|
|
}
|