1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 /* $Core: libIRCDtestsuite */
17 #include "testsuite.h"
18 #include "threadengine.h"
23 class TestSuiteThread : public Thread
26 TestSuiteThread() : Thread()
30 virtual ~TestSuiteThread()
36 while (GetExitFlag() == false)
38 cout << "Test suite thread run...\n";
44 TestSuite::TestSuite(InspIRCd* Instance) : ServerInstance(Instance)
46 cout << "\n\n*** STARTING TESTSUITE ***\n";
51 ServerInstance->SE->Blocking(fileno(stdin));
55 cout << "(1) Call all module OnRunTestSuite() methods\n";
56 cout << "(2) Load a module\n";
57 cout << "(3) Unload a module\n";
58 cout << "(4) Threading tests\n";
60 cout << endl << "(X) Exit test suite\n";
65 switch (*choice.begin())
68 FOREACH_MOD(I_OnRunTestSuite, OnRunTestSuite());
71 cout << "Enter module filename to load: ";
73 cout << (Instance->Modules->Load(modname.c_str()) ? "\nSUCCESS!\n" : "\nFAILURE\n");
76 cout << "Enter module filename to unload: ";
78 cout << (Instance->Modules->Unload(modname.c_str()) ? "\nSUCCESS!\n" : "\nFAILURE\n");
81 cout << (DoThreadTests() ? "\nSUCCESS!\n" : "\nFAILURE\n");
87 cout << "Invalid option\n";
94 bool TestSuite::DoThreadTests()
97 ThreadEngine* te = NULL;
99 cout << "Creating new ThreadEngine class...\n";
102 ThreadEngineFactory* tef = new ThreadEngineFactory();
103 te = tef->Create(ServerInstance);
108 cout << "Creation failed, test failure.\n";
111 cout << "Creation success, type " << te->GetName() << "\n";
113 cout << "Allocate: new TestSuiteThread...\n";
114 TestSuiteThread* tst = new TestSuiteThread();
116 cout << "ThreadEngine::Create on TestSuiteThread...\n";
123 catch (CoreException &ce)
125 cout << "Failure: " << ce.GetReason() << endl;
130 cout << "Failure, unhandled exception\n";
133 cout << "Type any line and press enter to end test.\n";
136 /* Thread engine auto frees thread on delete */
137 cout << "Waiting for thread to exit... " << flush;
141 cout << "Delete ThreadEngine... ";
148 TestSuite::~TestSuite()
150 cout << "\n\n*** END OF TEST SUITE ***\n";