forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
terminate_handler_test.cc
36 lines (26 loc) · 1.11 KB
/
terminate_handler_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "source/exe/terminate_handler.h"
#include "test/test_common/utility.h"
#include "gtest/gtest.h"
namespace Envoy {
class TerminateHandlerTest : public testing::Test {
public:
void logException(const std::exception_ptr e) { handler.logException(e); };
TerminateHandler handler;
};
TEST(TerminateHandlerDeathTest, HandlerInstalledTest) {
TerminateHandler handler;
EXPECT_DEATH([]() -> void { std::terminate(); }(), ".*std::terminate called!.*");
}
TEST_F(TerminateHandlerTest, LogsEnvoyException) {
EXPECT_LOG_CONTAINS("critical",
"std::terminate called! Uncaught EnvoyException 'boom', see trace.",
logException(std::make_exception_ptr(EnvoyException("boom"))));
}
TEST_F(TerminateHandlerTest, LogsUnknownException) {
EXPECT_LOG_CONTAINS("critical", "std::terminate called! Uncaught unknown exception, see trace.",
logException(std::make_exception_ptr("Boom")));
}
TEST_F(TerminateHandlerTest, HandlesNullptrCurrentException) {
EXPECT_LOG_CONTAINS("critical", "std::terminate called! See trace.", logException(nullptr));
}
} // namespace Envoy