| 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 TEST(ProcMapsTest, ReadProcMaps) { | 183 // ProcMapsTest.ReadProcMaps fails under TSan on Linux, |
| 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) { |
| 184 std::string proc_maps; | 191 std::string proc_maps; |
| 185 ASSERT_TRUE(ReadProcMaps(&proc_maps)); | 192 ASSERT_TRUE(ReadProcMaps(&proc_maps)); |
| 186 | 193 |
| 187 std::vector<MappedMemoryRegion> regions; | 194 std::vector<MappedMemoryRegion> regions; |
| 188 ASSERT_TRUE(ParseProcMaps(proc_maps, ®ions)); | 195 ASSERT_TRUE(ParseProcMaps(proc_maps, ®ions)); |
| 189 ASSERT_FALSE(regions.empty()); | 196 ASSERT_FALSE(regions.empty()); |
| 190 | 197 |
| 191 // We should be able to find both the current executable as well as the stack | 198 // We should be able to find both the current executable as well as the stack |
| 192 // mapped into memory. Use the address of |proc_maps| as a way of finding the | 199 // mapped into memory. Use the address of |proc_maps| as a way of finding the |
| 193 // stack. | 200 // stack. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 272 |
| 266 for (size_t i = 0; i < arraysize(kTestCases); ++i) { | 273 for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
| 267 SCOPED_TRACE(base::StringPrintf("kTestCases[%zu] = %s", i, kTestCases[i])); | 274 SCOPED_TRACE(base::StringPrintf("kTestCases[%zu] = %s", i, kTestCases[i])); |
| 268 std::vector<MappedMemoryRegion> regions; | 275 std::vector<MappedMemoryRegion> regions; |
| 269 EXPECT_FALSE(ParseProcMaps(kTestCases[i], ®ions)); | 276 EXPECT_FALSE(ParseProcMaps(kTestCases[i], ®ions)); |
| 270 } | 277 } |
| 271 } | 278 } |
| 272 | 279 |
| 273 } // namespace debug | 280 } // namespace debug |
| 274 } // namespace base | 281 } // namespace base |
| OLD | NEW |