]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/testsuite.cpp
Resolve collisions once, don't rely on every server being able to fix our collision
[user/henk/code/inspircd.git] / src / testsuite.cpp
index a129ecc728c3f153c73a7630bace673cca2acc2d..02d806480781e99d3e93cac1c8b0926b43ce1d80 100644 (file)
@@ -22,6 +22,7 @@ using namespace std;
 
 class TestSuiteThread : public Thread
 {
+ public:
        TestSuiteThread() : Thread()
        {
        }
@@ -32,10 +33,10 @@ class TestSuiteThread : public Thread
 
        virtual void Run()
        {
-               while (1)
+               while (GetExitFlag() == false)
                {
                        cout << "Test suite thread run...\n";
-                       sleep(10);
+                       sleep(5);
                }
        }
 };
@@ -93,11 +94,13 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance)
 bool TestSuite::DoThreadTests()
 {
        std::string anything;
+       ThreadEngine* te = NULL;
+
        cout << "Creating new ThreadEngine class...\n";
        try
        {
                ThreadEngineFactory* tef = new ThreadEngineFactory();
-               ThreadEngine* te = tef->Create(ServerInstance);
+               te = tef->Create(ServerInstance);
                delete tef;
        }
        catch (...)
@@ -105,21 +108,39 @@ bool TestSuite::DoThreadTests()
                cout << "Creation failed, test failure.\n";
                return false;
        }
-       cout << "Creation success!\n";
-
-       cout << "Creating new thread of type TestSuiteThread\n";
+       cout << "Creation success, type " << te->GetName() << "\n";
 
+       cout << "Allocate: new TestSuiteThread...\n";
        TestSuiteThread* tst = new TestSuiteThread();
 
-       te->Create(tst);
+       cout << "ThreadEngine::Create on TestSuiteThread...\n";
+       try
+       {
+               try
+               {
+                       te->Create(tst);
+               }
+               catch (CoreException &ce)
+               {
+                       cout << "Failure: " << ce.GetReason() << endl;
+               }
+       }
+       catch (...)
+       {
+               cout << "Failure, unhandled exception\n";
+       }
 
-       cout >> "Press enter to end test.";
+       cout << "Type any line and press enter to end test.\n";
        cin >> anything;
 
-       /* Auto frees thread */
+       /* Thread engine auto frees thread on delete */
+       cout << "Waiting for thread to exit... " << flush;
        delete tst;
+       cout << "Done!\n";
 
+       cout << "Delete ThreadEngine... ";
        delete te;
+       cout << "Done!\n";
 
        return true;
 }