0

[gtest] Consume AssertionResults in system_trust_store_nss...cc

`ASSERT_NO_FATAL_FAILURE(...)` checks for `ASSERT_*` failures while
executing the provided statement [0] but discards any expression. Use a
plain `ASSERT_TRUE()` to actually check that `ParseX509Certificate()`
succeeds.

The dropped assertion causes a build failure [1] with a recent
Googletest revision that marks `AssertionResult` as `[[nodiscard]]` [2].

[0]: https://google.github.io/googletest/advanced.html#asserting-on-subroutines
[1]: https://ci.chromium.org/ui/p/chromium/builders/try/chromeos-amd64-generic-rel-gtest/374803/overview
[2]: 3fbe4db9a3%5E%21/

Bug: 398298306
Change-Id: I809e26995510d4055d8aa9282be377cb86b34455
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6299635
Commit-Queue: Matt Mueller <mattm@chromium.org>
Reviewed-by: Matt Mueller <mattm@chromium.org>
Auto-Submit: Jonathan Lee <jonathanjlee@google.com>
Cr-Commit-Position: refs/heads/main@{#1424797}
This commit is contained in:
Jonathan Lee
2025-02-25 14:05:04 -08:00
committed by Chromium LUCI CQ
parent 46b56e058d
commit d09f5c193b

@@ -31,7 +31,7 @@ namespace net {
namespace { namespace {
// Parses |x509_cert| as a bssl::ParsedCertificate and stores the output in // Parses |x509_cert| as a bssl::ParsedCertificate and stores the output in
// *|out_parsed_cert|. Wrap in ASSERT_NO_FATAL_FAILURE on callsites. // *|out_parsed_cert|.
::testing::AssertionResult ParseX509Certificate( ::testing::AssertionResult ParseX509Certificate(
const scoped_refptr<X509Certificate>& x509_cert, const scoped_refptr<X509Certificate>& x509_cert,
std::shared_ptr<const bssl::ParsedCertificate>* out_parsed_cert) { std::shared_ptr<const bssl::ParsedCertificate>* out_parsed_cert) {
@@ -62,8 +62,7 @@ class SystemTrustStoreNSSTest : public ::testing::Test {
root_cert_ = root_cert_ =
ImportCertFromFile(GetTestCertsDirectory(), "root_ca_cert.pem"); ImportCertFromFile(GetTestCertsDirectory(), "root_ca_cert.pem");
ASSERT_TRUE(root_cert_); ASSERT_TRUE(root_cert_);
ASSERT_NO_FATAL_FAILURE( ASSERT_TRUE(ParseX509Certificate(root_cert_, &parsed_root_cert_));
ParseX509Certificate(root_cert_, &parsed_root_cert_));
nss_root_cert_ = nss_root_cert_ =
x509_util::CreateCERTCertificateFromX509Certificate(root_cert_.get()); x509_util::CreateCERTCertificateFromX509Certificate(root_cert_.get());
ASSERT_TRUE(nss_root_cert_); ASSERT_TRUE(nss_root_cert_);