diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Generating/PieceGenerator.cpp | 1 | ||||
-rw-r--r-- | src/Generating/PrefabPiecePool.cpp | 1 | ||||
-rw-r--r-- | src/OSSupport/NetworkInterfaceEnum.cpp | 1 | ||||
-rw-r--r-- | src/Root.cpp | 6 | ||||
-rw-r--r-- | src/SelfTests.cpp | 71 | ||||
-rw-r--r-- | src/SelfTests.h | 51 |
7 files changed, 0 insertions, 133 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c57be1c9..76a18801d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,7 +63,6 @@ SET (SRCS RCONServer.cpp Root.cpp Scoreboard.cpp - SelfTests.cpp Server.cpp SetChunkData.cpp SpawnPrepare.cpp @@ -140,7 +139,6 @@ SET (HDRS RCONServer.h Root.h Scoreboard.h - SelfTests.h Server.h SetChunkData.h SettingsRepositoryInterface.h diff --git a/src/Generating/PieceGenerator.cpp b/src/Generating/PieceGenerator.cpp index d6204ce85..842ac349b 100644 --- a/src/Generating/PieceGenerator.cpp +++ b/src/Generating/PieceGenerator.cpp @@ -6,7 +6,6 @@ #include "Globals.h" #include "PieceGenerator.h" -#include "../SelfTests.h" #include "VerticalStrategy.h" #include "VerticalLimit.h" diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp index e1bb9f684..417f8ce7e 100644 --- a/src/Generating/PrefabPiecePool.cpp +++ b/src/Generating/PrefabPiecePool.cpp @@ -6,7 +6,6 @@ #include "Globals.h" #include "PrefabPiecePool.h" #include "../Bindings/LuaState.h" -#include "SelfTests.h" #include "WorldStorage/SchematicFileSerializer.h" #include "VerticalStrategy.h" #include "../StringCompression.h" diff --git a/src/OSSupport/NetworkInterfaceEnum.cpp b/src/OSSupport/NetworkInterfaceEnum.cpp index c7339c408..d3a254c23 100644 --- a/src/OSSupport/NetworkInterfaceEnum.cpp +++ b/src/OSSupport/NetworkInterfaceEnum.cpp @@ -6,7 +6,6 @@ #include "Globals.h" #include "Network.h" #include "event2/util.h" -#include "../SelfTests.h" #ifdef _WIN32 #include <IPHlpApi.h> diff --git a/src/Root.cpp b/src/Root.cpp index bd8e026f3..1eca73cb2 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -22,7 +22,6 @@ #include "IniFile.h" #include "SettingsRepositoryInterface.h" #include "OverridesSettingsRepository.h" -#include "SelfTests.h" #include "Logger.h" #include <iostream> @@ -128,11 +127,6 @@ void cRoot::Start(std::unique_ptr<cSettingsRepositoryInterface> a_OverridesRepo) LOG("from commit id: " BUILD_COMMIT_ID " built at: " BUILD_DATETIME); #endif - // Run the self-tests registered previously via cSelfTests::Register(): - #ifdef SELF_TEST - cSelfTests::ExecuteAll(); - #endif - cDeadlockDetect dd; auto BeginTime = std::chrono::steady_clock::now(); diff --git a/src/SelfTests.cpp b/src/SelfTests.cpp deleted file mode 100644 index 7e35e675e..000000000 --- a/src/SelfTests.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// SelfTests.h - -// Implements the cSelfTests class representing the singleton used for registering self-tests -// This class is only declared if SELF_TEST macro is defined. - -#include "Globals.h" -#include "SelfTests.h" - - - - - -#ifdef SELF_TEST - cSelfTests::cSelfTests(void): - m_AllowRegistering(true) - { - } - - - - - - cSelfTests & cSelfTests::Get(void) - { - static cSelfTests singleton; - return singleton; - } - - - - - - void cSelfTests::Register(cSelfTests::SelfTestFunction a_FnToExecute, const AString & a_TestName) - { - ASSERT(Get().m_AllowRegistering); - Get().m_SelfTests.push_back(std::make_pair(a_FnToExecute, a_TestName)); - } - - - - - - void cSelfTests::ExecuteAll(void) - { - Get().m_AllowRegistering = false; - LOG("--- Performing self-tests ---"); - for (auto & test: Get().m_SelfTests) - { - LOG("Performing self-test: %s", test.second.c_str()); - try - { - test.first(); - } - catch (const std::exception & exc) - { - LOGWARNING("Exception in test %s: %s", test.second.c_str(), exc.what()); - } - catch (...) - { - LOGWARNING("Unknown exception in test %s", test.second.c_str()); - } - } // for test - m_SelfTests[] - LOG("--- Self-tests finished ---"); - } - -#endif // SELF_TEST - - - - diff --git a/src/SelfTests.h b/src/SelfTests.h deleted file mode 100644 index 03a3b5faa..000000000 --- a/src/SelfTests.h +++ /dev/null @@ -1,51 +0,0 @@ - -// SelfTests.h - -// Declares the cSelfTests class representing the singleton used for registering self-tests -// This class is only declared if SELF_TEST macro is defined. - - - - - -#pragma once - - - - - -#ifdef SELF_TEST - /** Singleton containing registered self-tests. - Used to schedule self-tests to run after the logging framework is initialized (#2228). */ - class cSelfTests - { - public: - /** Returns the singleton instance of this class. */ - static cSelfTests & Get(void); - - // typedef void (* SelfTestFunction)(void); - typedef std::function<void(void)> SelfTestFunction; - - /** Registers a self-test to be executed once the logging framework is initialized. */ - static void Register(SelfTestFunction a_FnToExecute, const AString & a_TestName); - - /** Executes all the registered self-tests. */ - static void ExecuteAll(void); - - protected: - typedef std::vector<std::pair<SelfTestFunction, AString>> SelfTestFunctions; - - /** Functions (registered self-tests) to call once the logging framework is initialized. */ - SelfTestFunctions m_SelfTests; - - /** If true, tests may be registered. Set to false once the tests are executed, to detect tests that are registered too late. */ - bool m_AllowRegistering; - - - cSelfTests(void); - }; -#endif // SELF_TEST - - - - |