psapi/tests: Fix the EnumProcessModules() test and provide more diagnostic information if it fails.

Francois Gouget fgouget at free.fr
Fri Aug 26 09:09:03 CDT 2011


On some Windows systems aclayers.dll gets injected into the process and brings in a lot of extra dlls.
---

Specifically this issue does not appear in any of the test.winehq.org 
results but does appear on TestBot's Windows 7 VM (and maybe Vista too). 

Given the variable nature of the upper bound limit, maybe that check 
should be removed entirely. Let me know if that's the preferred 
approach.

In any case the original upper bound check was obviously wrong with the 
sizeof() appearing on both sides of the comparison operator.


 dlls/psapi/tests/psapi_main.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index c4c129b..8a1cfc1 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -107,10 +107,26 @@ static void test_EnumProcessModules(void)
     ret = pEnumProcessModules(hpQV, &hMod, sizeof(HMODULE), &cbNeeded);
     if(ret != 1)
         return;
-    ok(cbNeeded / sizeof(HMODULE) >= 3 && cbNeeded / sizeof(HMODULE) <= 5 * sizeof(HMODULE),
-       "cbNeeded=%d\n", cbNeeded);
     ok(hMod == GetModuleHandle(NULL),
        "hMod=%p GetModuleHandle(NULL)=%p\n", hMod, GetModuleHandle(NULL));
+    ok(cbNeeded % sizeof(hMod) == 0, "not a multiple of sizeof(HMODULE) cbNeeded=%d\n", cbNeeded);
+    /* Windows sometimes has a bunch of extra dlls, presumably brought in by
+     * aclayers.dll.
+     */
+    if (cbNeeded < 4 * sizeof(HMODULE) || cbNeeded > 30 * sizeof(HMODULE))
+    {
+        HMODULE hmods[100];
+        int i;
+        ok(0, "cbNeeded=%d\n", cbNeeded);
+
+        pEnumProcessModules(hpQV, hmods, sizeof(hmods), &cbNeeded);
+        for (i = 0 ; i < cbNeeded/sizeof(*hmods); i++)
+        {
+            char path[1024];
+            GetModuleFileNameA(hmods[i], path, sizeof(path));
+            trace("i=%d hmod=%p path=[%s]\n", i, hmods[i], path);
+        }
+    }
 }
 
 static void test_GetModuleInformation(void)
-- 
1.7.5.4



More information about the wine-patches mailing list