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

Unified Diff: base/debug/proc_maps_linux_unittest.cc

Issue 18328027: Fix ProcMapsTest.ReadProcMaps to work under Valgrind. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: do both Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/valgrind/gtest_exclude/base_unittests.gtest.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/proc_maps_linux_unittest.cc
diff --git a/base/debug/proc_maps_linux_unittest.cc b/base/debug/proc_maps_linux_unittest.cc
index 3b7351abed81095b966ecb43c453a4d38f7391b2..6a043b88d0a2b850af6bb0dc61fbb0e65d4ba915 100644
--- a/base/debug/proc_maps_linux_unittest.cc
+++ b/base/debug/proc_maps_linux_unittest.cc
@@ -6,6 +6,7 @@
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
+#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -195,13 +196,22 @@ TEST(ProcMapsTest, ReadProcMaps) {
uintptr_t address = reinterpret_cast<uintptr_t>(&proc_maps);
bool found_exe = false;
bool found_stack = false;
+ bool found_address = false;
for (size_t i = 0; i < regions.size(); ++i) {
if (regions[i].path == exe_path.value()) {
+ // It's OK to find the executable mapped multiple times as there'll be
+ // multiple sections (e.g., text, data).
found_exe = true;
}
- if (address >= regions[i].start && address < regions[i].end) {
- EXPECT_EQ("[stack]", regions[i].path);
+ if (regions[i].path == "[stack]") {
+ // Only check if |address| lies within the real stack when not running
+ // Valgrind, otherwise |address| will be on a stack that Valgrind creates.
+ if (!RunningOnValgrind()) {
+ EXPECT_GE(address, regions[i].start);
+ EXPECT_LT(address, regions[i].end);
+ }
+
EXPECT_TRUE(regions[i].permissions & MappedMemoryRegion::READ);
EXPECT_TRUE(regions[i].permissions & MappedMemoryRegion::WRITE);
EXPECT_FALSE(regions[i].permissions & MappedMemoryRegion::EXECUTE);
@@ -209,10 +219,16 @@ TEST(ProcMapsTest, ReadProcMaps) {
EXPECT_FALSE(found_stack) << "Found duplicate stacks";
found_stack = true;
}
+
+ if (address >= regions[i].start && address < regions[i].end) {
+ EXPECT_FALSE(found_address) << "Found same address in multiple regions";
+ found_address = true;
+ }
}
EXPECT_TRUE(found_exe);
EXPECT_TRUE(found_stack);
+ EXPECT_TRUE(found_address);
}
TEST(ProcMapsTest, MissingFields) {
« no previous file with comments | « no previous file | tools/valgrind/gtest_exclude/base_unittests.gtest.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698