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
23 #include "wine/test.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)
37 pVerifyVersionInfoA
= NULL
;
38 pVerSetConditionMask
= NULL
;
40 hKernel32
= GetModuleHandleA("kernel32.dll");
42 KERNEL32_GET_PROC(VerifyVersionInfoA
);
43 KERNEL32_GET_PROC(VerSetConditionMask
);
48 OSVERSIONINFOEX info
= { sizeof(info
) };
51 init_function_pointers();
52 if(!pVerifyVersionInfoA
|| !pVerSetConditionMask
)
54 skip("Needed functions not available\n");
58 ret
= pVerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
,
59 pVerSetConditionMask(0, VER_MAJORVERSION
, VER_GREATER_EQUAL
));
60 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
62 ret
= pVerifyVersionInfoA(&info
, VER_BUILDNUMBER
| VER_MAJORVERSION
|
63 VER_MINORVERSION
/* | VER_PLATFORMID | VER_SERVICEPACKMAJOR |
64 VER_SERVICEPACKMINOR | VER_SUITENAME | VER_PRODUCT_TYPE */,
65 pVerSetConditionMask(0, VER_MAJORVERSION
, VER_GREATER_EQUAL
));
66 ok(!ret
&& (GetLastError() == ERROR_OLD_WIN_VERSION
),
67 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
69 /* tests special handling of VER_SUITENAME */
71 ret
= pVerifyVersionInfoA(&info
, VER_SUITENAME
,
72 pVerSetConditionMask(0, VER_SUITENAME
, VER_AND
));
73 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
75 ret
= pVerifyVersionInfoA(&info
, VER_SUITENAME
,
76 pVerSetConditionMask(0, VER_SUITENAME
, VER_OR
));
77 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
79 /* test handling of version numbers */
81 /* v3.10 is always less than v4.x even
82 * if the minor version is tested */
83 info
.dwMajorVersion
= 3;
84 info
.dwMinorVersion
= 10;
85 ret
= pVerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
86 pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
),
87 VER_MAJORVERSION
, VER_GREATER_EQUAL
));
88 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
90 info
.dwMinorVersion
= 0;
91 info
.wServicePackMajor
= 10;
92 ret
= pVerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
93 pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
),
94 VER_MAJORVERSION
, VER_GREATER_EQUAL
));
95 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
97 info
.wServicePackMajor
= 0;
98 info
.wServicePackMinor
= 10;
99 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
100 pVerSetConditionMask(pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
),
101 VER_MAJORVERSION
, VER_GREATER_EQUAL
));
102 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
104 GetVersionEx((OSVERSIONINFO
*)&info
);
105 info
.wServicePackMinor
++;
106 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
107 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
));
108 ok(!ret
&& (GetLastError() == ERROR_OLD_WIN_VERSION
),
109 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
111 GetVersionEx((OSVERSIONINFO
*)&info
);
112 info
.wServicePackMajor
--;
113 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
114 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER
));
115 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
117 GetVersionEx((OSVERSIONINFO
*)&info
);
118 info
.wServicePackMajor
--;
119 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
120 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
));
121 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
123 GetVersionEx((OSVERSIONINFO
*)&info
);
124 info
.wServicePackMajor
++;
125 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
126 pVerSetConditionMask(0, VER_MINORVERSION
, VER_LESS
));
127 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
129 GetVersionEx((OSVERSIONINFO
*)&info
);
130 info
.wServicePackMajor
++;
131 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
132 pVerSetConditionMask(0, VER_MINORVERSION
, VER_LESS_EQUAL
));
133 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
135 GetVersionEx((OSVERSIONINFO
*)&info
);
136 info
.wServicePackMajor
--;
137 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
138 pVerSetConditionMask(0, VER_MINORVERSION
, VER_EQUAL
));
139 ok(!ret
&& (GetLastError() == ERROR_OLD_WIN_VERSION
),
140 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
142 /* test the failure hierarchy for the four version fields */
144 GetVersionEx((OSVERSIONINFO
*)&info
);
145 info
.wServicePackMajor
++;
146 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
147 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
));
148 ok(!ret
&& (GetLastError() == ERROR_OLD_WIN_VERSION
),
149 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
151 GetVersionEx((OSVERSIONINFO
*)&info
);
152 info
.dwMinorVersion
++;
153 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
154 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
));
155 ok(!ret
&& (GetLastError() == ERROR_OLD_WIN_VERSION
),
156 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
158 GetVersionEx((OSVERSIONINFO
*)&info
);
159 info
.dwMajorVersion
++;
160 ret
= pVerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
161 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
));
162 ok(!ret
&& (GetLastError() == ERROR_OLD_WIN_VERSION
),
163 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
165 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
166 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
));
167 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
170 GetVersionEx((OSVERSIONINFO
*)&info
);
171 info
.dwBuildNumber
++;
172 ret
= pVerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
173 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
));
174 ok(!ret
&& (GetLastError() == ERROR_OLD_WIN_VERSION
),
175 "VerifyVersionInfoA should have failed with ERROR_OLD_WIN_VERSION instead of %d\n", GetLastError());
177 ret
= pVerifyVersionInfoA(&info
, VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
178 pVerSetConditionMask(0, VER_MINORVERSION
, VER_GREATER_EQUAL
));
179 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());
181 /* test bad dwOSVersionInfoSize */
182 GetVersionEx((OSVERSIONINFO
*)&info
);
183 info
.dwOSVersionInfoSize
= 0;
184 ret
= pVerifyVersionInfoA(&info
, VER_MAJORVERSION
| VER_MINORVERSION
| VER_SERVICEPACKMAJOR
| VER_SERVICEPACKMINOR
,
185 pVerSetConditionMask(0, VER_MAJORVERSION
, VER_GREATER_EQUAL
));
186 ok(ret
, "VerifyVersionInfoA failed with error %d\n", GetLastError());