StatisticsRecorder and HistogramTester conflict and break tests in order-dependent way |
||
Issue descriptionVersion: 51.0.2670 OS: all (tests only) The basic problem is that HistogramTester objects do not play nice with local StastiticsRecorder objects. Specifically, HistogramTester calls StatisticsRecorder::Initialize() which creates the global SR object. After that point, any attempt to create a local SR object will crash on DCHECK(!histograms_) in the SR constructor. base_unittests has one existing instance of HistogramTester and that is within histogram_tester_unittest.cc. By luck, this test conveniently runs later and only one test after it attempts to create local SR objects. The only one that does is "HistogramTest" which included the SR::ResetForTesting() method (that is actually just a hack to get around the just-described problem). The fix for this is non-trivial. If HistogramTester were to create its own instance of a StatisticsRecorder (which was obviously avoided purposely during its development) then it would crash if any previous test initialized the lazy-instance with the (global) SR. The simplest solution seems to be to simply delete the global instance inside ResetForTesting()... except there is no way to reset a LazyInstance. Run base_unittests with --gtest_shuffle to witness the failure.
,
Apr 8 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/b113b974a0cc071bd9822b499975307529eac294 commit b113b974a0cc071bd9822b499975307529eac294 Author: bcwhite <bcwhite@chromium.org> Date: Fri Apr 08 17:38:29 2016 Fix StatisticsRecorder to handle re-entry during tests. BUG= 592747 Review URL: https://codereview.chromium.org/1779503002 Cr-Commit-Position: refs/heads/master@{#386119} [modify] https://crrev.com/b113b974a0cc071bd9822b499975307529eac294/base/metrics/histogram_unittest.cc [modify] https://crrev.com/b113b974a0cc071bd9822b499975307529eac294/base/metrics/sparse_histogram_unittest.cc [modify] https://crrev.com/b113b974a0cc071bd9822b499975307529eac294/base/metrics/statistics_recorder.cc [modify] https://crrev.com/b113b974a0cc071bd9822b499975307529eac294/base/metrics/statistics_recorder.h [modify] https://crrev.com/b113b974a0cc071bd9822b499975307529eac294/base/metrics/statistics_recorder_unittest.cc
,
Apr 12 2016
Included in M51 beta. |
||
►
Sign in to add a comment |
||
Comment 1 by asvitk...@chromium.org
, Mar 7 2016