[PATCH 2/3] kernel32/tests: Add tests for GetProductInfo
Detlef Riekenberg
wine.dev at web.de
Sat May 26 18:55:47 CDT 2012
--
By by ... Detlef
---
dlls/kernel32/tests/version.c | 98 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 92 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/tests/version.c b/dlls/kernel32/tests/version.c
index 9f9b72e..9bc7d89 100644
--- a/dlls/kernel32/tests/version.c
+++ b/dlls/kernel32/tests/version.c
@@ -18,31 +18,116 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+/* Needed for PRODUCT_* defines and GetProductInfo() */
+#define _WIN32_WINNT 0x0600
+
#include <assert.h>
#include "wine/test.h"
#include "winbase.h"
+static BOOL (WINAPI * pGetProductInfo)(DWORD, DWORD, DWORD, DWORD, DWORD *);
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);
+ p##func = (void *)GetProcAddress(hKernel32, #func);
static void init_function_pointers(void)
{
HMODULE hKernel32;
- pVerifyVersionInfoA = NULL;
- pVerSetConditionMask = NULL;
-
hKernel32 = GetModuleHandleA("kernel32.dll");
- assert(hKernel32);
+
+ KERNEL32_GET_PROC(GetProductInfo);
KERNEL32_GET_PROC(VerifyVersionInfoA);
KERNEL32_GET_PROC(VerSetConditionMask);
}
+#define PRODUCT2NAME(x) case x:\
+ return #x;
+
+static const char * product_to_name(DWORD product)
+{
+ switch (product)
+ {
+ PRODUCT2NAME(PRODUCT_PROFESSIONAL)
+ PRODUCT2NAME(PRODUCT_STANDARD_SERVER)
+ PRODUCT2NAME(PRODUCT_BUSINESS)
+ PRODUCT2NAME(PRODUCT_ULTIMATE)
+ PRODUCT2NAME(PRODUCT_ULTIMATE_N)
+ PRODUCT2NAME(PRODUCT_HOME_PREMIUM)
+ }
+ return "";
+}
+#undef PRODUCT2NAME
+
+static void test_GetProductInfo(void)
+{
+ OSVERSIONINFOEXA os;
+ DWORD product;
+ DWORD res;
+ DWORD table[] = {9,9,9,0,
+ 7,0,0,0,
+ 6,2,0,0,
+ 6,1,2,0,
+ 6,1,1,0,
+ 6,1,0,0,
+ 6,0,3,0,
+ 6,0,2,0,
+ 6,0,1,0,
+ 6,0,0,0,
+ 5,3,0,0,
+ 5,2,0,0,
+ 5,1,0,0,
+ 5,0,0,0,
+ 0};
+
+ DWORD *entry = table;
+
+ if (!pGetProductInfo)
+ {
+ /* Not present before Vista */
+ win_skip("GetProductInfo() not available\n");
+ return;
+ }
+
+ memset(&os, 0, sizeof(OSVERSIONINFOEXA));
+ os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
+ res = GetVersionExA((OSVERSIONINFOA *)&os);
+ ok(res, "got %d (expected TRUE)\n", res);
+
+ trace("%s %u.%u (SP: %u.%u)\n", os.wProductType == VER_NT_WORKSTATION ? "Workstation" : "Server",
+ os.dwMajorVersion, os.dwMinorVersion, os.wServicePackMajor, os.wServicePackMinor);
+
+ while (*entry)
+ {
+ /* SetLastError() / GetLastError(): value is untouched */
+ product = 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ res = pGetProductInfo(entry[0], entry[1], entry[2], entry[3], &product);
+ trace("%d.%d / %d.%d: got %d and 0x%x %s\n",
+ entry[0], entry[1], entry[2], entry[3], res, product, product_to_name(product));
+
+ if (entry[0] >= 6)
+ ok(res && (product > PRODUCT_UNDEFINED) && (product <= PRODUCT_EMBEDDED) && (GetLastError() == 0xdeadbeef),
+ "got %d and 0x%x with 0x%x (expected TRUE and a valid PRODUCT_* value with LastError untouched)\n",
+ res, product, GetLastError());
+ else
+ ok(!res && !product && (GetLastError() == 0xdeadbeef),
+ "got %d and 0x%x with 0x%x (expected FALSE and PRODUCT_UNDEFINED with LastError untouched)\n",
+ res, product, GetLastError());
+
+ entry+= 4;
+ }
+
+ /* NULL pointer is not a problem */
+ SetLastError(0xdeadbeef);
+ res = pGetProductInfo(6, 1, 0, 0, NULL);
+ ok( (!res) && (GetLastError() == 0xdeadbeef),
+ "got %d with 0x%x (expected FALSE with LastError untouched\n", res, GetLastError());
+}
+
static void test_GetVersionEx(void)
{
OSVERSIONINFOA infoA;
@@ -292,6 +377,7 @@ START_TEST(version)
{
init_function_pointers();
+ test_GetProductInfo();
test_GetVersionEx();
test_VerifyVersionInfo();
}
--
1.7.5.4
More information about the wine-patches
mailing list