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

Unified Diff: base/debug/proc_maps_linux_unittest.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « base/command_line_unittest.cc ('k') | base/i18n/build_utf8_validator_tables.cc » ('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 142f891845d3f43d41cd10ef01ede0761522ac02..c9f2267e166e15cdcf8241cee9f8b20d51f3ca86 100644
--- a/base/debug/proc_maps_linux_unittest.cc
+++ b/base/debug/proc_maps_linux_unittest.cc
@@ -199,13 +199,6 @@ TEST(ProcMapsTest, ReadProcMaps) {
bool found_stack = false;
bool found_address = false;
- // Valgrind uses its own allocated stacks instead of the kernel-provided stack
- // without letting the kernel know via prctl(PR_SET_MM_START_STACK). This
- // causes the kernel to use [stack:TID] format. See http://crbug.com/431702
- // for details.
- std::string stack_with_tid =
- StringPrintf("[stack:%d]", PlatformThread::CurrentId());
-
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
@@ -213,23 +206,28 @@ TEST(ProcMapsTest, ReadProcMaps) {
found_exe = true;
}
- bool is_correct_stack = false;
- if (regions[i].path == "[stack]") {
- is_correct_stack = true;
- EXPECT_FALSE(RunningOnValgrind());
+ // Valgrind uses its own allocated stacks instead of the kernel-provided
+ // stack without letting the kernel know via prctl(PR_SET_MM_START_STACK).
+ // Depending on which kernel you're running it'll impact the output of
+ // /proc/self/maps.
+ //
+ // Prior to version 3.4, the kernel completely ignores other stacks and
+ // always prints out the vma lying within mm->start_stack as [stack] even
+ // if the program was currently executing on a different stack.
+ //
+ // Starting in 3.4, the kernel will print out the vma containing the current
+ // stack pointer as [stack:TID] as long as that vma does not lie within
+ // mm->start_stack.
+ //
+ // Because this has gotten too complicated and brittle of a test, completely
+ // ignore checking for the stack and address when running under Valgrind.
+ // See http://crbug.com/431702 for more details.
+ if (!RunningOnValgrind() && regions[i].path == "[stack]") {
EXPECT_GE(address, regions[i].start);
EXPECT_LT(address, regions[i].end);
- } else if (regions[i].path == stack_with_tid) {
- is_correct_stack = true;
- EXPECT_TRUE(RunningOnValgrind());
- }
-
- if (is_correct_stack) {
- // Note that the stack is executable when it is created by Valgrind.
EXPECT_TRUE(regions[i].permissions & MappedMemoryRegion::READ);
EXPECT_TRUE(regions[i].permissions & MappedMemoryRegion::WRITE);
- EXPECT_EQ(RunningOnValgrind(),
- (regions[i].permissions & MappedMemoryRegion::EXECUTE) != 0);
+ EXPECT_FALSE(regions[i].permissions & MappedMemoryRegion::EXECUTE);
EXPECT_TRUE(regions[i].permissions & MappedMemoryRegion::PRIVATE);
EXPECT_FALSE(found_stack) << "Found duplicate stacks";
found_stack = true;
@@ -242,8 +240,10 @@ TEST(ProcMapsTest, ReadProcMaps) {
}
EXPECT_TRUE(found_exe);
- EXPECT_TRUE(found_stack);
- EXPECT_TRUE(found_address);
+ if (!RunningOnValgrind()) {
+ EXPECT_TRUE(found_stack);
+ EXPECT_TRUE(found_address);
+ }
}
TEST(ProcMapsTest, ReadProcMapsNonEmptyString) {
« no previous file with comments | « base/command_line_unittest.cc ('k') | base/i18n/build_utf8_validator_tables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698