The patchwatcher robot is offline today while I
move it to a faster computer and add a timeout
to individual tests (since one hangs reliably on
the new computer). Here's the timeout patch,
if anyone's interested in doing a little prereview.
I finally realized the most windows-y way of
doing a timeout was to run the test in its own
thread.
include/wine/test.h | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/include/wine/test.h b/include/wine/test.h
index 62d8c3a..a18a7b3 100644
--- a/include/wine/test.h
+++ b/include/wine/test.h
@@ -163,6 +163,13 @@ struct test
void (*func)(void);
};
+static DWORD WINAPI func_thread_wrapper(void *param)
+{
+ void (*func)(void) = param;
+ func();
+ return 0;
+}
+
extern const struct test winetest_testlist[];
/* debug level */
@@ -434,12 +441,13 @@ static void list_tests(void)
for (test = winetest_testlist; test->name; test++) fprintf( stdout, " %s\n", test->name );
}
-
/* Run a named test, and return exit status */
static int run_test( const char *name )
{
const struct test *test;
int status;
+ HANDLE hThread_test;
+ DWORD wait_result;
if (!(test = find_test( name )))
{
@@ -449,9 +457,21 @@ static int run_test( const char *name )
successes = failures = todo_successes = todo_failures = 0;
tls_index=TlsAlloc();
current_test = test;
- test->func();
- if (winetest_debug)
+ /* Run the test in its own thread */
+ hThread_test = CreateThread(NULL, 0, func_thread_wrapper, test->func, 0, NULL);
+ /* Wait 150 seconds for the test to finish
+ * Wintest waits 120 seconds, so for now, this won't fire under wintest
+ */
+ wait_result = WaitForSingleObject(hThread_test, 150000);
+ if (wait_result == WAIT_TIMEOUT) {
+ /* terminate it. Do we need to do this? Is it safe? */
+ TerminateThread(hThread_test, 1);
+ InterlockedIncrement(&failures);
+ if (winetest_debug)
+ fprintf( stdout, "%s.c: Test failed; timed out!\n", test->name);
+ }
+ else if (winetest_debug)
{
fprintf( stdout, "%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
test->name, successes + failures + todo_successes + todo_failures,