Show
Ignore:
Timestamp:
09/25/07 12:18:50 (7 years ago)
Author:
robert
Message:

Added thread unit test to test the create, start and destruction of threads

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgunittests/osgunittests.cpp

    r7300 r7471  
    2424#include <osg/Timer> 
    2525#include <osg/io_utils> 
     26 
     27#include <OpenThreads/Thread> 
    2628 
    2729#include "UnitTestFramework.h" 
     
    382384} 
    383385 
     386class MyThread : public OpenThreads::Thread { 
     387public: 
     388  void run(void) { } 
     389}; 
     390 
     391void testThreadInitAndExit() 
     392{ 
     393    std::cout<<"******   Running thread start and delete test   ****** "<<std::endl; 
     394 
     395    { 
     396        MyThread thread; 
     397        thread.startThread(); 
     398    } 
     399     
     400    // add a sleep to allow the thread start to fall over it its going to. 
     401    OpenThreads::Thread::microSleep(500000); 
     402     
     403    std::cout<<"pass    thread start and delete test"<<std::endl<<std::endl; 
     404} 
     405 
    384406 
    385407int main( int argc, char** argv ) 
     
    415437 
    416438    bool printQuatTest = false;  
    417     while (arguments.read("quat")) printQuatTest = true;  
     439    while (arguments.read("quat")) printQuatTest = true; 
     440     
     441    bool doTestThreadInitAndExit = false; 
     442    while (arguments.read("thread")) doTestThreadInitAndExit = true; 
    418443 
    419444    osg::Vec3d quat_scale(1.0,1.0,1.0);  
     
    502527    } 
    503528 
     529    if (doTestThreadInitAndExit) 
     530    { 
     531        testThreadInitAndExit(); 
     532    } 
     533 
    504534    std::cout<<"******   Running tests   ******"<<std::endl; 
    505535