1 // Copyright 2018 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/trace_event/memory_infra_background_allowlist.h" 6 7 #include "testing/gtest/include/gtest/gtest.h" 8 9 namespace base { 10 11 namespace trace_event { 12 TEST(MemoryInfraBackgroundAllowlist,Allowlist)13TEST(MemoryInfraBackgroundAllowlist, Allowlist) { 14 // Global dumps that are of hex digits are all allowed for background use. 15 EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist("global/01234ABCDEF")); 16 EXPECT_TRUE( 17 IsMemoryAllocatorDumpNameInAllowlist("shared_memory/01234ABCDEF")); 18 19 // Global dumps that contain non-hex digits are not in the allowlist. 20 EXPECT_FALSE(IsMemoryAllocatorDumpNameInAllowlist("global/GHIJK")); 21 EXPECT_FALSE(IsMemoryAllocatorDumpNameInAllowlist("shared_memory/GHIJK")); 22 23 // Test a couple that contain pointer values. 24 EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist("blink_gc/main/heap")); 25 EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist( 26 "blink_gc/workers/worker_0x123/heap")); 27 EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist( 28 "blink_gc/workers/heap/worker_0x123")); 29 EXPECT_FALSE( 30 IsMemoryAllocatorDumpNameInAllowlist("blink_gc/main/heap/0x123")); 31 } 32 33 } // namespace trace_event 34 35 } // namespace base 36