Inline expectations into EXPECT_QUIC_BUGs
This prevents reading uninitialized results if EXPECT_QUIC_BUGs ever run
as death tests.
Chromium is in the process of removing the ability to cancel FATAL
LogMessages (incl. the underlying LOG(DFATAL)s that EXPECT_QUIC_BUGs are
detecting). With this change DefaultClientProofSource passes if
EXPECT_QUIC_BUG is defined as EXPECT_DCHECK_DEATH in Chromium.
PiperOrigin-RevId: 595468073
diff --git a/quiche/quic/core/crypto/client_proof_source_test.cc b/quiche/quic/core/crypto/client_proof_source_test.cc
index a35e0aa..0104ef3 100644
--- a/quiche/quic/core/crypto/client_proof_source_test.cc
+++ b/quiche/quic/core/crypto/client_proof_source_test.cc
@@ -178,36 +178,29 @@
TEST(DefaultClientProofSource, EmptyCerts) {
DefaultClientProofSource proof_source;
- bool ok;
- EXPECT_QUIC_BUG(
- ok = proof_source.AddCertAndKey({"*"}, NullCertChain(), TestPrivateKey()),
- "Certificate chain is empty");
- ASSERT_FALSE(ok);
-
- EXPECT_QUIC_BUG(ok = proof_source.AddCertAndKey({"*"}, EmptyCertChain(),
- TestPrivateKey()),
+ EXPECT_QUIC_BUG(ASSERT_FALSE(proof_source.AddCertAndKey(
+ {"*"}, NullCertChain(), TestPrivateKey())),
"Certificate chain is empty");
- ASSERT_FALSE(ok);
+
+ EXPECT_QUIC_BUG(ASSERT_FALSE(proof_source.AddCertAndKey(
+ {"*"}, EmptyCertChain(), TestPrivateKey())),
+ "Certificate chain is empty");
EXPECT_EQ(proof_source.GetCertAndKey("*"), nullptr);
}
TEST(DefaultClientProofSource, BadCerts) {
DefaultClientProofSource proof_source;
- bool ok;
- EXPECT_QUIC_BUG(
- ok = proof_source.AddCertAndKey({"*"}, BadCertChain(), TestPrivateKey()),
- "Unabled to parse leaf certificate");
- ASSERT_FALSE(ok);
+ EXPECT_QUIC_BUG(ASSERT_FALSE(proof_source.AddCertAndKey({"*"}, BadCertChain(),
+ TestPrivateKey())),
+ "Unabled to parse leaf certificate");
EXPECT_EQ(proof_source.GetCertAndKey("*"), nullptr);
}
TEST(DefaultClientProofSource, KeyMismatch) {
DefaultClientProofSource proof_source;
- bool ok;
- EXPECT_QUIC_BUG(ok = proof_source.AddCertAndKey(
- {"www.google.com"}, TestCertChain(), EmptyPrivateKey()),
+ EXPECT_QUIC_BUG(ASSERT_FALSE(proof_source.AddCertAndKey(
+ {"www.google.com"}, TestCertChain(), EmptyPrivateKey())),
"Private key does not match the leaf certificate");
- ASSERT_FALSE(ok);
EXPECT_EQ(proof_source.GetCertAndKey("*"), nullptr);
}
diff --git a/quiche/quic/core/http/end_to_end_test.cc b/quiche/quic/core/http/end_to_end_test.cc
index a243359..83ab26a 100644
--- a/quiche/quic/core/http/end_to_end_test.cc
+++ b/quiche/quic/core/http/end_to_end_test.cc
@@ -5006,10 +5006,8 @@
if (version_.UsesTls()) {
// TODO(b/154162689) add PSK support to QUIC+TLS.
- bool ok = true;
- EXPECT_QUIC_BUG(ok = Initialize(),
+ EXPECT_QUIC_BUG(EXPECT_FALSE(Initialize()),
"QUIC client pre-shared keys not yet supported with TLS");
- EXPECT_FALSE(ok);
return;
}
@@ -5029,10 +5027,8 @@
if (version_.UsesTls()) {
// TODO(b/154162689) add PSK support to QUIC+TLS.
- bool ok = true;
- EXPECT_QUIC_BUG(ok = Initialize(),
+ EXPECT_QUIC_BUG(EXPECT_FALSE(Initialize()),
"QUIC client pre-shared keys not yet supported with TLS");
- EXPECT_FALSE(ok);
return;
}
@@ -5056,10 +5052,8 @@
if (version_.UsesTls()) {
// TODO(b/154162689) add PSK support to QUIC+TLS.
- bool ok = true;
- EXPECT_QUIC_BUG(ok = Initialize(),
+ EXPECT_QUIC_BUG(EXPECT_FALSE(Initialize()),
"QUIC server pre-shared keys not yet supported with TLS");
- EXPECT_FALSE(ok);
return;
}
@@ -5077,10 +5071,8 @@
if (version_.UsesTls()) {
// TODO(b/154162689) add PSK support to QUIC+TLS.
- bool ok = true;
- EXPECT_QUIC_BUG(ok = Initialize(),
+ EXPECT_QUIC_BUG(EXPECT_FALSE(Initialize()),
"QUIC client pre-shared keys not yet supported with TLS");
- EXPECT_FALSE(ok);
return;
}