- Added fullMode input in workflow_dispatch
- Take decision whether to build either in debug or release mode and if to build for all python versions according to the commit message patterns
- Set proper artifact names
- Removed not needed steps
- Compacted some steps in order to leverage more the matrix feature
- Bumped cibuildwheel action to 2.22.0
- Run actual regress tests in place of sample scripts
- Specify optional test install in pyproject.toml with proper requirements
- Derive package version from git tags
- Add GENERATORS env var support in setup.py to specify cmake generator and minor refactoring
- Minor cleanup/refactoring for the regress test suite
- Marked some regress tests with skipIf to skip them in case of old python versions
- Marked some failing regress tests to be checked with skipIf
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import regress
|
|
from unicorn import Uc, UC_ARCH_X86, UC_MODE_64, UC_HOOK_CODE
|
|
|
|
CODE = b"\x90" * 3
|
|
CODE_ADDR = 0x1000
|
|
|
|
|
|
class HookCounter:
|
|
"""Counts number of hook calls."""
|
|
|
|
def __init__(self):
|
|
self.hook_calls = 0
|
|
|
|
def bad_code_hook(self, uc, address, size, data):
|
|
self.hook_calls += 1
|
|
raise ValueError("Something went wrong")
|
|
|
|
def good_code_hook(self, uc, address, size, data):
|
|
self.hook_calls += 1
|
|
|
|
|
|
class TestExceptionInHook(regress.RegressTest):
|
|
|
|
def test_exception_in_hook(self):
|
|
uc = Uc(UC_ARCH_X86, UC_MODE_64)
|
|
uc.mem_map(CODE_ADDR, 0x1000)
|
|
uc.mem_write(CODE_ADDR, CODE)
|
|
|
|
counter = HookCounter()
|
|
uc.hook_add(UC_HOOK_CODE, counter.good_code_hook, begin=CODE_ADDR, end=CODE_ADDR + len(CODE))
|
|
uc.hook_add(UC_HOOK_CODE, counter.bad_code_hook, begin=CODE_ADDR, end=CODE_ADDR + len(CODE))
|
|
|
|
self.assertRaises(ValueError, uc.emu_start, CODE_ADDR, CODE_ADDR + len(CODE))
|
|
# Make sure hooks calls finish before raising (hook_calls == 2)
|
|
self.assertEqual(counter.hook_calls, 2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
regress.main()
|