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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
/*
* Copyright (c) 2004 by FORCE Computers.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
* file and program are licensed under a BSD style license. See
* the Copying file included with the OpenHPI distribution for
* full licensing terms.
*
* Authors:
* Thomas Kanngieser <thomas.kanngieser@fci.com>
*/
#include "thread.h"
#include "test.h"
#include "ipmi_utils.h"
#define dMagic 0x47130815
class cThreadTest : public cThread, public cThreadLock, public cThreadLockRw
{
public:
cThreadTest()
: m_magic( dMagic ) {}
unsigned int m_magic;
protected:
virtual void *Run();
};
void *
cThreadTest::Run()
{
cTime tn = cTime::Now();
tn += 1000;
cThreadTest *thread = (cThreadTest *)cThread::GetThread();
Test( thread == this );
Test( thread->m_magic == dMagic );
while( tn > cTime::Now() )
usleep( 100000 );
return 0;
}
int
main()
{
cThread *mt = cThread::GetThread();
Test( mt );
Test( mt->IsRunning() );
Test( mt->IsMain() );
cThreadTest thread;
Test( thread.Start() );
Test( thread.IsRunning() );
while( thread.IsRunning() )
usleep( 100000 );
return TestResult();
}
|