Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: base/debug/proc_maps_linux_unittest.cc

Issue 18661009: Update ReadProcMaps() to reflect lack of atomicity when reading /proc/self/maps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« base/debug/proc_maps_linux.cc ('K') | « base/debug/proc_maps_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
173 173
174 std::vector<MappedMemoryRegion> regions; 174 std::vector<MappedMemoryRegion> regions;
175 EXPECT_TRUE(ParseProcMaps(kTestCases[i].input, &regions)); 175 EXPECT_TRUE(ParseProcMaps(kTestCases[i].input, &regions));
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, &regions)); 188 ASSERT_TRUE(ParseProcMaps(proc_maps, &regions));
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
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], &regions)); 269 EXPECT_FALSE(ParseProcMaps(kTestCases[i], &regions));
277 } 270 }
278 } 271 }
279 272
280 } // namespace debug 273 } // namespace debug
281 } // namespace base 274 } // namespace base
OLDNEW
« base/debug/proc_maps_linux.cc ('K') | « base/debug/proc_maps_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698