Test code for feature/improve-crashlog branch

This commit is contained in:
Julian Brost 2020-10-20 11:49:28 +02:00
parent 7bfe896efb
commit dd7eabeb03

View File

@ -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<std::string>& configs, bool closeConsoleLog = fa
}
}
throw_test_exception();
/* Create the internal API object storage. Do this here too with setups without API. */
ConfigObjectUtility::CreateStorage();
@ -520,8 +536,10 @@ static pid_t StartUnixWorker(const std::vector<std::string>& configs, bool close
_exit(RunWorker(configs, closeConsoleLog, stderrFile));
} catch (const std::exception& ex) {
Log(LogCritical, "cli") << "Exception in main process: " << DiagnosticInformation(ex);
throw;
_exit(EXIT_FAILURE);
} catch (...) {
throw;
_exit(EXIT_FAILURE);
}
@ -687,8 +705,10 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
return RunWorker(configs);
} catch (const std::exception& ex) {
Log(LogCritical, "cli") << "Exception in main process: " << DiagnosticInformation(ex);
throw;
return EXIT_FAILURE;
} catch (...) {
throw;
return EXIT_FAILURE;
}
#else /* _WIN32 */