wine.inf: We should not override existing associations.
[wine/hacks.git] / dlls / kernel / tests / version.c
blobc4ac6ea024d3a36941f9f578d5c32158f4f7978b
1 /*
2 * Unit test suite for version functions
4 * Copyright 2006 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <assert.h>
23 #include "wine/test.h"
24 #include "winbase.h"
26 static BOOL (WINAPI * pVerifyVersionInfoA)(LPOSVERSIONINFOEXA, DWORD, DWORDLONG);
27 static ULONGLONG (WINAPI * pVerSetConditionMask)(ULONGLONG, DWORD, BYTE);
29 #define KERNEL32_GET_PROC(func) \
30 p##func = (void *)GetProcAddress(hKernel32, #func); \
31 if(!p##func) trace("GetProcAddress(hKernel32, '%s') failed\n", #func);
33 static void init_function_pointers(void)
35 HMODULE hKernel32;
37 pVerifyVersionInfoA = NULL;
38 pVerSetConditionMask = NULL;
40 hKernel32 = GetModuleHandleA("kernel32.dll");
41 assert(hKernel32);
42 KERNEL32_GET_PROC(VerifyVersionInfoA);
43 KERNEL32_GET_PROC(VerSetConditionMask);
46 START_TEST(version)
48 OSVERSIONINFOEX info = { sizeof(info) };
49 BOOL ret;
51 init_function_pointers();
52 if(!pVerifyVersionInfoA || !pVerSetConditionMask) return;
54 ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION,
55 pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
56 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
58 ret = pVerifyVersionInfoA(&info, VER_BUILDNUMBER | VER_MAJORVERSION |
59 VER_MINORVERSION/* | VER_PLATFORMID | VER_SERVICEPACKMAJOR |
60 VER_SERVICEPACKMINOR | VER_SUITENAME | VER_PRODUCT_TYPE */,
61 pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
62 ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
63 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
65 /* tests special handling of VER_SUITENAME */
67 ret = pVerifyVersionInfoA(&info, VER_SUITENAME,
68 pVerSetConditionMask(0, VER_SUITENAME, VER_AND));
69 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
71 ret = pVerifyVersionInfoA(&info, VER_SUITENAME,
72 pVerSetConditionMask(0, VER_SUITENAME, VER_OR));
73 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
75 /* test handling of version numbers */
77 /* v3.10 is always less than v4.x even
78 * if the minor version is tested */
79 info.dwMajorVersion = 3;
80 info.dwMinorVersion = 10;
81 ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
82 pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
83 VER_MAJORVERSION, VER_GREATER_EQUAL));
84 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
86 info.dwMinorVersion = 0;
87 info.wServicePackMajor = 10;
88 ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
89 pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
90 VER_MAJORVERSION, VER_GREATER_EQUAL));
91 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
93 info.wServicePackMajor = 0;
94 info.wServicePackMinor = 10;
95 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
96 pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
97 VER_MAJORVERSION, VER_GREATER_EQUAL));
98 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
100 GetVersionEx((OSVERSIONINFO *)&info);
101 info.wServicePackMinor++;
102 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
103 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
104 ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
105 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
107 GetVersionEx((OSVERSIONINFO *)&info);
108 info.wServicePackMajor--;
109 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
110 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER));
111 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
113 GetVersionEx((OSVERSIONINFO *)&info);
114 info.wServicePackMajor--;
115 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
116 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
117 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
119 GetVersionEx((OSVERSIONINFO *)&info);
120 info.wServicePackMajor++;
121 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
122 pVerSetConditionMask(0, VER_MINORVERSION, VER_LESS));
123 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
125 GetVersionEx((OSVERSIONINFO *)&info);
126 info.wServicePackMajor++;
127 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
128 pVerSetConditionMask(0, VER_MINORVERSION, VER_LESS_EQUAL));
129 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
131 GetVersionEx((OSVERSIONINFO *)&info);
132 info.wServicePackMajor--;
133 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
134 pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL));
135 ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
136 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
138 /* test the failure hierarchy for the four version fields */
140 GetVersionEx((OSVERSIONINFO *)&info);
141 info.wServicePackMajor++;
142 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
143 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
144 ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
145 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
147 GetVersionEx((OSVERSIONINFO *)&info);
148 info.dwMinorVersion++;
149 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
150 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
151 ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
152 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
154 GetVersionEx((OSVERSIONINFO *)&info);
155 info.dwMajorVersion++;
156 ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
157 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
158 ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
159 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
161 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
162 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
163 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
166 GetVersionEx((OSVERSIONINFO *)&info);
167 info.dwBuildNumber++;
168 ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
169 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
170 ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
171 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
173 ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
174 pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
175 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());
177 /* test bad dwOSVersionInfoSize */
178 GetVersionEx((OSVERSIONINFO *)&info);
179 info.dwOSVersionInfoSize = 0;
180 ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
181 pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
182 ok(ret, "VerifyVersionInfoA failed with error %ld\n", GetLastError());