diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-02-07 18:21:01 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-02-07 18:21:01 +0100 |
commit | 5b6ae9c5427b32f5bacba592fc08e1f70009aee4 (patch) | |
tree | 67e49b1802bcb8c2b9c7de9b2cd5c165f846c5fc /src | |
parent | 4ed0292914ca78aa419aab3add5b113c26b81a12 (diff) |
Only compile the testsuite if INSPIRCD_ENABLE_TESTSUITE is defined
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 23 | ||||
-rw-r--r-- | src/modules.cpp | 5 | ||||
-rw-r--r-- | src/testsuite.cpp | 9 |
3 files changed, 30 insertions, 7 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 12962d92d..7cc66cd5f 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -89,6 +89,13 @@ const char* ExitCodes[] = "Received SIGTERM" // 10 }; +#ifdef INSPIRCD_ENABLE_TESTSUITE +/** True if we have been told to run the testsuite from the commandline, + * rather than entering the mainloop. + */ +static int do_testsuite = 0; +#endif + template<typename T> static void DeleteZero(T*&n) { T* t = n; @@ -250,8 +257,9 @@ InspIRCd::InspIRCd(int argc, char** argv) : Extensions.Register(&OperQuit); FailedPortList pl; + // Flag variables passed to getopt_long() later int do_version = 0, do_nofork = 0, do_debug = 0, - do_nolog = 0, do_root = 0, do_testsuite = 0; /* flag variables */ + do_nolog = 0, do_root = 0; // Initialize so that if we exit before proper initialization they're not deleted this->Logs = 0; @@ -330,7 +338,9 @@ InspIRCd::InspIRCd(int argc, char** argv) : { "nolog", no_argument, &do_nolog, 1 }, { "runasroot", no_argument, &do_root, 1 }, { "version", no_argument, &do_version, 1 }, +#ifdef INSPIRCD_ENABLE_TESTSUITE { "testsuite", no_argument, &do_testsuite, 1 }, +#endif { 0, 0, 0, 0 } }; @@ -353,14 +363,16 @@ InspIRCd::InspIRCd(int argc, char** argv) : /* Fall through to handle other weird values too */ std::cout << "Unknown parameter '" << argv[optind-1] << "'" << std::endl; std::cout << "Usage: " << argv[0] << " [--nofork] [--nolog] [--debug] [--config <config>]" << std::endl << - std::string(static_cast<int>(8+strlen(argv[0])), ' ') << "[--runasroot] [--version] [--testsuite]" << std::endl; + std::string(static_cast<int>(8+strlen(argv[0])), ' ') << "[--runasroot] [--version]" << std::endl; Exit(EXIT_STATUS_ARGV); break; } } +#ifdef INSPIRCD_ENABLE_TESTSUITE if (do_testsuite) do_nofork = do_debug = true; +#endif if (do_version) { @@ -378,7 +390,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : Config->cmdline.nofork = (do_nofork != 0); Config->cmdline.forcedebug = (do_debug != 0); Config->cmdline.writelog = (!do_nolog != 0); - Config->cmdline.TestSuite = (do_testsuite != 0); if (do_debug) { @@ -515,7 +526,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : * * -- nenolod */ - if ((!do_nofork) && (!do_testsuite) && (!Config->cmdline.forcedebug)) + if ((!do_nofork) && (!Config->cmdline.forcedebug)) { int fd = open("/dev/null", O_RDWR); @@ -636,13 +647,15 @@ void InspIRCd::UpdateTime() void InspIRCd::Run() { +#ifdef INSPIRCD_ENABLE_TESTSUITE /* See if we're supposed to be running the test suite rather than entering the mainloop */ - if (Config->cmdline.TestSuite) + if (do_testsuite) { TestSuite* ts = new TestSuite; delete ts; return; } +#endif UpdateTime(); time_t OLDTIME = TIME.tv_sec; diff --git a/src/modules.cpp b/src/modules.cpp index 245ad5345..2eefc957e 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -151,13 +151,16 @@ void Module::OnBuildNeighborList(User*, IncludeChanList&, std::map<User*,bool>& void Module::OnGarbageCollect() { DetachEvent(I_OnGarbageCollect); } ModResult Module::OnSetConnectClass(LocalUser* user, ConnectClass* myclass) { DetachEvent(I_OnSetConnectClass); return MOD_RES_PASSTHRU; } void Module::OnText(User*, void*, int, const std::string&, char, CUList&) { DetachEvent(I_OnText); } -void Module::OnRunTestSuite() { DetachEvent(I_OnRunTestSuite); } void Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { DetachEvent(I_OnNamesListItem); } ModResult Module::OnNumeric(User*, unsigned int, const std::string&) { DetachEvent(I_OnNumeric); return MOD_RES_PASSTHRU; } ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { DetachEvent(I_OnAcceptConnection); return MOD_RES_PASSTHRU; } void Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, Channel*, std::string&) { DetachEvent(I_OnSendWhoLine); } void Module::OnSetUserIP(LocalUser*) { DetachEvent(I_OnSetUserIP); } +#ifdef INSPIRCD_ENABLE_TESTSUITE +void Module::OnRunTestSuite() { } +#endif + ServiceProvider::ServiceProvider(Module* Creator, const std::string& Name, ServiceType Type) : creator(Creator), name(Name), service(Type) { diff --git a/src/testsuite.cpp b/src/testsuite.cpp index b27f6e18c..b57a21ab8 100644 --- a/src/testsuite.cpp +++ b/src/testsuite.cpp @@ -19,6 +19,8 @@ */ +#ifdef INSPIRCD_ENABLE_TESTSUITE + #include "inspircd.h" #include "testsuite.h" #include "threadengine.h" @@ -74,8 +76,12 @@ TestSuite::TestSuite() switch (choice) { case '1': - FOREACH_MOD(OnRunTestSuite, ()); + { + const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules(); + for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i) + i->second->OnRunTestSuite(); break; + } case '2': std::cout << "Enter module filename to load: "; std::cin >> modname; @@ -394,3 +400,4 @@ TestSuite::~TestSuite() std::cout << "\n\n*** END OF TEST SUITE ***\n"; } +#endif |