Revamp Python regression tests suite (#2022)

* Fix Python regression test suite (partial)

* Fix Python regression test suite

* Add a test for mapping at high addresses

* Add ctl tests
This commit is contained in:
Eli
2024-10-13 08:14:10 +03:00
committed by GitHub
parent 78580ca8f9
commit 9f578946d5
58 changed files with 1903 additions and 1455 deletions

View File

@@ -1,18 +1,19 @@
#!/usr/bin/env python
from unicorn import *
from unicorn.x86_const import *
from struct import pack
import os
import regress
from unicorn import *
from unicorn.x86_const import *
# The file we're loading is a full assembled ELF.
# Source for it, along with assembly instructions, are in x86_self_modifying.s
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x86_self_modifying.elf')
CODE_ADDR = 0x08048000
STACK_ADDR = 0x2000000
CODE = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'x86_self_modifying.elf')).read()
CODE_SIZE = len(CODE) + (0x1000 - len(CODE)%0x1000)
CODE = open(filename, 'rb').read()
CODE_SIZE = len(CODE) + (0x1000 - len(CODE) % 0x1000)
STACK_SIZE = 0x8000
ENTRY_POINT = 0x8048074
@@ -20,6 +21,7 @@ ENTRY_POINT = 0x8048074
def hook_intr(uc, intno, data):
uc.emu_stop()
class SelfModifying(regress.RegressTest):
def test_self_modifying(self):
uc = Uc(UC_ARCH_X86, UC_MODE_32)
@@ -36,5 +38,6 @@ class SelfModifying(regress.RegressTest):
retcode = uc.reg_read(UC_X86_REG_EBX)
self.assertEqual(retcode, 65)
if __name__ == '__main__':
regress.main()