OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/debug/proc_maps_linux.h" | 5 #include "base/debug/proc_maps_linux.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 std::vector<MappedMemoryRegion> regions; | 174 std::vector<MappedMemoryRegion> regions; |
175 EXPECT_TRUE(ParseProcMaps(kTestCases[i].input, ®ions)); | 175 EXPECT_TRUE(ParseProcMaps(kTestCases[i].input, ®ions)); |
176 EXPECT_EQ(1u, regions.size()); | 176 EXPECT_EQ(1u, regions.size()); |
177 if (regions.empty()) | 177 if (regions.empty()) |
178 continue; | 178 continue; |
179 EXPECT_EQ(kTestCases[i].permissions, regions[0].permissions); | 179 EXPECT_EQ(kTestCases[i].permissions, regions[0].permissions); |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 // ProcMapsTest.ReadProcMaps fails under TSan on Linux, | 183 TEST(ProcMapsTest, ReadProcMaps) { |
184 // see http://crbug.com/258451. | |
185 #if defined(THREAD_SANITIZER) | |
186 #define MAYBE_ReadProcMaps DISABLED_ReadProcMaps | |
187 #else | |
188 #define MAYBE_ReadProcMaps ReadProcMaps | |
189 #endif | |
190 TEST(ProcMapsTest, MAYBE_ReadProcMaps) { | |
191 std::string proc_maps; | 184 std::string proc_maps; |
192 ASSERT_TRUE(ReadProcMaps(&proc_maps)); | 185 ASSERT_TRUE(ReadProcMaps(&proc_maps)); |
193 | 186 |
194 std::vector<MappedMemoryRegion> regions; | 187 std::vector<MappedMemoryRegion> regions; |
195 ASSERT_TRUE(ParseProcMaps(proc_maps, ®ions)); | 188 ASSERT_TRUE(ParseProcMaps(proc_maps, ®ions)); |
196 ASSERT_FALSE(regions.empty()); | 189 ASSERT_FALSE(regions.empty()); |
197 | 190 |
198 // We should be able to find both the current executable as well as the stack | 191 // We should be able to find both the current executable as well as the stack |
199 // mapped into memory. Use the address of |proc_maps| as a way of finding the | 192 // mapped into memory. Use the address of |proc_maps| as a way of finding the |
200 // stack. | 193 // stack. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 265 |
273 for (size_t i = 0; i < arraysize(kTestCases); ++i) { | 266 for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
274 SCOPED_TRACE(base::StringPrintf("kTestCases[%zu] = %s", i, kTestCases[i])); | 267 SCOPED_TRACE(base::StringPrintf("kTestCases[%zu] = %s", i, kTestCases[i])); |
275 std::vector<MappedMemoryRegion> regions; | 268 std::vector<MappedMemoryRegion> regions; |
276 EXPECT_FALSE(ParseProcMaps(kTestCases[i], ®ions)); | 269 EXPECT_FALSE(ParseProcMaps(kTestCases[i], ®ions)); |
277 } | 270 } |
278 } | 271 } |
279 | 272 |
280 } // namespace debug | 273 } // namespace debug |
281 } // namespace base | 274 } // namespace base |
OLD | NEW |