]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
More test suite stuff
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 21 Feb 2008 15:59:57 +0000 (15:59 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 21 Feb 2008 15:59:57 +0000 (15:59 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8976 e03df62e-2008-0410-955e-edbf42e46eb7

include/configreader.h
include/modules.h
include/testsuite.h
src/inspircd.cpp
src/modules.cpp
src/testsuite.cpp

index e74895e8bd1315d555f68a3e7c2353c373f3e70a..a5ae36c09306a0b6c2bb534bce55d6ff1bcda53a 100644 (file)
@@ -629,6 +629,11 @@ class CoreExport ServerConfig : public Extensible
         */
        char sid[MAXBUF];
 
+       /** True if we have been told to run the testsuite from the commandline,
+        * rather than entering the mainloop.
+        */
+       bool TestSuite;
+
        /** Construct a new ServerConfig
         */
        ServerConfig(InspIRCd* Instance);
index f19df390cc596fed0185aa37ef07c2162ef54479..9498e239e6027f3cd0afb16377138823c4dc3307 100644 (file)
@@ -401,7 +401,7 @@ enum Implementation
        I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister,
        I_OnChannelPreDelete, I_OnChannelDelete, I_OnPostOper, I_OnSyncOtherMetaData, I_OnSetAway, I_OnCancelAway, I_OnUserList,
        I_OnPostCommand, I_OnPostJoin, I_OnWhoisLine, I_OnBuildExemptList, I_OnRawSocketConnect, I_OnGarbageCollect, I_OnBufferFlushed,
-       I_OnText, I_OnReadConfig, I_OnDownloadFile, I_OnPassCompare,
+       I_OnText, I_OnReadConfig, I_OnDownloadFile, I_OnPassCompare, I_OnRunTestSuite,
        I_END
 };
 
@@ -1352,6 +1352,11 @@ class CoreExport Module : public Extensible
         * @param user The user who's buffer is now empty.
         */
        virtual void OnBufferFlushed(User* user);
+
+       /** Add test suite hooks here. These are used for testing functionality of a module
+        * via the --testsuite debugging parameter.
+        */
+       virtual void OnRunTestSuite();
 };
 
 
index 447e2b15e9bfd550a9666f6e4967346e0ef0f7c9..b72e2b3a1449f336cda61830b29bdbf9da726b1c 100644 (file)
 #ifndef __TESTSUITE_H__
 #define __TESTSUITE_H__
 
+class InspIRCd;
+
+class TestSuite : public Extensible
+{
+ public:
+       TestSuite(InspIRCd* ServerInstance);
+       ~TestSuite();
+};
+
 #endif
index 501be39798f66c8fdbfc2cc4a72405e96b26f75a..907a4c14d0680cabfb9c098b3acb7602dd8b4b06 100644 (file)
@@ -289,7 +289,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
 
        int found_ports = 0;
        FailedPortList pl;
-       int do_version = 0, do_nofork = 0, do_debug = 0, do_nolog = 0, do_root = 0;    /* flag variables */
+       int do_version = 0, do_nofork = 0, do_debug = 0,
+           do_nolog = 0, do_root = 0, do_testsuite = 0;    /* flag variables */
        char c = 0;
 
        memset(&server, 0, sizeof(server));
@@ -352,6 +353,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
                { "nolog",      no_argument,            &do_nolog,      1       },
                { "runasroot",  no_argument,            &do_root,       1       },
                { "version",    no_argument,            &do_version,    1       },
+               { "testsuite",  no_argument,            &do_testsuite,  1       },
                { 0, 0, 0, 0 }
        };
 
@@ -372,7 +374,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
                        break;
                        default:
                                /* Unknown parameter! DANGER, INTRUDER.... err.... yeah. */
-                               printf("Usage: %s [--nofork] [--nolog] [--debug] [--logfile <filename>] [--runasroot] [--version] [--config <config>]\n", argv[0]);
+                               printf("Usage: %s [--nofork] [--nolog] [--debug] [--logfile <filename>]\n\
+                                                 [--runasroot] [--version] [--config <config>] [--testsuite]\n", argv[0]);
                                Exit(EXIT_STATUS_ARGV);
                        break;
                }
@@ -404,7 +407,8 @@ InspIRCd::InspIRCd(int argc, char** argv)
        /* Set the finished argument values */
        Config->nofork = do_nofork;
        Config->forcedebug = do_debug;
-       Config->writelog = !do_nolog;   
+       Config->writelog = !do_nolog;
+       Config->TestSuite = do_testsuite;
 
        if (!this->OpenLog(argv, argc))
        {
@@ -602,6 +606,14 @@ void InspIRCd::InitialiseUID()
 
 int InspIRCd::Run()
 {
+       /* See if we're supposed to be running the test suite rather than entering the mainloop */
+       if (Config->TestSuite)
+       {
+               TestSuite* ts = new TestSuite(this);
+               delete ts;
+               Exit(0);
+       }
+
        while (true)
        {
 #ifndef WIN32
index 81be2415441eac9938714f8dd555821cca894efe..ba98ad8651285d47421dd96df36563aaebe2ea0f 100644 (file)
@@ -192,6 +192,7 @@ void                Module::OnBuildExemptList(MessageType, Channel*, User*, char, CUList&, con
 void           Module::OnGarbageCollect() { }
 void           Module::OnBufferFlushed(User*) { }
 void           Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
+void           Module::OnRunTestSuite() { }
 
 
 ModuleManager::ModuleManager(InspIRCd* Ins) : ModCount(0), Instance(Ins)
index a9ae8caba7050e43432589babd22bd9edc848050..80a9a3d38c6b2d2a57c92d6016c543f9a390e40b 100644 (file)
 #include "inspircd.h"
 #include "testsuite.h"
 
+TestSuite::TestSuite(InspIRCd* ServerInstance)
+{
+       FOREACH_MOD(I_OnRunTestSuite, OnRunTestSuite());
+}
+
+TestSuite::~TestSuite()
+{
+}
+
 /* $Core: libIRCDtestsuite */