def setUp(self): cpu_factory = TestCpuFactory() cpu = cpu_factory.create_cpu(TestCpu.architecture()) inferior_factory = TestInferiorFactory() inferior = inferior_factory.create_inferior(cpu, 0) self._inferior_repository = InferiorRepository() self._inferior_repository.add_inferior(inferior) thread_factory = TestThreadFactory() thread_factory.create_thread(inferior, 0) self._platform_factory = TestPlatformFactory()
def test_command(self): inferior_factory = TestInferiorFactory() thread_factory = TestThreadFactory() inferior_repository = InferiorRepository() bldr = CommandBuilder(TestCommandFactory(), inferior_repository, TestPlatformFactory(), inferior_factory, thread_factory, Configuration(), self._terminal) self.assertIn(TestCommand.name(), bldr.commands) self.assertIn(TestDataCommand.name(), bldr.commands)
class ContextTest(TestCase): def setUp(self): cpu_factory = TestCpuFactory() cpu = cpu_factory.create_cpu(TestCpu.architecture()) inferior_factory = TestInferiorFactory() inferior = inferior_factory.create_inferior(cpu, 0) self._inferior_repository = InferiorRepository() self._inferior_repository.add_inferior(inferior) thread_factory = TestThreadFactory() thread_factory.create_thread(inferior, 0) self._platform_factory = TestPlatformFactory() def test_registers(self): inferior = self._inferior_repository.get_inferior(0) thread = inferior.thread(0) context = self._platform_factory.create_context(Configuration(), inferior, thread) for _, register_dict in inferior.cpu().registers(): for name, register in register_dict.items(): self.assertIsNotNone(context.register(name)) context_register = context.register(name) self.assertEqual(register.size(), context_register.size()) self.assertEqual(register.value(), context_register.value())
class ContextTest(TestCase): def setUp(self): cpu_factory = TestCpuFactory() cpu = cpu_factory.create_cpu(TestCpu.architecture()) inferior_factory = TestInferiorFactory() inferior = inferior_factory.create_inferior(cpu, 0) self._inferior_repository = InferiorRepository() self._inferior_repository.add_inferior(inferior) thread_factory = TestThreadFactory() thread_factory.create_thread(inferior, 0) self._platform_factory = TestPlatformFactory() def test_registers(self): inferior = self._inferior_repository.get_inferior(0) thread = inferior.thread(0) context = self._platform_factory.create_context( Configuration(), inferior, thread) for _, register_dict in inferior.cpu().registers(): for name, register in register_dict.iteritems(): self.assertIsNotNone(context.register(name)) context_register = context.register(name) self.assertEqual(register.size(), context_register.size()) self.assertEqual(register.value(), context_register.value())
def test_inferior_repository(self): inferior_repository = InferiorRepository() self.assertFalse(inferior_repository.has_inferior(0))