fix python binding

This commit is contained in:
kabeor 2023-03-07 13:17:45 +08:00
parent 1a6f12176a
commit eed417a810
3 changed files with 12 additions and 3 deletions

View File

@ -93,6 +93,7 @@ jobs:
run: |
./make.sh;
make check;
cp libcapstone.so.5 libcapstone.so.5.0
# sudo make install
- name: cmake
@ -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 ;

View File

@ -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 (

View File

@ -2,6 +2,9 @@ import unittest
from capstone import *
from capstone.arm64 import *
_python3 = sys.version_info.major == 3
class SubRegTest(unittest.TestCase):
PATTERNS = [
@ -18,7 +21,10 @@ class SubRegTest(unittest.TestCase):
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()