poisson_allocation_sampler_unittest.cc 848 B

123456789101112131415161718192021222324252627
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/sampling_heap_profiler/poisson_allocation_sampler.h"
  5. #include <stdlib.h>
  6. #include "testing/gtest/include/gtest/gtest.h"
  7. namespace base {
  8. TEST(PoissonAllocationSamplerTest, MuteHooksWithoutInit) {
  9. // ScopedMuteHookedSamplesForTesting updates the allocator hooks. Make sure
  10. // is safe to call from tests that might not call
  11. // PoissonAllocationSampler::Get() to initialize the rest of the
  12. // PoissonAllocationSampler.
  13. EXPECT_FALSE(PoissonAllocationSampler::AreHookedSamplesMuted());
  14. void* volatile p = nullptr;
  15. {
  16. PoissonAllocationSampler::ScopedMuteHookedSamplesForTesting mute_hooks;
  17. p = malloc(10000);
  18. }
  19. free(p);
  20. }
  21. } // namespace base