winex11.drv: Map coordinates before calling send_mouse_input.
[wine/zf.git] / dlls / kernel32 / tests / version.c
blob861b870b569812aa0ccc86b55b6bb84d9dd43303
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 "wine/test.h"
22 #include "winbase.h"
23 #include "winternl.h"
25 static BOOL (WINAPI * pGetProductInfo)(DWORD, DWORD, DWORD, DWORD, DWORD *);
26 static UINT (WINAPI * pGetSystemFirmwareTable)(DWORD, DWORD, void *, DWORD);
27 static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, void *, ULONG, ULONG *);
28 static NTSTATUS (WINAPI * pRtlGetVersion)(RTL_OSVERSIONINFOEXW *);
30 #define GET_PROC(func) \
31 p##func = (void *)GetProcAddress(hmod, #func);
33 /* Firmware table providers */
34 #define ACPI 0x41435049
35 #define FIRM 0x4649524D
36 #define RSMB 0x52534D42
38 static void init_function_pointers(void)
40 HMODULE hmod;
42 hmod = GetModuleHandleA("kernel32.dll");
44 GET_PROC(GetProductInfo);
45 GET_PROC(GetSystemFirmwareTable);
47 hmod = GetModuleHandleA("ntdll.dll");
49 GET_PROC(NtQuerySystemInformation);
50 GET_PROC(RtlGetVersion);
53 static void test_GetProductInfo(void)
55 DWORD product;
56 DWORD res;
57 DWORD table[] = {9,8,7,6,
58 7,0,0,0,
59 6,2,0,0,
60 6,1,2,0,
61 6,1,1,0,
62 6,1,0,2,
63 6,1,0,0,
64 6,0,3,0,
65 6,0,2,0,
66 6,0,1,5,
67 6,0,1,0,
68 6,0,0,0,
69 5,3,0,0,
70 5,2,0,0,
71 5,1,0,0,
72 5,0,0,0,
73 0};
75 DWORD *entry = table;
77 if (!pGetProductInfo)
79 /* Not present before Vista */
80 win_skip("GetProductInfo() not available\n");
81 return;
84 while (*entry)
86 /* SetLastError() / GetLastError(): value is untouched */
87 product = 0xdeadbeef;
88 SetLastError(0xdeadbeef);
89 res = pGetProductInfo(entry[0], entry[1], entry[2], entry[3], &product);
91 if (entry[0] >= 6)
92 ok(res && (product > PRODUCT_UNDEFINED) && (product <= PRODUCT_ENTERPRISE_S_N_EVALUATION),
93 "got %d and 0x%x (expected TRUE and a valid PRODUCT_* value)\n", res, product);
94 else
95 ok(!res && !product && (GetLastError() == 0xdeadbeef),
96 "got %d and 0x%x with 0x%x (expected FALSE and PRODUCT_UNDEFINED with LastError untouched)\n",
97 res, product, GetLastError());
99 entry+= 4;
102 /* NULL pointer is not a problem */
103 SetLastError(0xdeadbeef);
104 res = pGetProductInfo(6, 1, 0, 0, NULL);
105 ok( (!res) && (GetLastError() == 0xdeadbeef),
106 "got %d with 0x%x (expected FALSE with LastError untouched\n", res, GetLastError());
109 static void test_GetVersionEx(void)
111 OSVERSIONINFOA infoA;
112 OSVERSIONINFOEXA infoExA;
113 BOOL ret;
115 if (0)
117 /* Silently crashes on XP */
118 GetVersionExA(NULL);
121 SetLastError(0xdeadbeef);
122 memset(&infoA,0,sizeof infoA);
123 ret = GetVersionExA(&infoA);
124 ok(!ret, "Expected GetVersionExA to fail\n");
125 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
126 GetLastError() == 0xdeadbeef /* Win9x */,
127 "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
128 GetLastError());
130 SetLastError(0xdeadbeef);
131 infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA) / 2;
132 ret = GetVersionExA(&infoA);
133 ok(!ret, "Expected GetVersionExA to fail\n");
134 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
135 GetLastError() == 0xdeadbeef /* Win9x */,
136 "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
137 GetLastError());
139 SetLastError(0xdeadbeef);
140 infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA) * 2;
141 ret = GetVersionExA(&infoA);
142 ok(!ret, "Expected GetVersionExA to fail\n");
143 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
144 GetLastError() == 0xdeadbeef /* Win9x */,
145 "Expected ERROR_INSUFFICIENT_BUFFER or 0xdeadbeef (Win9x), got %d\n",
146 GetLastError());
148 SetLastError(0xdeadbeef);
149 infoA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
150 ret = GetVersionExA(&infoA);
151 ok(ret, "Expected GetVersionExA to succeed\n");
152 ok(GetLastError() == 0xdeadbeef,
153 "Expected 0xdeadbeef, got %d\n", GetLastError());
155 SetLastError(0xdeadbeef);
156 infoExA.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
157 ret = GetVersionExA((OSVERSIONINFOA *)&infoExA);
158 ok(ret, "GetVersionExA failed.\n");
160 if (!infoExA.wServicePackMajor && !infoExA.wServicePackMinor)
161 ok(!infoExA.szCSDVersion[0], "got '%s'\n", infoExA.szCSDVersion);
164 static void test_VerifyVersionInfo(void)
166 enum srcversion_mode
168 SRCVERSION_ZERO = 0,
169 SRCVERSION_CURRENT = 1,
170 SRCVERSION_INC_MINOR = 2,
171 SRCVERSION_INC_SP_MINOR = 3,
172 SRCVERSION_INC_SP_MAJOR = 4,
173 SRCVERSION_DEC_SP_MAJOR = 5,
174 SRCVERSION_DEC_MAJOR = 6,
175 SRCVERSION_INC_BUILD = 7,
176 SRCVERSION_REQUIRES_SP = 0x1000,
179 struct verify_version_test
181 DWORD verifymask; /* Type mask for VerifyVersionInfo() */
182 DWORD srcinfo; /* The way current version info is modified. */
183 DWORD err; /* Error code on failure, 0 on success. */
185 DWORD typemask1;
186 DWORD condition1;
187 DWORD typemask2;
188 DWORD condition2;
189 DWORD typemask3;
190 DWORD condition3;
191 DWORD typemask4;
192 DWORD condition4;
193 } verify_version_tests[] =
196 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
197 SRCVERSION_INC_MINOR,
200 VER_MAJORVERSION, VER_EQUAL,
201 VER_MINORVERSION, VER_LESS,
204 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
205 SRCVERSION_INC_MINOR,
206 ERROR_OLD_WIN_VERSION,
208 VER_MAJORVERSION, VER_GREATER_EQUAL,
209 VER_MINORVERSION, VER_LESS,
212 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
213 SRCVERSION_CURRENT,
216 VER_MAJORVERSION, VER_GREATER_EQUAL,
217 VER_MINORVERSION, VER_LESS,
220 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
221 SRCVERSION_CURRENT,
224 VER_MAJORVERSION, VER_GREATER_EQUAL,
225 VER_MINORVERSION, VER_AND,
228 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
229 SRCVERSION_INC_MINOR,
232 VER_MAJORVERSION, VER_LESS_EQUAL,
233 VER_MINORVERSION, VER_LESS,
236 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
237 SRCVERSION_INC_MINOR,
238 ERROR_OLD_WIN_VERSION,
240 VER_MAJORVERSION, VER_AND,
241 VER_MINORVERSION, VER_LESS,
244 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
245 SRCVERSION_INC_MINOR,
246 ERROR_OLD_WIN_VERSION,
248 VER_MAJORVERSION, VER_OR,
249 VER_MINORVERSION, VER_LESS,
252 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
253 SRCVERSION_INC_SP_MINOR,
254 ERROR_OLD_WIN_VERSION,
256 VER_MINORVERSION, VER_EQUAL,
257 VER_SERVICEPACKMINOR, VER_LESS,
260 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
261 SRCVERSION_INC_SP_MINOR,
262 ERROR_OLD_WIN_VERSION,
264 VER_MAJORVERSION, VER_EQUAL,
265 VER_SERVICEPACKMINOR, VER_LESS,
268 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
269 SRCVERSION_INC_SP_MAJOR,
270 ERROR_OLD_WIN_VERSION,
272 VER_MAJORVERSION, VER_EQUAL,
273 VER_SERVICEPACKMAJOR, VER_EQUAL,
276 VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
277 SRCVERSION_INC_SP_MINOR,
280 VER_SERVICEPACKMAJOR, VER_EQUAL,
281 VER_SERVICEPACKMINOR, VER_LESS,
284 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
285 SRCVERSION_INC_SP_MINOR,
286 ERROR_OLD_WIN_VERSION,
288 VER_SERVICEPACKMAJOR, VER_EQUAL,
289 VER_SERVICEPACKMINOR, VER_LESS,
292 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
293 SRCVERSION_INC_SP_MINOR,
296 VER_MINORVERSION, VER_EQUAL,
297 VER_SERVICEPACKMAJOR, VER_EQUAL,
298 VER_SERVICEPACKMINOR, VER_LESS,
301 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
302 SRCVERSION_INC_SP_MINOR,
303 ERROR_OLD_WIN_VERSION,
305 VER_MINORVERSION, VER_EQUAL,
306 VER_SERVICEPACKMAJOR, VER_EQUAL,
307 VER_SERVICEPACKMINOR, VER_LESS,
310 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
311 SRCVERSION_INC_SP_MINOR,
314 VER_MAJORVERSION, VER_EQUAL,
315 VER_MINORVERSION, VER_EQUAL,
316 VER_SERVICEPACKMAJOR, VER_EQUAL,
317 VER_SERVICEPACKMINOR, VER_LESS,
320 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
321 SRCVERSION_INC_SP_MINOR,
322 ERROR_OLD_WIN_VERSION,
324 VER_MAJORVERSION, VER_EQUAL,
325 VER_MINORVERSION, VER_GREATER_EQUAL,
326 VER_SERVICEPACKMAJOR, VER_EQUAL,
327 VER_SERVICEPACKMINOR, VER_LESS,
330 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
331 SRCVERSION_INC_SP_MAJOR,
334 VER_MAJORVERSION, VER_LESS_EQUAL,
335 VER_SERVICEPACKMAJOR, VER_GREATER,
338 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
339 SRCVERSION_INC_SP_MAJOR,
340 ERROR_OLD_WIN_VERSION,
342 VER_MAJORVERSION, VER_EQUAL,
343 VER_SERVICEPACKMAJOR, VER_LESS,
346 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
347 SRCVERSION_INC_SP_MAJOR,
348 ERROR_OLD_WIN_VERSION,
350 VER_MINORVERSION, VER_EQUAL,
351 VER_SERVICEPACKMAJOR, VER_LESS,
354 VER_MAJORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
355 SRCVERSION_INC_SP_MAJOR,
358 VER_MAJORVERSION, VER_EQUAL,
359 VER_SERVICEPACKMAJOR, VER_LESS,
362 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
363 SRCVERSION_INC_SP_MAJOR,
364 ERROR_OLD_WIN_VERSION,
366 VER_MAJORVERSION, VER_EQUAL,
367 VER_SERVICEPACKMAJOR, VER_LESS,
370 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
371 SRCVERSION_INC_SP_MAJOR,
374 VER_MAJORVERSION, VER_EQUAL,
375 VER_MINORVERSION, VER_EQUAL,
376 VER_SERVICEPACKMAJOR, VER_LESS,
379 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
380 SRCVERSION_INC_SP_MAJOR,
381 ERROR_OLD_WIN_VERSION,
383 VER_MAJORVERSION, VER_GREATER_EQUAL,
384 VER_SERVICEPACKMAJOR, VER_LESS,
387 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
388 SRCVERSION_DEC_MAJOR,
391 VER_MAJORVERSION, VER_GREATER_EQUAL,
392 VER_SERVICEPACKMAJOR, VER_LESS,
395 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
396 SRCVERSION_CURRENT,
399 VER_MAJORVERSION, VER_GREATER_EQUAL,
400 VER_SERVICEPACKMAJOR, VER_LESS,
403 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
404 SRCVERSION_INC_SP_MAJOR,
405 ERROR_OLD_WIN_VERSION,
407 VER_MAJORVERSION, VER_GREATER_EQUAL,
408 VER_MINORVERSION, VER_EQUAL,
409 VER_SERVICEPACKMAJOR, VER_LESS,
412 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
413 SRCVERSION_INC_SP_MAJOR,
414 ERROR_OLD_WIN_VERSION,
416 VER_MAJORVERSION, VER_GREATER_EQUAL,
417 VER_MINORVERSION, VER_GREATER_EQUAL,
418 VER_SERVICEPACKMAJOR, VER_LESS_EQUAL,
421 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
422 SRCVERSION_INC_SP_MAJOR,
423 ERROR_OLD_WIN_VERSION,
425 VER_MAJORVERSION, VER_GREATER_EQUAL,
426 VER_SERVICEPACKMAJOR, VER_AND,
429 VER_MAJORVERSION | VER_MINORVERSION,
430 SRCVERSION_ZERO,
433 VER_MAJORVERSION, VER_GREATER_EQUAL,
436 VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER,
437 SRCVERSION_ZERO,
438 ERROR_OLD_WIN_VERSION,
440 VER_MAJORVERSION, VER_GREATER_EQUAL,
443 VER_SUITENAME,
444 SRCVERSION_ZERO,
447 VER_SUITENAME, VER_AND,
450 VER_SUITENAME,
451 SRCVERSION_ZERO,
454 VER_SUITENAME, VER_OR,
457 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
458 SRCVERSION_INC_SP_MINOR,
459 ERROR_OLD_WIN_VERSION,
461 VER_MINORVERSION, VER_GREATER_EQUAL,
464 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
465 SRCVERSION_INC_SP_MAJOR,
468 VER_MINORVERSION, VER_LESS,
471 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
472 SRCVERSION_INC_SP_MAJOR,
475 VER_MINORVERSION, VER_LESS_EQUAL,
478 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
479 SRCVERSION_INC_SP_MAJOR,
480 ERROR_OLD_WIN_VERSION,
482 VER_MINORVERSION, VER_EQUAL,
485 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
486 SRCVERSION_INC_SP_MAJOR,
487 ERROR_OLD_WIN_VERSION,
489 VER_MINORVERSION, VER_GREATER_EQUAL,
492 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
493 SRCVERSION_INC_MINOR,
494 ERROR_OLD_WIN_VERSION,
496 VER_MINORVERSION, VER_GREATER_EQUAL,
499 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
500 SRCVERSION_INC_MINOR,
501 ERROR_OLD_WIN_VERSION,
503 VER_MINORVERSION, VER_GREATER_EQUAL,
506 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
507 SRCVERSION_CURRENT,
510 VER_MINORVERSION, VER_GREATER_EQUAL,
513 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
514 SRCVERSION_INC_BUILD,
515 ERROR_OLD_WIN_VERSION,
517 VER_MINORVERSION, VER_GREATER_EQUAL,
520 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
521 SRCVERSION_INC_BUILD,
524 VER_MINORVERSION, VER_GREATER_EQUAL,
527 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
528 SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
531 VER_MINORVERSION, VER_GREATER,
534 VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
535 SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
538 VER_MINORVERSION, VER_GREATER_EQUAL,
541 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
542 SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
543 ERROR_OLD_WIN_VERSION,
545 VER_MAJORVERSION, VER_EQUAL,
546 VER_SERVICEPACKMAJOR, VER_GREATER,
549 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
550 SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
553 VER_MAJORVERSION, VER_GREATER_EQUAL,
554 VER_MINORVERSION, VER_EQUAL,
555 VER_SERVICEPACKMAJOR, VER_GREATER,
558 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
559 SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
562 VER_MAJORVERSION, VER_GREATER_EQUAL,
563 VER_MINORVERSION, VER_LESS_EQUAL,
564 VER_SERVICEPACKMAJOR, VER_GREATER,
567 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
568 SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
571 VER_MAJORVERSION, VER_GREATER_EQUAL,
572 VER_MINORVERSION, VER_AND,
573 VER_SERVICEPACKMAJOR, VER_GREATER,
576 VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
577 SRCVERSION_DEC_SP_MAJOR | SRCVERSION_REQUIRES_SP,
578 ERROR_OLD_WIN_VERSION,
580 VER_SERVICEPACKMAJOR, VER_GREATER,
581 VER_SERVICEPACKMINOR, VER_EQUAL,
585 OSVERSIONINFOEXA info;
586 DWORD servicepack;
587 unsigned int i;
588 BOOL ret;
590 /* Before we start doing some tests we should check what the version of
591 * the ServicePack is. Tests on a box with no ServicePack will fail otherwise.
593 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
594 GetVersionExA((OSVERSIONINFOA *)&info);
595 servicepack = info.wServicePackMajor;
596 if (servicepack == 0)
597 skip("There is no ServicePack on this system. Some tests will be skipped.\n");
599 /* Win8.1+ returns Win8 version in GetVersionEx when there's no app manifest targeting 8.1 */
600 if (info.dwMajorVersion == 6 && info.dwMinorVersion == 2)
602 RTL_OSVERSIONINFOEXW rtlinfo;
603 rtlinfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
604 ok(!pRtlGetVersion(&rtlinfo), "RtlGetVersion failed\n");
606 if (rtlinfo.dwMajorVersion != 6 || rtlinfo.dwMinorVersion != 2)
608 skip("GetVersionEx and VerifyVersionInfo are faking values\n");
609 return;
613 for (i = 0; i < ARRAY_SIZE(verify_version_tests); i++)
615 struct verify_version_test *test = &verify_version_tests[i];
616 DWORD srcinfo = test->srcinfo;
617 ULONGLONG mask;
619 if (servicepack == 0 && srcinfo & SRCVERSION_REQUIRES_SP)
620 continue;
621 srcinfo &= ~SRCVERSION_REQUIRES_SP;
623 info.dwOSVersionInfoSize = sizeof(info);
624 GetVersionExA((OSVERSIONINFOA *)&info);
626 switch (srcinfo)
628 case SRCVERSION_ZERO:
629 memset(&info, 0, sizeof(info));
630 break;
631 case SRCVERSION_INC_MINOR:
632 info.dwMinorVersion++;
633 break;
634 case SRCVERSION_INC_SP_MINOR:
635 info.wServicePackMinor++;
636 break;
637 case SRCVERSION_INC_SP_MAJOR:
638 info.wServicePackMajor++;
639 break;
640 case SRCVERSION_DEC_SP_MAJOR:
641 info.wServicePackMajor--;
642 break;
643 case SRCVERSION_DEC_MAJOR:
644 info.dwMajorVersion--;
645 break;
646 case SRCVERSION_INC_BUILD:
647 info.dwBuildNumber++;
648 break;
649 default:
653 mask = VerSetConditionMask(0, test->typemask1, test->condition1);
654 if (test->typemask2)
655 mask = VerSetConditionMask(mask, test->typemask2, test->condition2);
656 if (test->typemask3)
657 mask = VerSetConditionMask(mask, test->typemask3, test->condition3);
658 if (test->typemask4)
659 mask = VerSetConditionMask(mask, test->typemask4, test->condition4);
661 SetLastError(0xdeadbeef);
662 ret = VerifyVersionInfoA(&info, test->verifymask, mask);
663 ok(test->err ? !ret : ret, "%u: unexpected return value %d.\n", i, ret);
664 if (!ret)
665 ok(GetLastError() == test->err, "%u: unexpected error code %d, expected %d.\n", i, GetLastError(), test->err);
668 /* test handling of version numbers */
669 /* v3.10 is always less than v4.x even
670 * if the minor version is tested */
671 info.dwMajorVersion = 3;
672 info.dwMinorVersion = 10;
673 ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
674 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
675 VER_MAJORVERSION, VER_GREATER_EQUAL));
676 ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
678 info.dwMinorVersion = 0;
679 info.wServicePackMajor = 10;
680 ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
681 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
682 VER_MAJORVERSION, VER_GREATER_EQUAL));
683 ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
685 info.wServicePackMajor = 0;
686 info.wServicePackMinor = 10;
687 ret = VerifyVersionInfoA(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
688 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
689 VER_MAJORVERSION, VER_GREATER_EQUAL));
690 ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
692 /* test bad dwOSVersionInfoSize */
693 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
694 GetVersionExA((OSVERSIONINFOA *)&info);
695 info.dwOSVersionInfoSize = 0;
696 ret = VerifyVersionInfoA(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
697 VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
698 ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
701 static void test_GetSystemFirmwareTable(void)
703 static const ULONG min_sfti_len = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
704 ULONG expected_len;
705 UINT len;
706 SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti;
707 UCHAR *smbios_table;
709 if (!pGetSystemFirmwareTable)
711 win_skip("GetSystemFirmwareTable not available\n");
712 return;
715 sfti = HeapAlloc(GetProcessHeap(), 0, min_sfti_len);
716 ok(!!sfti, "Failed to allocate memory\n");
717 sfti->ProviderSignature = RSMB;
718 sfti->Action = SystemFirmwareTable_Get;
719 sfti->TableID = 0;
720 pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, min_sfti_len, &expected_len);
721 if (expected_len == 0) /* xp, 2003 */
723 win_skip("SystemFirmwareTableInformation is not available\n");
724 HeapFree(GetProcessHeap(), 0, sfti);
725 return;
727 sfti = HeapReAlloc(GetProcessHeap(), 0, sfti, expected_len);
728 ok(!!sfti, "Failed to allocate memory\n");
729 pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, expected_len, &expected_len);
731 expected_len -= min_sfti_len;
732 len = pGetSystemFirmwareTable(RSMB, 0, NULL, 0);
733 ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
735 smbios_table = HeapAlloc(GetProcessHeap(), 0, expected_len);
736 len = pGetSystemFirmwareTable(RSMB, 0, smbios_table, expected_len);
737 ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
738 ok(len == 0 || !memcmp(smbios_table, sfti->TableBuffer, 6),
739 "Expected prologue %02x %02x %02x %02x %02x %02x, got %02x %02x %02x %02x %02x %02x\n",
740 sfti->TableBuffer[0], sfti->TableBuffer[1], sfti->TableBuffer[2],
741 sfti->TableBuffer[3], sfti->TableBuffer[4], sfti->TableBuffer[5],
742 smbios_table[0], smbios_table[1], smbios_table[2],
743 smbios_table[3], smbios_table[4], smbios_table[5]);
745 HeapFree(GetProcessHeap(), 0, sfti);
746 HeapFree(GetProcessHeap(), 0, smbios_table);
749 START_TEST(version)
751 init_function_pointers();
753 test_GetProductInfo();
754 test_GetVersionEx();
755 test_VerifyVersionInfo();
756 test_GetSystemFirmwareTable();