[PATCH 2/2] kernel32: test GetLogicalProcessorInformation only where available

Claudio Fontana claudio.fontana at gmail.com
Thu Nov 24 13:34:30 CST 2011


glpi is only available on WINXP / SP3 and newer.
Skip the glpi test on systems that do not export this API in kernel32.dll.
---
 dlls/kernel32/tests/glpi.c |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/dlls/kernel32/tests/glpi.c b/dlls/kernel32/tests/glpi.c
index a81d1d5..4e480ad 100644
--- a/dlls/kernel32/tests/glpi.c
+++ b/dlls/kernel32/tests/glpi.c
@@ -8,30 +8,39 @@
 #include "winbase.h"
 #include "winerror.h"
 
+static BOOL (WINAPI *pGetLogicalProcessorInformation)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION b, PDWORD plen);
+
 static void test_glpi(void)
 {
     SYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer[200];
     DWORD buflen = sizeof(buffer);
     BOOL ret; int i, n;
 
-    ret = GetLogicalProcessorInformation(NULL, &buflen);
+    if (pGetLogicalProcessorInformation == NULL)
+    {
+	/* only exists on XP and later */
+	win_skip("GetLogicalProcessorInformation not found.\n");
+	return;
+    }
+
+    ret = pGetLogicalProcessorInformation(NULL, &buflen);
     ok(!ret, "Passing NULL as buffer should not be ok.\n");
 
-    ret = GetLogicalProcessorInformation(buffer, NULL);
+    ret = pGetLogicalProcessorInformation(buffer, NULL);
     ok(!ret, "Passing NULL as pbuflen should not be ok.\n");
 
-    ret = GetLogicalProcessorInformation(buffer, &buflen);
+    ret = pGetLogicalProcessorInformation(buffer, &buflen);
     ok(ret, "Normal glpi call (%d)\n", GetLastError());
 
-    ret = GetLogicalProcessorInformation(buffer, &buflen);
+    ret = pGetLogicalProcessorInformation(buffer, &buflen);
     ok(ret, "glpi call with the resulting buflen (%d)\n", buflen);
 
     buflen--;
 
-    ret = GetLogicalProcessorInformation(buffer, &buflen);
+    ret = pGetLogicalProcessorInformation(buffer, &buflen);
     ok(!ret, "glpi call with insufficient buflen (%d)\n", buflen);
 
-    ret = GetLogicalProcessorInformation(buffer, &buflen);
+    ret = pGetLogicalProcessorInformation(buffer, &buflen);
     ok(ret, "glpi call with resulting buflen (%d)\n", buflen);
 
     n = buflen / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
@@ -77,6 +86,10 @@ static void test_glpi(void)
 
 START_TEST(glpi)
 {
+    HINSTANCE hdll;
+    hdll = GetModuleHandleA("kernel32.dll");
+
+    pGetLogicalProcessorInformation = (void *)GetProcAddress(hdll, "GetLogicalProcessorInformation");
+
     test_glpi();
 }
-
-- 
1.6.4




More information about the wine-patches mailing list