0

Reland "Make DUMP_WILL_BE_* fatal for non-official builds"

This is a reland of commit 029ef5893a

Original change's description:
> Make DUMP_WILL_BE_* fatal for non-official builds
>
> This is a proxy for non-user-facing builds (testing, fuzzing). Any early
> detection for will-be-fatal invariant violations seems good at face
> value, let's try it out.
>
> Bug: None
> Change-Id: I46322b144d8e871bb4a83e9fe45f0958ebe97eee
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5783255
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Commit-Queue: Daniel Cheng <dcheng@chromium.org>
> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
> Auto-Submit: Peter Boström <pbos@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1341369}

Bug: None
Change-Id: Ifc76813daae7298d5d7913e864dbe2ba8b8658ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5792849
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1352536}
This commit is contained in:
Peter Boström
2024-09-09 01:09:23 +00:00
committed by Chromium LUCI CQ
parent 639c9286a8
commit 04bfc3ba33
10 changed files with 57 additions and 29 deletions

@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/prefs/pref_notifier_impl.h"
#include <stddef.h>
#include "base/dcheck_is_on.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "components/prefs/mock_pref_change_callback.h"
#include "components/prefs/pref_notifier_impl.h"
#include "components/prefs/pref_observer.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
@ -122,9 +124,9 @@ TEST_F(PrefNotifierTest, AddAndRemovePrefObservers) {
ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs2_));
// Re-adding the same observer for the same pref doesn't change anything.
// Skip this in debug mode, since it hits a DCHECK and death tests aren't
// thread-safe.
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
// This hits a DUMP_WILL_BE_NOTREACHED() which is fatal in non-official
// builds.
#if defined(OFFICIAL_BUILD) && !DCHECK_IS_ON()
notifier.AddPrefObserver(pref_name, &obs1_);
ASSERT_EQ(1u, notifier.CountObserver(pref_name, &obs1_));
ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs1_));