Skip to content

Commit 1140c93

Browse files
authored
Make EXPECT_ENVOY_BUG not leak between test cases (#30844)
* Make EXPECT_ENVOY_BUG not leak between test cases Signed-off-by: Raven Black <[email protected]> * Use the public interface Signed-off-by: Raven Black <[email protected]> * include assert.h Signed-off-by: Raven Black <[email protected]> * Strict namespace Signed-off-by: Raven Black <[email protected]> * Don't expect non-logging for quic Signed-off-by: Raven Black <[email protected]> --------- Signed-off-by: Raven Black <[email protected]>
1 parent b056211 commit 1140c93

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

test/common/quic/platform/quic_platform_test.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,9 @@ TEST_F(QuicPlatformTest, QuicClientStats) {
110110

111111
TEST_F(QuicPlatformTest, QuicExpectBug) {
112112
auto bug = [](const char* error_message) { QUIC_BUG(bug_id) << error_message; };
113-
114113
auto peer_bug = [](const char* error_message) { QUIC_PEER_BUG(bug_id) << error_message; };
115114
EXPECT_QUIC_BUG(bug("bug one is expected"), "bug one");
116115
EXPECT_QUIC_BUG(bug("bug two is expected"), "bug two");
117-
#ifdef NDEBUG
118-
// The 3rd triggering in release mode should not be logged.
119-
EXPECT_LOG_NOT_CONTAINS("error", "bug three", bug("bug three is expected"));
120-
#else
121-
EXPECT_QUIC_BUG(bug("bug three is expected"), "bug three");
122-
#endif
123-
124116
EXPECT_QUIC_PEER_BUG(peer_bug("peer_bug_1 is expected"), "peer_bug_1");
125117
EXPECT_QUIC_PEER_BUG(peer_bug("peer_bug_2 is expected"), "peer_bug_2");
126118
}

test/extensions/filters/http/cache/cache_filter_test.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,21 +1150,18 @@ TEST_F(CacheFilterDeathTest, StreamTimeoutDuringLookup) {
11501150
}
11511151

11521152
TEST(LookupStatusDeathTest, ResolveLookupStatusRequireValidationAndInitialIsBug) {
1153-
GTEST_SKIP(); // TODO(issue #29217): Remove skip.
11541153
EXPECT_ENVOY_BUG(
11551154
CacheFilter::resolveLookupStatus(CacheEntryStatus::RequiresValidation, FilterState::Initial),
11561155
"Unexpected filter state in requestCacheStatus");
11571156
}
11581157

11591158
TEST(LookupStatusDeathTest, ResolveLookupStatusRequireValidationAndDecodeServingFromCacheIsBug) {
1160-
GTEST_SKIP(); // TODO(issue #29217): Remove skip.
11611159
EXPECT_ENVOY_BUG(CacheFilter::resolveLookupStatus(CacheEntryStatus::RequiresValidation,
11621160
FilterState::DecodeServingFromCache),
11631161
"Unexpected filter state in requestCacheStatus");
11641162
}
11651163

11661164
TEST(LookupStatusDeathTest, ResolveLookupStatusRequireValidationAndDestroyedIsBug) {
1167-
GTEST_SKIP(); // TODO(issue #29217): Remove skip.
11681165
EXPECT_ENVOY_BUG(CacheFilter::resolveLookupStatus(CacheEntryStatus::RequiresValidation,
11691166
FilterState::Destroyed),
11701167
"Unexpected filter state in requestCacheStatus");

test/test_common/logging.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <string>
55
#include <vector>
66

7+
#include "source/common/common/assert.h"
78
#include "source/common/common/logger.h"
89

910
#include "absl/strings/str_join.h"
@@ -97,6 +98,7 @@ using ExpectedLogMessages = std::vector<StringPair>;
9798
#define EXPECT_LOG_CONTAINS_ALL_OF_HELPER(expected_messages, stmt, escaped) \
9899
do { \
99100
ASSERT_FALSE(expected_messages.empty()) << "Expected messages cannot be empty."; \
101+
::Envoy::Assert::resetEnvoyBugCountersForTest(); \
100102
Envoy::LogLevelSetter save_levels(spdlog::level::trace); \
101103
Envoy::Logger::DelegatingLogSinkSharedPtr sink_ptr = Envoy::Logger::Registry::getSink(); \
102104
sink_ptr->setShouldEscape(escaped); \

0 commit comments

Comments
 (0)