~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/kernel32/tests/version.c

Version: ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Unit test suite for version functions
  3  *
  4  * Copyright 2006 Robert Shearman
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #include <assert.h>
 22 
 23 #include "wine/test.h"
 24 #include "winbase.h"
 25 
 26 static BOOL (WINAPI * pVerifyVersionInfoA)(LPOSVERSIONINFOEXA, DWORD, DWORDLONG);
 27 static ULONGLONG (WINAPI * pVerSetConditionMask)(ULONGLONG, DWORD, BYTE);
 28 
 29 #define KERNEL32_GET_PROC(func)                                     \
 30     p##func = (void *)GetProcAddress(hKernel32, #func);             \
 31     if(!p##func) trace("GetProcAddress(hKernel32, '%s') failed\n", #func);
 32 
 33 static void init_function_pointers(void)
 34 {
 35     HMODULE hKernel32;
 36 
 37     pVerifyVersionInfoA = NULL;
 38     pVerSetConditionMask = NULL;
 39 
 40     hKernel32 = GetModuleHandleA("kernel32.dll");
 41     assert(hKernel32);
 42     KERNEL32_GET_PROC(VerifyVersionInfoA);
 43     KERNEL32_GET_PROC(VerSetConditionMask);
 44 }
 45 
 46 static void test_GetVersionEx(void)
 47 {
 48     OSVERSIONINFOA infoA;
 49     OSVERSIONINFOEXA infoExA;
 50     BOOL ret;
 51 
 52     if (0)
 53     {
 54         /* Silently crashes on XP */
 55         ret = GetVersionExA(NULL);
 56     }
 57 
 58     SetLastError(0xdeadbeef);
 59     memset(&infoA,0,sizeof infoA);
 60     ret = GetVersionExA(&infoA);
 61     ok(!ret, "Expected GetVersionExA to fail\n");
 62     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
 63         GetLastError() == 0xdeadbeef /* Win9x */,
 64         "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
 65         GetLastError());
 66 
 67     SetLastError(0xdeadbeef);
 68     infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA) / 2;
 69     ret = GetVersionExA(&infoA);
 70     ok(!ret, "Expected GetVersionExA to fail\n");
 71     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
 72         GetLastError() == 0xdeadbeef /* Win9x */,
 73         "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
 74         GetLastError());
 75 
 76     SetLastError(0xdeadbeef);
 77     infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA) * 2;
 78     ret = GetVersionExA(&infoA);
 79     ok(!ret, "Expected GetVersionExA to fail\n");
 80     ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
 81         GetLastError() == 0xdeadbeef /* Win9x */,
 82         "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
 83         GetLastError());
 84 
 85     SetLastError(0xdeadbeef);
 86     infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
 87     ret = GetVersionExA(&infoA);
 88     ok(ret, "Expected GetVersionExA to succeed\n");
 89     ok(GetLastError() == 0xdeadbeef,
 90         "Expected 0xdeadbeef, got %d\n", GetLastError());
 91 
 92     SetLastError(0xdeadbeef);
 93     infoExA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
 94     ret = GetVersionExA((OSVERSIONINFOA *)&infoExA);
 95     ok(ret ||
 96        broken(ret == 0), /* win95 */
 97        "Expected GetVersionExA to succeed\n");
 98     ok(GetLastError() == 0xdeadbeef,
 99         "Expected 0xdeadbeef, got %d\n", GetLastError());
100 }
101 
102 static void test_VerifyVersionInfo(void)
103 {
104     OSVERSIONINFOEX info = { sizeof(info) };
105     BOOL ret;
106     DWORD servicepack;
107 
108     if(!pVerifyVersionInfoA || !pVerSetConditionMask)
109     {
110         skip("Needed functions not available\n");
111         return;
112     }
113 
114     /* Before we start doing some tests we should check what the version of
115      * the ServicePack is. Tests on a box with no ServicePack will fail otherwise.
116      */
117     GetVersionEx((OSVERSIONINFO *)&info);
118     servicepack = info.wServicePackMajor;
119     memset(&info, 0, sizeof(info));
120     info.dwOSVersionInfoSize = sizeof(info);
121 
122     ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION,
123         pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
124     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
125 
126     ret = pVerifyVersionInfoA(&info, VER_BUILDNUMBER | VER_MAJORVERSION |
127         VER_MINORVERSION/* | VER_PLATFORMID | VER_SERVICEPACKMAJOR |
128         VER_SERVICEPACKMINOR | VER_SUITENAME | VER_PRODUCT_TYPE */,
129         pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
130     ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
131         "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
132 
133     /* tests special handling of VER_SUITENAME */
134 
135     ret = pVerifyVersionInfoA(&info, VER_SUITENAME,
136         pVerSetConditionMask(0, VER_SUITENAME, VER_AND));
137     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
138 
139     ret = pVerifyVersionInfoA(&info, VER_SUITENAME,
140         pVerSetConditionMask(0, VER_SUITENAME, VER_OR));
141     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
142 
143     /* test handling of version numbers */
144     
145     /* v3.10 is always less than v4.x even
146      * if the minor version is tested */
147     info.dwMajorVersion = 3;
148     info.dwMinorVersion = 10;
149     ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
150         pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
151             VER_MAJORVERSION, VER_GREATER_EQUAL));
152     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
153 
154     info.dwMinorVersion = 0;
155     info.wServicePackMajor = 10;
156     ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
157         pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
158             VER_MAJORVERSION, VER_GREATER_EQUAL));
159     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
160 
161     info.wServicePackMajor = 0;
162     info.wServicePackMinor = 10;
163     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
164         pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
165             VER_MAJORVERSION, VER_GREATER_EQUAL));
166     if (servicepack == 0)
167     {
168         ok(!ret || broken(ret), /* win2k3 */
169            "VerifyVersionInfoA should have failed\n");
170         ok(GetLastError() == ERROR_OLD_WIN_VERSION,
171             "Expected ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
172     }
173     else
174         ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
175 
176     GetVersionEx((OSVERSIONINFO *)&info);
177     info.wServicePackMinor++;
178     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
179         pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
180     ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
181         "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
182 
183     if (servicepack == 0)
184     {
185         skip("There is no ServicePack on this system\n");
186     }
187     else
188     {
189         GetVersionEx((OSVERSIONINFO *)&info);
190         info.wServicePackMajor--;
191         ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
192             pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER));
193         ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
194 
195         GetVersionEx((OSVERSIONINFO *)&info);
196         info.wServicePackMajor--;
197         ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
198             pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
199         ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
200     }
201 
202     GetVersionEx((OSVERSIONINFO *)&info);
203     info.wServicePackMajor++;
204     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
205         pVerSetConditionMask(0, VER_MINORVERSION, VER_LESS));
206     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
207 
208     GetVersionEx((OSVERSIONINFO *)&info);
209     info.wServicePackMajor++;
210     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
211         pVerSetConditionMask(0, VER_MINORVERSION, VER_LESS_EQUAL));
212     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
213 
214     GetVersionEx((OSVERSIONINFO *)&info);
215     info.wServicePackMajor--;
216     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
217         pVerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL));
218     ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
219         "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
220 
221     /* test the failure hierarchy for the four version fields */
222 
223     GetVersionEx((OSVERSIONINFO *)&info);
224     info.wServicePackMajor++;
225     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
226         pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
227     ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
228         "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
229 
230     GetVersionEx((OSVERSIONINFO *)&info);
231     info.dwMinorVersion++;
232     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
233         pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
234     ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
235         "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
236 
237     GetVersionEx((OSVERSIONINFO *)&info);
238     info.dwMajorVersion++;
239     ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
240         pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
241     ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
242         "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
243 
244     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
245         pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
246     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
247 
248 
249     GetVersionEx((OSVERSIONINFO *)&info);
250     info.dwBuildNumber++;
251     ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
252         pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
253     ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
254         "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
255 
256     ret = pVerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
257         pVerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
258     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
259 
260     /* test bad dwOSVersionInfoSize */
261     GetVersionEx((OSVERSIONINFO *)&info);
262     info.dwOSVersionInfoSize = 0;
263     ret = pVerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
264         pVerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
265     ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
266 }
267 
268 START_TEST(version)
269 {
270     init_function_pointers();
271 
272     test_GetVersionEx();
273     test_VerifyVersionInfo();
274 }
275 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.