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

Unified Diff: src/processor/exploitability_unittest.cc

Issue 1697963002: Fixing a flaky Linux exploitability unittest. (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Fixing a typo. Created 4 years, 10 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
Index: src/processor/exploitability_unittest.cc
diff --git a/src/processor/exploitability_unittest.cc b/src/processor/exploitability_unittest.cc
index ec845bf025b6b6165764b4912f91512ecb082a76..502edcc79504a48193d08402570eae65700294ce 100644
--- a/src/processor/exploitability_unittest.cc
+++ b/src/processor/exploitability_unittest.cc
@@ -47,9 +47,10 @@ namespace google_breakpad {
class ExploitabilityLinuxTest : public ExploitabilityLinux {
public:
+ using ExploitabilityLinux::CalculateAddress;
using ExploitabilityLinux::DisassembleBytes;
+ using ExploitabilityLinux::GetObjdumpInstructionLine;
using ExploitabilityLinux::TokenizeObjdumpInstruction;
- using ExploitabilityLinux::CalculateAddress;
};
class ExploitabilityLinuxTestMinidumpContext : public MinidumpContext {
@@ -200,6 +201,48 @@ TEST(ExploitabilityLinuxUtilsTest, DisassembleBytesTest) {
ASSERT_EQ(line, " 0:\tc7 00 05 00 00 00 \tmov DWORD PTR [rax],0x5");
}
+TEST(ExploitabilityLinuxUtilsTest, GetObjdumpInstructionLine) {
+ string disassebly =
+ "\n"
+ "/tmp/breakpad_mem_region-raw_bytes-tMmMo0: file format binary\n"
+ "// Trying to confuse the parser 0:\n"
+ "\n"
+ "Disassembly of section .data:\n"
+ "\n"
+ "0000000000000000 <.data>:\n"
+ " 0:\tc7 00 01 00 00 00 \tmov DWORD PTR [rax],0x1\n"
+ " 6:\t5d \tpop rbp\n"
+ " 7:\tc3 \tret \n"
+ " 8:\t55 \tpush rbp\n"
+ " 9:\t48 89 e5 \tmov rbp,rsp\n"
+ " c:\t53 \tpush rbx\n"
+ " d:\t48 \trex.W\n"
+ " e:\t81 \t.byte 0x81\n";
+ string line;
+ EXPECT_TRUE(ExploitabilityLinuxTest::GetObjdumpInstructionLine(
+ disassebly.c_str(), &line));
+ EXPECT_EQ(" 0:\tc7 00 01 00 00 00 \tmov DWORD PTR [rax],0x1", line);
+
+ // There is no "0:" after "<.data>:". Expected to return false.
+ disassebly =
+ "\n"
+ "/tmp/breakpad_mem_region-raw_bytes-tMmMo0: file format binary\n"
+ "// Trying to confuse the parser 0:\n"
+ "\n"
+ "Disassembly of section .data:\n"
+ "\n"
+ " 0:\tc7 00 01 00 00 00 \tmov DWORD PTR [rax],0x1\n"
+ " 6:\t5d \tpop rbp\n"
+ " 7:\tc3 \tret \n"
+ " 8:\t55 \tpush rbp\n"
+ " 9:\t48 89 e5 \tmov rbp,rsp\n"
+ " d:\t48 \trex.W\n"
+ "0000000000000000 <.data>:\n"
+ " c:\t53 \tpush rbx\n";
+ EXPECT_FALSE(ExploitabilityLinuxTest::GetObjdumpInstructionLine(
+ disassebly.c_str(), &line));
+}
+
TEST(ExploitabilityLinuxUtilsTest, TokenizeObjdumpInstructionTest) {
ASSERT_FALSE(ExploitabilityLinuxTest::TokenizeObjdumpInstruction("",
NULL,
« src/processor/exploitability_linux.cc ('K') | « src/processor/exploitability_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698