mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-10-07 02:43:23 +00:00
add ci_test steps&&Fixed suite test for python3
This commit is contained in:
parent
8190cf1b82
commit
9057f42a89
5
.github/workflows/CITest.yml
vendored
5
.github/workflows/CITest.yml
vendored
@ -41,8 +41,3 @@ jobs:
|
|||||||
cd suite/cstest && ./build_cstest.sh;
|
cd suite/cstest && ./build_cstest.sh;
|
||||||
python cstest_report.py -D -t build/cstest -d ../MC;
|
python cstest_report.py -D -t build/cstest -d ../MC;
|
||||||
python cstest_report.py -D -t build/cstest -f issues.cs; cd ..;
|
python cstest_report.py -D -t build/cstest -f issues.cs; cd ..;
|
||||||
|
|
||||||
- name: fuzz
|
|
||||||
shell: 'script -q -e -c "bash {0}"'
|
|
||||||
run: |
|
|
||||||
python ./fuzz.py
|
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -111,6 +111,7 @@ xcode/Capstone.xcodeproj/xcuserdata
|
|||||||
xcode/Capstone.xcodeproj/project.xcworkspace/xcuserdata
|
xcode/Capstone.xcodeproj/project.xcworkspace/xcuserdata
|
||||||
|
|
||||||
# suite/
|
# suite/
|
||||||
|
corpus-libFuzzer-capstone_fuzz_disasmnext-latest.zip
|
||||||
test_arm_regression
|
test_arm_regression
|
||||||
test_arm_regression.o
|
test_arm_regression.o
|
||||||
fuzz_harness
|
fuzz_harness
|
||||||
@ -119,7 +120,8 @@ fuzz_bindisasm
|
|||||||
fuzz_disasm
|
fuzz_disasm
|
||||||
fuzz_decode_platform
|
fuzz_decode_platform
|
||||||
capstone_get_setup
|
capstone_get_setup
|
||||||
|
suite/fuzz/
|
||||||
|
suite/cstest/cmocka/
|
||||||
|
|
||||||
*.s
|
*.s
|
||||||
|
|
||||||
|
@ -4,17 +4,31 @@
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from capstone import *
|
from capstone import *
|
||||||
|
import sys
|
||||||
|
|
||||||
from xprint import to_hex
|
from xprint import to_hex
|
||||||
|
|
||||||
CODE = "\x60\x61\x50"
|
_python3 = sys.version_info.major == 3
|
||||||
cs = Cs(CS_ARCH_EVM, 0)
|
|
||||||
cs.detail = True
|
|
||||||
|
|
||||||
print("Platform: EVM")
|
|
||||||
print("Code: %s" %to_hex(CODE))
|
|
||||||
print("Disasm:")
|
|
||||||
|
|
||||||
for i in cs.disasm(CODE, 0x80001000):
|
EVM_CODE = b"\x60\x61\x50"
|
||||||
|
|
||||||
|
all_tests = (
|
||||||
|
(CS_ARCH_EVM, 0, EVM_CODE, "EVM"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_class():
|
||||||
|
address = 0x80001000
|
||||||
|
for (arch, mode, code, comment) in all_tests:
|
||||||
|
print("Platform: %s" % comment)
|
||||||
|
print("Code: %s " % to_hex(code))
|
||||||
|
print("Disasm:")
|
||||||
|
|
||||||
|
try:
|
||||||
|
md = Cs(arch, mode)
|
||||||
|
md.detail = True
|
||||||
|
for i in md.disasm(code, address):
|
||||||
print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
|
print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
|
||||||
if i.pop > 0:
|
if i.pop > 0:
|
||||||
print("\tPop: %u" %i.pop)
|
print("\tPop: %u" %i.pop)
|
||||||
@ -27,3 +41,10 @@ for i in cs.disasm(CODE, 0x80001000):
|
|||||||
for m in i.groups:
|
for m in i.groups:
|
||||||
print("%s " % i.group_name(m), end=''),
|
print("%s " % i.group_name(m), end=''),
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
except CsError as e:
|
||||||
|
print("ERROR: %s" % e.__str__())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
test_class()
|
||||||
|
0
suite/cstest/build_cstest.sh
Normal file → Executable file
0
suite/cstest/build_cstest.sh
Normal file → Executable file
@ -7,6 +7,8 @@ from subprocess import Popen, PIPE
|
|||||||
from pprint import pprint as ppr
|
from pprint import pprint as ppr
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
_python3 = sys.version_info.major == 3
|
||||||
|
|
||||||
|
|
||||||
def Usage(s):
|
def Usage(s):
|
||||||
print('Usage: {} -t <cstest_path> [-f <file_name.cs>] [-d <directory>]'.format(s))
|
print('Usage: {} -t <cstest_path> [-f <file_name.cs>] [-d <directory>]'.format(s))
|
||||||
@ -19,8 +21,11 @@ def get_report_file(toolpath, filepath, getDetails, cmt_out):
|
|||||||
|
|
||||||
# stdout
|
# stdout
|
||||||
failed_tests = []
|
failed_tests = []
|
||||||
# print('---> stdout\n', stdout)
|
if _python3:
|
||||||
# print('---> stderr\n', stderr)
|
stdout = bytes.decode(stdout)
|
||||||
|
stderr = bytes.decode(stderr)
|
||||||
|
# print('---> stdout\n', stdout)
|
||||||
|
# print('---> stderr\n', stderr)
|
||||||
matches = re.finditer(r'\[\s+RUN\s+\]\s+(.*)\n\[\s+FAILED\s+\]', stdout)
|
matches = re.finditer(r'\[\s+RUN\s+\]\s+(.*)\n\[\s+FAILED\s+\]', stdout)
|
||||||
for match in matches:
|
for match in matches:
|
||||||
failed_tests.append(match.group(1))
|
failed_tests.append(match.group(1))
|
||||||
@ -58,7 +63,7 @@ def get_report_file(toolpath, filepath, getDetails, cmt_out):
|
|||||||
rm_proc = Popen(tmp_cmd2, stdout=PIPE, stderr=PIPE)
|
rm_proc = Popen(tmp_cmd2, stdout=PIPE, stderr=PIPE)
|
||||||
rm_proc.communicate()
|
rm_proc.communicate()
|
||||||
|
|
||||||
return 0;
|
return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def get_report_folder(toolpath, folderpath, details, cmt_out):
|
def get_report_folder(toolpath, folderpath, details, cmt_out):
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
|
|
||||||
# syntax: test_all.sh <name>
|
# syntax: test_all.sh <name>
|
||||||
|
|
||||||
./test_archs.py > /tmp/$1_arch
|
# ./test_archs.py > /tmp/$1_arch
|
||||||
./test_c.sh $1_c
|
./test_c.sh $1_c
|
||||||
|
@ -3,16 +3,24 @@
|
|||||||
# Run all the Python tests, and send the output that to a file to be compared later
|
# Run all the Python tests, and send the output that to a file to be compared later
|
||||||
# This is useful when we want to verify if a commit (wrongly) changes the disassemble result.
|
# This is useful when we want to verify if a commit (wrongly) changes the disassemble result.
|
||||||
|
|
||||||
../tests/test > /tmp/$1
|
../tests/test_arm > /tmp/$1
|
||||||
../tests/test_detail >> /tmp/$1
|
../tests/test_arm64 > /tmp/$1
|
||||||
../tests/test_skipdata >> /tmp/$1
|
../tests/test_basic > /tmp/$1
|
||||||
../tests/test_iter >> /tmp/$1
|
../tests/test_bpf > /tmp/$1
|
||||||
../tests/test_arm >> /tmp/$1
|
../tests/test_customized_mnem > /tmp/$1
|
||||||
../tests/test_arm64 >> /tmp/$1
|
../tests/test_detail > /tmp/$1
|
||||||
../tests/test_mips >> /tmp/$1
|
../tests/test_evm > /tmp/$1
|
||||||
../tests/test_ppc >> /tmp/$1
|
../tests/test_iter > /tmp/$1
|
||||||
../tests/test_sparc >> /tmp/$1
|
../tests/test_m680x > /tmp/$1
|
||||||
../tests/test_x86 >> /tmp/$1
|
../tests/test_m68k > /tmp/$1
|
||||||
../tests/test_systemz >> /tmp/$1
|
../tests/test_mips > /tmp/$1
|
||||||
../tests/test_xcore >> /tmp/$1
|
../tests/test_mos65xx > /tmp/$1
|
||||||
../tests/test_riscv >> /tmp/$1
|
../tests/test_ppc > /tmp/$1
|
||||||
|
../tests/test_skipdata > /tmp/$1
|
||||||
|
../tests/test_sparc > /tmp/$1
|
||||||
|
../tests/test_systemz > /tmp/$1
|
||||||
|
../tests/test_tms320c64x > /tmp/$1
|
||||||
|
../tests/test_wasm > /tmp/$1
|
||||||
|
../tests/test_winkernel > /tmp/$1
|
||||||
|
../tests/test_x86 > /tmp/$1
|
||||||
|
../tests/test_xcore > /tmp/$1
|
Loading…
Reference in New Issue
Block a user