Clear log stream before failing with longjmp in fatal log

When an assertion fails in the C++ API, it ultimately invokes a
`Fatal`-level `DeepState_Log()`. This calls `DeepState_Fail()`, which
longjmps. If we don't clear the log buffer here, it won't get cleared by
the usual logic which does so. This causes hanging, unflushed log
messages to persist between tests.

This relationship should eventually be inverted and decoupled.
This commit is contained in:
Joe Ranweiler 2018-02-09 17:33:17 -08:00
parent 4a90b2a5e8
commit d81cbba137
No known key found for this signature in database
GPG Key ID: E0B6458CB03D167E

View File

@ -77,6 +77,9 @@ void DeepState_Log(enum DeepState_LogLevel level, const char *str) {
if (DeepState_LogError == level) {
DeepState_SoftFail();
} else if (DeepState_LogFatal == level) {
/* `DeepState_Fail()` calls `longjmp()`, so we need to make sure
* we clean up the log buffer first. */
DeepState_ClearStream(level);
DeepState_Fail();
}
}