| 1 | //===-- late_init.cpp -------------------------------------------*- C++ -*-===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "gwp_asan/guarded_pool_allocator.h" |
| 10 | #include "gwp_asan/options.h" |
| 11 | #include "gwp_asan/tests/harness.h" |
| 12 | |
| 13 | TEST(LateInit, CheckLateInitIsOK) { |
| 14 | gwp_asan::GuardedPoolAllocator GPA; |
| 15 | |
| 16 | for (size_t i = 0; i < 0x100; ++i) |
| 17 | EXPECT_FALSE(GPA.shouldSample()); |
| 18 | |
| 19 | gwp_asan::options::Options Opts; |
| 20 | Opts.Enabled = true; |
| 21 | Opts.SampleRate = 1; |
| 22 | |
| 23 | GPA.init(Opts); |
| 24 | EXPECT_TRUE(GPA.shouldSample()); |
| 25 | GPA.uninitTestOnly(); |
| 26 | } |
| 27 |
