Skip to content

Commit

Permalink
Implement minimal workable testing state and add test with integratio…
Browse files Browse the repository at this point in the history
…n tests.
  • Loading branch information
Rot127 committed Aug 16, 2024
1 parent 1f96475 commit 584d896
Show file tree
Hide file tree
Showing 3 changed files with 347 additions and 35 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ jobs:
- name: Build and install capstone
run: pip install ./bindings/python

- name: Run tests
- name: Run legacy tests
run: python ./bindings/python/tests/test_all.py

- name: cstest.py integration tests
run: |
cd suite/cstest/test/
python3 ./integration_tests.py "python3 ../../../bindings/python/py_cstest/cstest.py"
23 changes: 13 additions & 10 deletions bindings/python/capstone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,15 @@
CS_AC_READ_WRITE = (2)

# Capstone syntax value
CS_OPT_SYNTAX_DEFAULT = 1 << 1 # Default assembly syntax of all platforms (CS_OPT_SYNTAX)
CS_OPT_SYNTAX_INTEL = 1 << 2 # Intel X86 asm syntax - default syntax on X86 (CS_OPT_SYNTAX, CS_ARCH_X86)
CS_OPT_SYNTAX_ATT = 1 << 3 # ATT asm syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
CS_OPT_SYNTAX_NOREGNAME = 1 << 4 # Asm syntax prints register name with only number - (CS_OPT_SYNTAX, CS_ARCH_PPC, CS_ARCH_ARM)
CS_OPT_SYNTAX_MASM = 1 << 5 # MASM syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
CS_OPT_SYNTAX_MOTOROLA = 1 << 6 # MOS65XX use $ as hex prefix
CS_OPT_SYNTAX_CS_REG_ALIAS = 1 << 7 # Prints common register alias which are not defined in LLVM (ARM: r9 = sb etc.)
CS_OPT_SYNTAX_DEFAULT = (1 << 1) # Default assembly syntax of all platforms (CS_OPT_SYNTAX)
CS_OPT_SYNTAX_INTEL = (1 << 2) # Intel X86 asm syntax - default syntax on X86 (CS_OPT_SYNTAX, CS_ARCH_X86)
CS_OPT_SYNTAX_ATT = (1 << 3) # ATT asm syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
CS_OPT_SYNTAX_NOREGNAME = (1 << 4) # Asm syntax prints register name with only number - (CS_OPT_SYNTAX, CS_ARCH_PPC, CS_ARCH_ARM)
CS_OPT_SYNTAX_MASM = (1 << 5) # MASM syntax (CS_OPT_SYNTAX, CS_ARCH_X86)
CS_OPT_SYNTAX_MOTOROLA = (1 << 6) # MOS65XX use $ as hex prefix
CS_OPT_SYNTAX_CS_REG_ALIAS = (1 << 7) # Prints common register alias which are not defined in LLVM (ARM: r9 = sb etc.)
CS_OPT_SYNTAX_PERCENT = (1 << 8) # Prints the % in front of PPC registers.
CS_OPT_DETAIL_REAL = (1 << 1) # If enabled, always sets the real instruction detail.Even if the instruction is an alias.

# Capstone error type
CS_ERR_OK = 0 # No error: everything was fine
Expand Down Expand Up @@ -1021,9 +1023,10 @@ def __del__(self):
except: # _cs might be pulled from under our feet
pass


# def option(self, opt_type, opt_value):
# return _cs.cs_option(self.csh, opt_type, opt_value)
def option(self, opt_type, opt_value):
status = _cs.cs_option(self.csh, opt_type, opt_value)
if status != CS_ERR_OK:
raise CsError(status)


# is this a diet engine?
Expand Down
Loading

0 comments on commit 584d896

Please sign in to comment.