diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-02-21 17:06:20 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-02-21 17:06:20 +0000 |
commit | 21193e2e625859978e98b278beda00181fcd317c (patch) | |
tree | 6d1ee4085e38ceb52c02edef9de730a5dc30cfd8 /src/testsuite.cpp | |
parent | 14b1960421814bcc6e5a744dad3d0b6d81a2771c (diff) |
Threadengine stuff
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8980 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/testsuite.cpp')
-rw-r--r-- | src/testsuite.cpp | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/src/testsuite.cpp b/src/testsuite.cpp index f02b3aed3..a129ecc72 100644 --- a/src/testsuite.cpp +++ b/src/testsuite.cpp @@ -15,15 +15,39 @@ #include "inspircd.h" #include "testsuite.h" +#include "threadengine.h" #include <iostream> using namespace std; +class TestSuiteThread : public Thread +{ + TestSuiteThread() : Thread() + { + } + + virtual ~TestSuiteThread() + { + } + + virtual void Run() + { + while (1) + { + cout << "Test suite thread run...\n"; + sleep(10); + } + } +}; + TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance) { cout << "\n\n*** STARTING TESTSUITE ***\n"; std::string modname; + std::string choice; + + ServerInstance->SE->Blocking(fileno(stdin)); while (1) { @@ -31,8 +55,13 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance) cout << "(2) Load a module\n"; cout << "(3) Unload a module\n"; cout << "(4) Threading tests\n"; - - switch (fgetc(stdin)) + + cout << endl << "(X) Exit test suite\n"; + + cout << "\nChoice: "; + cin >> choice; + + switch (*choice.begin()) { case '1': FOREACH_MOD(I_OnRunTestSuite, OnRunTestSuite()); @@ -50,6 +79,12 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance) case '4': cout << (DoThreadTests() ? "\nSUCCESS!\n" : "\nFAILURE\n"); break; + case 'X': + return; + break; + default: + cout << "Invalid option\n"; + break; } cout << endl; } @@ -57,6 +92,35 @@ TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance) bool TestSuite::DoThreadTests() { + std::string anything; + cout << "Creating new ThreadEngine class...\n"; + try + { + ThreadEngineFactory* tef = new ThreadEngineFactory(); + ThreadEngine* te = tef->Create(ServerInstance); + delete tef; + } + catch (...) + { + cout << "Creation failed, test failure.\n"; + return false; + } + cout << "Creation success!\n"; + + cout << "Creating new thread of type TestSuiteThread\n"; + + TestSuiteThread* tst = new TestSuiteThread(); + + te->Create(tst); + + cout >> "Press enter to end test."; + cin >> anything; + + /* Auto frees thread */ + delete tst; + + delete te; + return true; } |