summaryrefslogtreecommitdiff
path: root/src/msvc6/testrunner/ActiveTest.cpp
blob: aac40150e5b0132de719a5b01e5d87e41671309e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45


#include "stdafx.h"
#include "ActiveTest.h"


// Spawn a thread to a test
void ActiveTest::run (CppUnit::TestResult *result)
{
    CWinThread *thread;
    
    setTestResult (result);
    m_runCompleted.ResetEvent ();

    thread = AfxBeginThread (threadFunction, 
        this, 
        THREAD_PRIORITY_NORMAL, 
        0, 
        CREATE_SUSPENDED);
    
    DuplicateHandle (GetCurrentProcess (), 
        thread->m_hThread,
        GetCurrentProcess (), 
        &m_threadHandle, 
        0, 
        FALSE, 
        DUPLICATE_SAME_ACCESS);

    thread->ResumeThread ();

}


// Simple execution thread.  Assuming that an ActiveTest instance
// only creates one of these at a time.
UINT ActiveTest::threadFunction (LPVOID thisInstance)
{
    ActiveTest *test = (ActiveTest *)thisInstance;

    test->run ();
    test->m_runCompleted.SetEvent ();

    return 0;
}