Skip to content
Snippets Groups Projects
Commit dd529635 authored by pompolic's avatar pompolic
Browse files

More tests

parent 474fb429
No related branches found
No related tags found
No related merge requests found
...@@ -41,12 +41,25 @@ class BreakpointManagerSettingBreakpoints(unittest.TestCase): ...@@ -41,12 +41,25 @@ class BreakpointManagerSettingBreakpoints(unittest.TestCase):
self.ipbp_patcher = unittest.mock.patch('__main__.InitParserBreakpoint') self.ipbp_patcher = unittest.mock.patch('__main__.InitParserBreakpoint')
self.ipbp_mock_object = self.ipbp_patcher.start() self.ipbp_mock_object = self.ipbp_patcher.start()
self.hdpbp_patcher = unittest.mock.patch('__main__.HDoParseBreakpoint')
self.hdpbp_mock_object = self.hdpbp_patcher.start()
self.hppbp_patcher = unittest.mock.patch('__main__.HPackratParseBreakpoint')
self.hppbp_mock_object = self.hppbp_patcher.start()
self.pllpbp_patcher = unittest.mock.patch('__main__.PerformLowLevelParseBreakpoint')
self.pllpbp_mock_object = self.pllpbp_patcher.start()
self.hamrbp_patcher = unittest.mock.patch('__main__.HArenaMallocRawBreakpoint')
self.hamrbp_mock_object = self.hamrbp_patcher.start()
def tearDown(self): def tearDown(self):
self.hpprbp_patcher.stop() self.hpprbp_patcher.stop()
self.plprbp_patcher.stop() self.plprbp_patcher.stop()
self.hrbp_patcher.stop() self.hrbp_patcher.stop()
self.pvbp_patcher.stop() self.pvbp_patcher.stop()
self.ipbp_patcher.stop() self.ipbp_patcher.stop()
self.hdpbp_patcher.stop()
self.hppbp_patcher.stop()
self.pllpbp_patcher.stop()
self.hamrbp_patcher.stop()
# TODO: mock breakpoints, assert on arguments to constructor # TODO: mock breakpoints, assert on arguments to constructor
def test_set_h_rule_breakpoints(self): def test_set_h_rule_breakpoints(self):
...@@ -125,6 +138,17 @@ class BreakpointManagerSettingBreakpoints(unittest.TestCase): ...@@ -125,6 +138,17 @@ class BreakpointManagerSettingBreakpoints(unittest.TestCase):
instr = self.arch.disassemble(bp_addr, bp_addr+8, 1)[0] instr = self.arch.disassemble(bp_addr, bp_addr+8, 1)[0]
self.assertTrue(instr['asm'].startswith('ret')) self.assertTrue(instr['asm'].startswith('ret'))
def test_del_init_parser_breakpoints(self):
self.bpm.set_init_parser_breakpoint()
self.bpm.del_init_parser_breakpoint()
self.assertTrue(self.bpm.init_parser_retq.mock_calls == [unittest.mock.call.delete()])
def test_set_hammer_breakpoints(self):
self.bpm.set_hammer_breakpoints()
bps = [self.hdpbp_mock_object, self.hppbp_mock_object, self.pllpbp_mock_object, self.hamrbp_mock_object]
for i in range(0, len(bps)):
with self.subTest(i=i):
self.assertTrue(bps[i].called)
# TODO # TODO
#def tearDown(self): #def tearDown(self):
#self.bpm.delete #self.bpm.delete
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment