Пример #1
0
class Harness(TestCase):
    def setUp(self):
        self.build_command()
        subprocess.check_output('objcopy --only-keep-debug dummy dummy.debug'
                                .split())
        self.debug_command()
        subprocess.check_output('strip dummy'.split())
        self.process = subprocess.Popen('./dummy', stdout=subprocess.PIPE)
        # The process prints out the address of some symbol, which we then
        # try to resolve in the test.
        self.addr = int(self.process.stdout.readline().strip(), 16)
        self.syms = SymbolCache(self.process.pid)

    def tearDown(self):
        self.process.kill()
        self.process.wait()

    def resolve_addr(self):
        sym, offset, module = self.syms.resolve(self.addr, False)
        self.assertEqual(sym, self.mangled_name)
        self.assertEqual(offset, 0)
        self.assertTrue(module[-5:] == 'dummy')
        sym, offset, module = self.syms.resolve(self.addr, True)
        self.assertEqual(sym, 'some_namespace::some_function(int, int)')
        self.assertEqual(offset, 0)
        self.assertTrue(module[-5:] == 'dummy')


    def resolve_name(self):
        script_dir = os.path.dirname(os.path.realpath(__file__))
        addr = self.syms.resolve_name(os.path.join(script_dir, 'dummy'),
                                      self.mangled_name)
        self.assertEqual(addr, self.addr)
        pass
Пример #2
0
class Harness(TestCase):
    def setUp(self):
        self.build_command()
        subprocess.check_output(
            'objcopy --only-keep-debug dummy dummy.debug'.split())
        self.debug_command()
        subprocess.check_output('strip dummy'.split())
        self.process = subprocess.Popen('./dummy', stdout=subprocess.PIPE)
        # The process prints out the address of some symbol, which we then
        # try to resolve in the test.
        self.addr = int(self.process.stdout.readline().strip(), 16)
        self.syms = SymbolCache(self.process.pid)

    def tearDown(self):
        self.process.kill()
        self.process.wait()

    def resolve_addr(self):
        sym, offset, module = self.syms.resolve(self.addr)
        self.assertEqual(sym, 'some_function')
        self.assertEqual(offset, 0)
        self.assertTrue(module[-5:] == 'dummy')

    def resolve_name(self):
        script_dir = os.path.dirname(os.path.realpath(__file__))
        addr = self.syms.resolve_name(os.path.join(script_dir, 'dummy'),
                                      'some_function')
        self.assertEqual(addr, self.addr)
        pass
Пример #3
0
 def setUp(self):
     self.build_command()
     subprocess.check_output(
         'objcopy --only-keep-debug dummy dummy.debug'.split())
     self.debug_command()
     subprocess.check_output('strip dummy'.split())
     self.process = subprocess.Popen('./dummy', stdout=subprocess.PIPE)
     # The process prints out the address of some symbol, which we then
     # try to resolve in the test.
     self.addr = int(self.process.stdout.readline().strip(), 16)
     self.syms = SymbolCache(self.process.pid)
Пример #4
0
 def setUp(self):
     self.build_command()
     subprocess.check_output('objcopy --only-keep-debug dummy dummy.debug'
                             .split())
     self.debug_command()
     subprocess.check_output('strip dummy'.split())
     self.process = subprocess.Popen('./dummy', stdout=subprocess.PIPE)
     # The process prints out the address of some symbol, which we then
     # try to resolve in the test.
     self.addr = int(self.process.stdout.readline().strip(), 16)
     self.syms = SymbolCache(self.process.pid)