Remove VERIFY_AND_RETURN_SUCCESS.
This is a non-standard macro that calls VERIFY_SUCCESS then returns
AssertionSuccess. The same result can be achieved by simply returning its
argument. The only change is that VERIFY_SUCCESS logs the location of this
macro upon failure, but given that every macro that potentially generates an
AssertionFailure (like VERIFY_EQ or VERIFY_FALSE) already logs the location of
the failure itself, there is not much value in this intermediate location.
PiperOrigin-RevId: 441560319
diff --git a/quiche/common/platform/api/quiche_test_helpers.h b/quiche/common/platform/api/quiche_test_helpers.h
index 5b67812..2dbe611 100644
--- a/quiche/common/platform/api/quiche_test_helpers.h
+++ b/quiche/common/platform/api/quiche_test_helpers.h
@@ -5,10 +5,4 @@
#define EXPECT_QUICHE_BUG EXPECT_QUICHE_BUG_IMPL
-#define VERIFY_AND_RETURN_SUCCESS(expression) \
- { \
- VERIFY_SUCCESS(expression); \
- return ::testing::AssertionSuccess(); \
- }
-
#endif // QUICHE_COMMON_PLATFORM_API_QUICHE_TEST_HELPERS_H_
diff --git a/quiche/http2/decoder/http2_frame_decoder_test.cc b/quiche/http2/decoder/http2_frame_decoder_test.cc
index fb6b2f5..411f46e 100644
--- a/quiche/http2/decoder/http2_frame_decoder_test.cc
+++ b/quiche/http2/decoder/http2_frame_decoder_test.cc
@@ -96,7 +96,7 @@
AssertionResult VerifyCollected(const FrameParts& expected) {
VERIFY_FALSE(collector_.IsInProgress());
VERIFY_EQ(1u, collector_.size());
- VERIFY_AND_RETURN_SUCCESS(expected.VerifyEquals(*collector_.frame(0)));
+ return expected.VerifyEquals(*collector_.frame(0));
}
AssertionResult DecodePayloadAndValidateSeveralWays(absl::string_view payload,
@@ -117,7 +117,7 @@
auto validator = [&expected, this](const DecodeBuffer& /*input*/,
DecodeStatus status) -> AssertionResult {
VERIFY_EQ(status, DecodeStatus::kDecodeDone);
- VERIFY_AND_RETURN_SUCCESS(VerifyCollected(expected));
+ return VerifyCollected(expected);
};
ResetDecodeSpeedCounters();
VERIFY_SUCCESS(DecodePayloadAndValidateSeveralWays(
@@ -161,7 +161,7 @@
auto validator = [&expected, this](const DecodeBuffer& /*input*/,
DecodeStatus status) -> AssertionResult {
VERIFY_EQ(status, DecodeStatus::kDecodeError);
- VERIFY_AND_RETURN_SUCCESS(VerifyCollected(expected));
+ return VerifyCollected(expected);
};
ResetDecodeSpeedCounters();
EXPECT_TRUE(
@@ -175,7 +175,7 @@
AssertionResult DecodePayloadExpectingFrameSizeError(const char (&buf)[N],
FrameParts expected) {
expected.SetHasFrameSizeError(true);
- VERIFY_AND_RETURN_SUCCESS(DecodePayloadExpectingError(buf, expected));
+ return DecodePayloadExpectingError(buf, expected);
}
template <size_t N>
@@ -843,7 +843,7 @@
// The decoder detects this error after decoding the header, and without
// trying to decode the payload.
VERIFY_EQ(input.Offset(), Http2FrameHeader::EncodedSize());
- VERIFY_AND_RETURN_SUCCESS(VerifyCollected(expected));
+ return VerifyCollected(expected);
};
ResetDecodeSpeedCounters();
EXPECT_TRUE(DecodePayloadAndValidateSeveralWays(ToStringPiece(kFrameData),
diff --git a/quiche/http2/decoder/http2_structure_decoder_test.cc b/quiche/http2/decoder/http2_structure_decoder_test.cc
index 5f5660c..e0fc9b6 100644
--- a/quiche/http2/decoder/http2_structure_decoder_test.cc
+++ b/quiche/http2/decoder/http2_structure_decoder_test.cc
@@ -142,14 +142,12 @@
template <size_t N>
AssertionResult DecodeLeadingStructure(const char (&data)[N]) {
- VERIFY_AND_RETURN_SUCCESS(
- DecodeLeadingStructure(nullptr, absl::string_view(data, N)));
+ return DecodeLeadingStructure(nullptr, absl::string_view(data, N));
}
template <size_t N>
AssertionResult DecodeLeadingStructure(const unsigned char (&data)[N]) {
- VERIFY_AND_RETURN_SUCCESS(
- DecodeLeadingStructure(nullptr, ToStringPiece(data)));
+ return DecodeLeadingStructure(nullptr, ToStringPiece(data));
}
// Encode the structure |in_s| into bytes, then decode the bytes
@@ -157,7 +155,7 @@
AssertionResult EncodeThenDecode(const S& in_s) {
std::string bytes = SerializeStructure(in_s);
VERIFY_EQ(S::EncodedSize(), bytes.size());
- VERIFY_AND_RETURN_SUCCESS(DecodeLeadingStructure(&in_s, bytes));
+ return DecodeLeadingStructure(&in_s, bytes);
}
// Repeatedly fill a structure with random but valid contents, encode it, then
diff --git a/quiche/http2/decoder/payload_decoders/data_payload_decoder_test.cc b/quiche/http2/decoder/payload_decoders/data_payload_decoder_test.cc
index 5df8899..8d4b6fd 100644
--- a/quiche/http2/decoder/payload_decoders/data_payload_decoder_test.cc
+++ b/quiche/http2/decoder/payload_decoders/data_payload_decoder_test.cc
@@ -92,8 +92,8 @@
set_frame_header(frame_header);
ScrubFlagsOfHeader(&frame_header);
FrameParts expected(frame_header, data_payload, total_pad_length_);
- VERIFY_AND_RETURN_SUCCESS(
- DecodePayloadAndValidateSeveralWays(frame_builder_.buffer(), expected));
+ return DecodePayloadAndValidateSeveralWays(frame_builder_.buffer(),
+ expected);
}
};
diff --git a/quiche/http2/decoder/payload_decoders/payload_decoder_base_test_util.h b/quiche/http2/decoder/payload_decoders/payload_decoder_base_test_util.h
index 856c298..efca39f 100644
--- a/quiche/http2/decoder/payload_decoders/payload_decoder_base_test_util.h
+++ b/quiche/http2/decoder/payload_decoders/payload_decoder_base_test_util.h
@@ -195,7 +195,7 @@
auto validator = [&expected, this]() -> AssertionResult {
VERIFY_FALSE(listener_.IsInProgress());
VERIFY_EQ(1u, listener_.size());
- VERIFY_AND_RETURN_SUCCESS(expected.VerifyEquals(*listener_.frame(0)));
+ return expected.VerifyEquals(*listener_.frame(0));
};
return PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays(
payload, ValidateDoneAndEmpty(validator));
@@ -234,9 +234,8 @@
VERIFY_FALSE(frame->GetOptMissingLength());
return validator(input, status);
};
- VERIFY_AND_RETURN_SUCCESS(
- PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays(payload,
- validator));
+ return PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays(
+ payload, validator);
}
// Confirm that we get OnFrameSizeError when trying to decode unpadded_payload
@@ -312,8 +311,8 @@
uint8_t known_flags = KnownFlagsMaskForFrameType(frame_type);
VERIFY_EQ(0, known_flags & Http2FrameFlag::PADDED);
VERIFY_EQ(0, required_flags & Http2FrameFlag::PADDED);
- VERIFY_AND_RETURN_SUCCESS(VerifyDetectsMultipleFrameSizeErrors(
- required_flags, unpadded_payload, approve_size, 0));
+ return VerifyDetectsMultipleFrameSizeErrors(
+ required_flags, unpadded_payload, approve_size, 0);
}
Listener listener_;
@@ -399,9 +398,8 @@
VERIFY_FALSE(frame->GetHasFrameSizeError());
return ::testing::AssertionSuccess();
};
- VERIFY_AND_RETURN_SUCCESS(
- PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays(payload,
- validator));
+ return PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays(
+ payload, validator);
}
// Verifies that we get OnPaddingTooLong for a padded frame payload whose
@@ -434,8 +432,7 @@
const Http2FrameHeader header(payload_length, DecoderPeer::FrameType(),
flags, RandStreamId());
- VERIFY_AND_RETURN_SUCCESS(
- VerifyDetectsPaddingTooLong(payload, header, missing_length));
+ return VerifyDetectsPaddingTooLong(payload, header, missing_length);
}
// total_pad_length_ includes the size of the Pad Length field, and thus
diff --git a/quiche/http2/hpack/decoder/hpack_block_decoder_test.cc b/quiche/http2/hpack/decoder/hpack_block_decoder_test.cc
index 25d603e..e8a1cb4 100644
--- a/quiche/http2/hpack/decoder/hpack_block_decoder_test.cc
+++ b/quiche/http2/hpack/decoder/hpack_block_decoder_test.cc
@@ -83,9 +83,9 @@
// http://httpwg.org/specs/rfc7541.html#rfc.section.C.2.1
TEST_F(HpackBlockDecoderTest, SpecExample_C_2_1) {
auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateSoleLiteralNameValueHeader(
+ return collector_.ValidateSoleLiteralNameValueHeader(
HpackEntryType::kIndexedLiteralHeader, false, "custom-key", false,
- "custom-header"));
+ "custom-header");
};
const char hpack_example[] = R"(
40 | == Literal indexed ==
@@ -104,8 +104,8 @@
// http://httpwg.org/specs/rfc7541.html#rfc.section.C.2.2
TEST_F(HpackBlockDecoderTest, SpecExample_C_2_2) {
auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateSoleLiteralValueHeader(
- HpackEntryType::kUnindexedLiteralHeader, 4, false, "/sample/path"));
+ return collector_.ValidateSoleLiteralValueHeader(
+ HpackEntryType::kUnindexedLiteralHeader, 4, false, "/sample/path");
};
const char hpack_example[] = R"(
04 | == Literal not indexed ==
@@ -123,9 +123,9 @@
// http://httpwg.org/specs/rfc7541.html#rfc.section.C.2.3
TEST_F(HpackBlockDecoderTest, SpecExample_C_2_3) {
auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateSoleLiteralNameValueHeader(
+ return collector_.ValidateSoleLiteralNameValueHeader(
HpackEntryType::kNeverIndexedLiteralHeader, false, "password", false,
- "secret"));
+ "secret");
};
const char hpack_example[] = R"(
10 | == Literal never indexed ==
@@ -142,9 +142,7 @@
// http://httpwg.org/specs/rfc7541.html#rfc.section.C.2.4
TEST_F(HpackBlockDecoderTest, SpecExample_C_2_4) {
- auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateSoleIndexedHeader(2));
- };
+ auto do_check = [this]() { return collector_.ValidateSoleIndexedHeader(2); };
const char hpack_example[] = R"(
82 | == Indexed - Add ==
| idx = 2
@@ -181,7 +179,7 @@
expected.ExpectNameIndexAndLiteralValue(HpackEntryType::kIndexedLiteralHeader,
1, false, "www.example.com");
NoArgValidator do_check = [expected, this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.VerifyEq(expected));
+ return collector_.VerifyEq(expected);
};
EXPECT_TRUE(DecodeHpackExampleAndValidateSeveralWays(
example, ValidateDoneAndEmpty(do_check)));
@@ -231,7 +229,7 @@
expected.ExpectNameIndexAndLiteralValue(HpackEntryType::kIndexedLiteralHeader,
46, false, "https://www.example.com");
NoArgValidator do_check = [expected, this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.VerifyEq(expected));
+ return collector_.VerifyEq(expected);
};
EXPECT_TRUE(DecodeHpackExampleAndValidateSeveralWays(
example, ValidateDoneAndEmpty(do_check)));
@@ -281,7 +279,7 @@
expected.AppendToHpackBlockBuilder(&hbb);
NoArgValidator do_check = [expected, this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.VerifyEq(expected));
+ return collector_.VerifyEq(expected);
};
EXPECT_TRUE(
DecodeAndValidateSeveralWays(hbb, ValidateDoneAndEmpty(do_check)));
diff --git a/quiche/http2/hpack/decoder/hpack_entry_decoder_test.cc b/quiche/http2/hpack/decoder/hpack_entry_decoder_test.cc
index 5307767..275495d 100644
--- a/quiche/http2/hpack/decoder/hpack_entry_decoder_test.cc
+++ b/quiche/http2/hpack/decoder/hpack_entry_decoder_test.cc
@@ -56,9 +56,7 @@
{
const char input[] = {'\x82'}; // == Index 2 ==
DecodeBuffer b(input);
- auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(2));
- };
+ auto do_check = [this]() { return collector_.ValidateIndexedHeader(2); };
EXPECT_TRUE(
DecodeAndValidateSeveralWays(&b, ValidateDoneAndEmpty(do_check)));
EXPECT_TRUE(do_check());
@@ -67,9 +65,7 @@
{
const char input[] = {'\xfe'}; // == Index 126 ==
DecodeBuffer b(input);
- auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(126));
- };
+ auto do_check = [this]() { return collector_.ValidateIndexedHeader(126); };
EXPECT_TRUE(
DecodeAndValidateSeveralWays(&b, ValidateDoneAndEmpty(do_check)));
EXPECT_TRUE(do_check());
@@ -78,9 +74,7 @@
{
const char input[] = {'\xff', '\x00'}; // == Index 127 ==
DecodeBuffer b(input);
- auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(127));
- };
+ auto do_check = [this]() { return collector_.ValidateIndexedHeader(127); };
EXPECT_TRUE(
DecodeAndValidateSeveralWays(&b, ValidateDoneAndEmpty(do_check)));
EXPECT_TRUE(do_check());
@@ -94,7 +88,7 @@
hbb.AppendIndexedHeader(ndx);
auto do_check = [this, ndx]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateIndexedHeader(ndx));
+ return collector_.ValidateIndexedHeader(ndx);
};
EXPECT_TRUE(
DecodeAndValidateSeveralWays(hbb, ValidateDoneAndEmpty(do_check)));
@@ -110,8 +104,8 @@
"custom-header"; // Value
DecodeBuffer b(input, sizeof input - 1);
auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateLiteralValueHeader(
- HpackEntryType::kIndexedLiteralHeader, 0x40, false, "custom-header"));
+ return collector_.ValidateLiteralValueHeader(
+ HpackEntryType::kIndexedLiteralHeader, 0x40, false, "custom-header");
};
EXPECT_TRUE(DecodeAndValidateSeveralWays(&b, ValidateDoneAndEmpty(do_check)));
EXPECT_TRUE(do_check());
@@ -127,9 +121,9 @@
DecodeBuffer b(input, sizeof input - 1);
auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateLiteralNameValueHeader(
+ return collector_.ValidateLiteralNameValueHeader(
HpackEntryType::kIndexedLiteralHeader, false, "custom-key", false,
- "custom-header"));
+ "custom-header");
};
EXPECT_TRUE(DecodeAndValidateSeveralWays(&b, ValidateDoneAndEmpty(do_check)));
EXPECT_TRUE(do_check());
@@ -140,7 +134,7 @@
const char input[] = "\x3f\x00";
DecodeBuffer b(input, 2);
auto do_check = [this]() {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateDynamicTableSizeUpdate(31));
+ return collector_.ValidateDynamicTableSizeUpdate(31);
};
EXPECT_TRUE(DecodeAndValidateSeveralWays(&b, ValidateDoneAndEmpty(do_check)));
EXPECT_TRUE(do_check());
@@ -171,8 +165,8 @@
value_is_huffman_encoded, value);
auto do_check = [this, ndx, value_is_huffman_encoded,
value]() -> AssertionResult {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateLiteralValueHeader(
- entry_type_, ndx, value_is_huffman_encoded, value));
+ return collector_.ValidateLiteralValueHeader(
+ entry_type_, ndx, value_is_huffman_encoded, value);
};
EXPECT_TRUE(
DecodeAndValidateSeveralWays(hbb, ValidateDoneAndEmpty(do_check)));
@@ -193,9 +187,9 @@
value_is_huffman_encoded, value);
auto do_check = [this, name_is_huffman_encoded, name,
value_is_huffman_encoded, value]() -> AssertionResult {
- VERIFY_AND_RETURN_SUCCESS(collector_.ValidateLiteralNameValueHeader(
+ return collector_.ValidateLiteralNameValueHeader(
entry_type_, name_is_huffman_encoded, name, value_is_huffman_encoded,
- value));
+ value);
};
EXPECT_TRUE(
DecodeAndValidateSeveralWays(hbb, ValidateDoneAndEmpty(do_check)));
diff --git a/quiche/http2/tools/random_decoder_test.h b/quiche/http2/tools/random_decoder_test.h
index cd23d9f..deb2744 100644
--- a/quiche/http2/tools/random_decoder_test.h
+++ b/quiche/http2/tools/random_decoder_test.h
@@ -116,7 +116,7 @@
const SelectSize& select_size,
const Validator& validator) {
DecodeStatus status = DecodeSegments(original, select_size);
- VERIFY_AND_RETURN_SUCCESS(validator(*original, status));
+ return validator(*original, status);
}
// Returns a SelectSize function for fast decoding, i.e. passing all that