Skip to content

Commit

Permalink
fix python binding
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeor committed Mar 7, 2023
1 parent 7ef8e5b commit 824dc5e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CITest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
run: |
./make.sh;
make check;
cp libcapstone.so.5 libcapstone.so.5.0
# sudo make install
- name: cmake
Expand All @@ -108,7 +109,6 @@ jobs:
- name: build python binding
shell: 'script -q -e -c "bash {0}"'
run: |
pwd && ls;
mkdir -p bindings/python/capstone/lib && cp libcapstone.so.5.* bindings/python/capstone/lib/libcapstone.so;
cd bindings/python;
make && make check ;
Expand Down
5 changes: 4 additions & 1 deletion bindings/python/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def test_cs_disasm_quick():


def test_different_data_formats():
data = bytes.fromhex('4831C948F7E1043B48BB0A2F62696E2F2F736852530A545F5257545E0F05')
if _python3:
data = bytes.fromhex('4831C948F7E1043B48BB0A2F62696E2F2F736852530A545F5257545E0F05')
else:
data = bytes(bytearray.fromhex('4831C948F7E1043B48BB0A2F62696E2F2F736852530A545F5257545E0F05'))
mnemonics = ['xor', 'mul', 'add', 'movabs', 'push', 'pop', 'push', 'push', 'push', 'pop', 'syscall']
disassembler = Cs(CS_ARCH_X86, CS_MODE_64)
for name, code in (
Expand Down
8 changes: 7 additions & 1 deletion suite/regress/test_arm64_ldr_registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from capstone import *
from capstone.arm64 import *

_python3 = sys.version_info.major == 3


class SubRegTest(unittest.TestCase):

PATTERNS = [
Expand All @@ -18,7 +21,10 @@ def setUp(self):
self.cs.detail = True

for pattern, asm in self.PATTERNS:
l = list(self.cs.disasm(bytes.fromhex(pattern), 0))
if _python3:
l = list(self.cs.disasm(bytes.fromhex(pattern), 0))
else:
l = list(self.cs.disasm(bytearray.fromhex(pattern), 0))
self.assertTrue(len(l) == 1)

_, expected_reg_written, expected_reg_read = asm.split()
Expand Down

0 comments on commit 824dc5e

Please sign in to comment.