Test code for feature/improve-crashlog branch

This commit is contained in:
Julian Brost 2020-10-20 11:49:28 +02:00
parent ab77dabc43
commit fc89dedfd0

View File

@ -191,6 +191,20 @@ pid_t l_UmbrellaPid = 0;
static Atomic<bool> l_AllowedToWork (false);
#endif /* _WIN32 */
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, ...)
*
@ -254,6 +268,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();
@ -483,6 +499,7 @@ static pid_t StartUnixWorker(const std::vector<std::string>& configs, bool close
Log(LogCritical, "cli") << "Exception in main process: " << DiagnosticInformation(ex);
_exit(EXIT_FAILURE);
} catch (...) {
throw;
_exit(EXIT_FAILURE);
}
@ -648,8 +665,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 */