Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/common/common/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ void resetEnvoyBugCountersForTest();
ENVOY_LOG_TO_LOGGER(Envoy::Logger::Registry::getLog(Envoy::Logger::Id::assert), critical, \
"assert failure: {}.{}{}", CONDITION_STR, \
details.empty() ? "" : " Details: ", details); \
Envoy::Assert::EnvoyBugStackTrace st; \
st.capture(); \
st.logStackTrace(); \
ACTION; \
} \
} while (false)
Expand Down
14 changes: 14 additions & 0 deletions test/common/common/assert_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Envoy {

static void releaseAssertInAFunction() { RELEASE_ASSERT(0, ""); }

TEST(ReleaseAssertDeathTest, VariousLogs) {
EXPECT_DEATH({ RELEASE_ASSERT(0, ""); }, ".*assert failure: 0.*");
EXPECT_DEATH({ RELEASE_ASSERT(0, "With some logs"); },
Expand All @@ -15,6 +17,18 @@ TEST(ReleaseAssertDeathTest, VariousLogs) {
".*assert failure: 0 == EAGAIN. Details: using fmt.*");
}

TEST(ReleaseAssertDeathTest, AssertIncludesStackTrace) {
#ifdef NDEBUG
GTEST_SKIP() << "optimized build inlines functions so the stack trace won't be reliable";
#endif
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
GTEST_SKIP() << "memory sanitizer build inlines functions so the stack trace won't be reliable";
#endif
#endif
EXPECT_DEATH({ releaseAssertInAFunction(); }, "releaseAssertInAFunction");
}

TEST(AssertDeathTest, VariousLogs) {
int expected_counted_failures;
// Use 2 assert action registrations to verify that action chaining is working correctly.
Expand Down
Loading