1 // Copyright 2018 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 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("net/url_request_context")); 25 EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist( 26 "net/url_request_context/app_request/0x123/cookie_monster")); 27 EXPECT_TRUE( 28 IsMemoryAllocatorDumpNameInAllowlist("net/http_network_session_0x123")); 29 EXPECT_FALSE( 30 IsMemoryAllocatorDumpNameInAllowlist("net/http_network_session/0x123")); 31 EXPECT_TRUE(IsMemoryAllocatorDumpNameInAllowlist( 32 "net/http_network_session_0x123/quic_stream_factory")); 33 } 34 35 } // namespace trace_event 36 37 } // namespace base 38