From 01d8c768a0e34d4f4ada894d5e646d88523b1756 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Tue, 20 Oct 2020 11:49:28 +0200 Subject: [PATCH] Test code for feature/improve-crashlog branch --- lib/cli/daemoncommand.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/cli/daemoncommand.cpp b/lib/cli/daemoncommand.cpp index 784ffa4d2..871f8d038 100644 --- a/lib/cli/daemoncommand.cpp +++ b/lib/cli/daemoncommand.cpp @@ -210,6 +210,20 @@ static double GetDebugWorkerDelay() } #endif /* I2_DEBUG */ +void throw_test_exception() { + if (!Utility::GetFromEnvironment("DEBUG_ABORT").IsEmpty()) { + abort(); + } + if (!Utility::GetFromEnvironment("DEBUG_THROW_CXX").IsEmpty()) { + throw std::runtime_error("test exception"); + } +#ifdef _WIN32 + if (!Utility::GetFromEnvironment("DEBUG_THROW_SEH").IsEmpty()) { + RaiseException(42, 0, 0, nullptr); + } +#endif +} + /** * Do the actual work (config loading, ...) * @@ -285,6 +299,8 @@ int RunWorker(const std::vector& configs, bool closeConsoleLog = fa } } + throw_test_exception(); + /* Create the internal API object storage. Do this here too with setups without API. */ ConfigObjectUtility::CreateStorage(); @@ -520,6 +536,7 @@ static pid_t StartUnixWorker(const std::vector& configs, bool close _exit(RunWorker(configs, closeConsoleLog, stderrFile)); } catch (...) { + throw; _exit(EXIT_FAILURE); }