1 // Copyright © 2015 Hewlett-Packard Development Company, L.P.
3 #include <winpr/file.h>
4 #include <winpr/synch.h>
5 #include <winpr/thread.h>
7 static void* thread_func(void* arg)
9 /* exists of the thread the quickest as possible */
14 int TestThreadExitThread(int argc, char* argv[])
20 /* FIXME: create some noise to better guaranty the test validity and
21 * decrease the number of loops */
22 for (i=0; i<50000; i++)
24 thread = CreateThread(NULL,
26 (LPTHREAD_START_ROUTINE)thread_func,
31 if (thread == INVALID_HANDLE_VALUE)
33 fprintf(stderr, "Got an invalid thread!\n");
37 waitResult = WaitForSingleObject(thread, 1000);
38 if (waitResult != WAIT_OBJECT_0)
40 /* When the thread exits before the internal thread_list
41 * was updated, ExitThread() is not able to retrieve the
42 * related WINPR_THREAD object and is not able to signal
43 * the end of the thread. Therefore WaitForSingleObject
44 * never get the signal.
46 fprintf(stderr, "1 second should have been enough for the thread to be in a signaled state\n");