[PATCH] ole32/tests: Fix flaky test in cowait_unmarshal_thread.

Kevin Puetz PuetzKevinA at JohnDeere.com
Thu Nov 5 17:09:11 CST 2020


When run with runtest -q (WINETEST_DEBUG=0) it passed within the
first 50ms, but with any verbose logging it sometimes failed.

Use CoWaitForMultipleHandles (which keeps pumping the STA) since
cowait_unmarshal_thread only releases its marshaled unk at the end,
so it needs to be able to call back in order to exit cleanly.

Signed-off-by: Kevin Puetz <PuetzKevinA at JohnDeere.com>
--

It's a bit weird how this was split into 50ms with message pumping
(that will always time out), and then <=200ms more to actually exit.
With the latter being WaitForSingleObject, if it didn't complete
in that first 50ms, the call to Release will just hang anyway after
test_CoWaitForMultipleHandles_thread quits pumping.

We could also just combine these and give CoWaitForMultipleHandles
the full 50+200ms timeout period in one call, exiting early when done,
but then the RPC_S_CALLPENDING path would not be excercised.
This case seems to about CoRegisterMessageFilter, so that might be OK;
there are many others which would still test timeouts.

But keeping the shape unchanged seems like a more conservative fix,
in case there was a reason jacek wanted to test timeouts here when he
added these cases in de90cca586b6a04340907ebefd31ede38f6894fa.
---
 dlls/ole32/tests/compobj.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index 5ed3f9638b1..0d7f3d8adee 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -2772,8 +2772,9 @@ static DWORD CALLBACK test_CoWaitForMultipleHandles_thread(LPVOID arg)
     ok(thread != NULL, "CreateThread failed, error %u\n", GetLastError());
     hr = CoWaitForMultipleHandles(0, 50, 1, &event, &index);
     ok(hr == RPC_S_CALLPENDING, "expected RPC_S_CALLPENDING, got 0x%08x\n", hr);
-    index = WaitForSingleObject(thread, 200);
-    ok(index == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
+    hr = CoWaitForMultipleHandles(0, 200, 1, &thread, &index);
+    ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
+    ok(index == WAIT_OBJECT_0, "cowait_unmarshal_thread didn't finish");
     CloseHandle(thread);
 
     hr = CoRegisterMessageFilter(NULL, NULL);



More information about the wine-devel mailing list