Fixing a flaky Linux exploitability unittest.
BUG=https://code.google.com/p/chromium/issues/detail?id=584174 R=mmandlis@chromium.org Review URL: https://codereview.chromium.org/1697963002 .
This commit is contained in:
@@ -47,9 +47,10 @@ namespace google_breakpad {
|
||||
|
||||
class ExploitabilityLinuxTest : public ExploitabilityLinux {
|
||||
public:
|
||||
using ExploitabilityLinux::DisassembleBytes;
|
||||
using ExploitabilityLinux::TokenizeObjdumpInstruction;
|
||||
using ExploitabilityLinux::CalculateAddress;
|
||||
using ExploitabilityLinux::DisassembleBytes;
|
||||
using ExploitabilityLinux::GetObjdumpInstructionLine;
|
||||
using ExploitabilityLinux::TokenizeObjdumpInstruction;
|
||||
};
|
||||
|
||||
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,
|
||||
|
Reference in New Issue
Block a user