From b77840d3a22f370fce5f9b77c6af42f91ff65235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 17 Feb 2018 16:02:22 +0100 Subject: [PATCH] [SHELL32_APITEST] Run the CUserNotification worker test function in a thread to copy with possible test timeouts. CORE-13177 --- .../apitests/shell32/CUserNotification.cpp | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/modules/rostests/apitests/shell32/CUserNotification.cpp b/modules/rostests/apitests/shell32/CUserNotification.cpp index b10185cee99..acfd6023a83 100644 --- a/modules/rostests/apitests/shell32/CUserNotification.cpp +++ b/modules/rostests/apitests/shell32/CUserNotification.cpp @@ -171,9 +171,39 @@ TestNotification(void) ok_hr(hr, S_FALSE); } +DWORD +CALLBACK +TestThread(LPVOID lpParam) +{ + /* Initialize COM */ + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + + /* Start the test */ + TestNotification(); + + /* Cleanup and return */ + CoUninitialize(); + return 0; +} + START_TEST(CUserNotification) { - CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - TestNotification(); - CoUninitialize(); + HANDLE hThread; + DWORD dwWait; + + /* We create a test thread, because the notification tests can hang */ + hThread = CreateThread(NULL, 0, TestThread, NULL, 0, NULL); + ok(hThread != NULL, "CreateThread failed with error 0x%lu\n", GetLastError()); + if (!hThread) + { + skip("Could not create the CUserNotification test thread!"); + return; + } + + /* Wait a maximum of 1:30 for the thread to finish (the timeout tests take some time) */ + dwWait = WaitForSingleObject(hThread, 90 * 1000); + ok(dwWait == WAIT_OBJECT_0, "WaitForSingleObject returned %lu, expected WAIT_OBJECT_0\n", dwWait); + + /* Cleanup and return */ + CloseHandle(hThread); }