[PATCH 3/3] ntdll/tests: Add tests for RtlGetProductInfo

Detlef Riekenberg wine.dev at web.de
Sat May 26 18:55:48 CDT 2012


--
By by ... Detlef
---
 dlls/ntdll/tests/rtl.c |   76 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 5ba577d..2074c55 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -21,6 +21,9 @@
  * windows.
  */
 
+/* Needed for PRODUCT_* defines and RtlGetProductInfo() */
+#define _WIN32_WINNT 0x0600
+
 #include <stdlib.h>
 
 #include "ntdll_test.h"
@@ -88,6 +91,7 @@ static NTSTATUS  (WINAPI *pRtlSetThreadErrorMode)(DWORD, LPDWORD);
 static IMAGE_BASE_RELOCATION *(WINAPI *pLdrProcessRelocationBlock)(void*,UINT,USHORT*,INT_PTR);
 static CHAR *    (WINAPI *pRtlIpv4AddressToStringA)(const IN_ADDR *, LPSTR);
 static NTSTATUS  (WINAPI *pRtlIpv4AddressToStringExA)(const IN_ADDR *, USHORT, LPSTR, PULONG);
+static BOOLEAN   (WINAPI *pRtlGetProductInfo)(DWORD, DWORD, DWORD, DWORD, DWORD *);
 
 static HMODULE hkernel32 = 0;
 static BOOL      (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
@@ -131,6 +135,7 @@ static void InitFunctionPtrs(void)
         pLdrProcessRelocationBlock  = (void *)GetProcAddress(hntdll, "LdrProcessRelocationBlock");
         pRtlIpv4AddressToStringA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringA");
         pRtlIpv4AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringExA");
+        pRtlGetProductInfo = (void *)GetProcAddress(hntdll, "RtlGetProductInfo");
     }
     hkernel32 = LoadLibraryA("kernel32.dll");
     ok(hkernel32 != 0, "LoadLibrary failed\n");
@@ -1313,6 +1318,76 @@ static void test_RtlIpv4AddressToStringEx(void)
 }
 
 
+#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_RtlGetProductInfo(void)
+{
+    BOOLEAN res;
+    DWORD product;
+    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 (!pRtlGetProductInfo)
+    {
+        /* Not present before Vista */
+        win_skip("RtlGetProductInfo not available\n");
+        return;
+    }
+
+    while (*entry)
+    {
+        product = 0xdeadbeef;
+        res = pRtlGetProductInfo(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),
+                "got %d and 0x%x (expected TRUE and a valid PRODUCT_* value)\n", res, product);
+        else
+            ok(!res && !product, "got %d and 0x%x (expected FALSE and PRODUCT_UNDEFINED)\n", res, product);
+
+        entry+= 4;
+    }
+
+    /* NULL pointer is not a problem */
+    res = pRtlGetProductInfo(6, 1, 0, 0, NULL);
+    ok(!res, "got %d (expected FALSE)\n", res);
+}
+
+
 START_TEST(rtl)
 {
     InitFunctionPtrs();
@@ -1336,4 +1411,5 @@ START_TEST(rtl)
     test_LdrProcessRelocationBlock();
     test_RtlIpv4AddressToString();
     test_RtlIpv4AddressToStringEx();
+    test_RtlGetProductInfo();
 }
-- 
1.7.5.4




More information about the wine-patches mailing list