OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/android/library_loader/library_prefetcher.h" | 5 #include "base/android/library_loader/library_prefetcher.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
7 #include <sys/mman.h> | 9 #include <sys/mman.h> |
8 #include <string> | 10 #include <string> |
9 #include <vector> | 11 #include <vector> |
10 #include "base/debug/proc_maps_linux.h" | 12 #include "base/debug/proc_maps_linux.h" |
11 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 | 15 |
14 namespace base { | 16 namespace base { |
15 namespace android { | 17 namespace android { |
16 | 18 |
17 namespace { | 19 namespace { |
18 const uint8 kRead = base::debug::MappedMemoryRegion::READ; | 20 const uint8_t kRead = base::debug::MappedMemoryRegion::READ; |
19 const uint8 kReadPrivate = base::debug::MappedMemoryRegion::READ | | 21 const uint8_t kReadPrivate = base::debug::MappedMemoryRegion::READ | |
20 base::debug::MappedMemoryRegion::PRIVATE; | 22 base::debug::MappedMemoryRegion::PRIVATE; |
21 const uint8 kExecutePrivate = base::debug::MappedMemoryRegion::EXECUTE | | 23 const uint8_t kExecutePrivate = base::debug::MappedMemoryRegion::EXECUTE | |
22 base::debug::MappedMemoryRegion::PRIVATE; | 24 base::debug::MappedMemoryRegion::PRIVATE; |
23 const size_t kPageSize = 4096; | 25 const size_t kPageSize = 4096; |
24 } // namespace | 26 } // namespace |
25 | 27 |
26 TEST(NativeLibraryPrefetcherTest, TestIsGoodToPrefetchNoRange) { | 28 TEST(NativeLibraryPrefetcherTest, TestIsGoodToPrefetchNoRange) { |
27 const base::debug::MappedMemoryRegion regions[4] = { | 29 const base::debug::MappedMemoryRegion regions[4] = { |
28 base::debug::MappedMemoryRegion{0x4000, 0x5000, 10, kReadPrivate, ""}, | 30 base::debug::MappedMemoryRegion{0x4000, 0x5000, 10, kReadPrivate, ""}, |
29 base::debug::MappedMemoryRegion{0x4000, 0x5000, 10, kReadPrivate, "foo"}, | 31 base::debug::MappedMemoryRegion{0x4000, 0x5000, 10, kReadPrivate, "foo"}, |
30 base::debug::MappedMemoryRegion{ | 32 base::debug::MappedMemoryRegion{ |
31 0x4000, 0x5000, 10, kReadPrivate, "foobar.apk"}, | 33 0x4000, 0x5000, 10, kReadPrivate, "foobar.apk"}, |
32 base::debug::MappedMemoryRegion{ | 34 base::debug::MappedMemoryRegion{ |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 EXPECT_EQ(33, NativeLibraryPrefetcher::PercentageOfResidentCode(ranges)); | 146 EXPECT_EQ(33, NativeLibraryPrefetcher::PercentageOfResidentCode(ranges)); |
145 // The second one. | 147 // The second one. |
146 ASSERT_EQ(0, mlock(address2, length2)); | 148 ASSERT_EQ(0, mlock(address2, length2)); |
147 EXPECT_EQ(100, NativeLibraryPrefetcher::PercentageOfResidentCode(ranges)); | 149 EXPECT_EQ(100, NativeLibraryPrefetcher::PercentageOfResidentCode(ranges)); |
148 munlock(address, length); | 150 munlock(address, length); |
149 munlock(address2, length); | 151 munlock(address2, length); |
150 } | 152 } |
151 | 153 |
152 } // namespace android | 154 } // namespace android |
153 } // namespace base | 155 } // namespace base |
OLD | NEW |