Merge commit '3621a6c08002c6b3e5b6f91bb0e20d8372613160' into dev

This commit is contained in:
Simone
2025-01-07 15:08:55 +00:00
1521 changed files with 323443 additions and 365407 deletions

View File

@@ -5,14 +5,14 @@
name = "cstest_py"
version = "0.1.0"
dependencies = [
"pyyaml >= 6.0.2",
"capstone >= 5.0.0",
"pyyaml >= 6.0.2",
"capstone >= 5.0.0",
]
requires-python = ">= 3.8"
[tool.setuptools]
packages = ["cstest_py"]
package-dir = {"" = "src"}
package-dir = { "" = "src" }
[project.scripts]
cstest_py = "cstest_py.cstest:main"

View File

@@ -11,8 +11,8 @@ configs = {
},
"CS_OPT_SKIPDATA": {"type": cs.CS_OPT_SKIPDATA, "val": cs.CS_OPT_ON},
"CS_OPT_UNSIGNED": {"type": cs.CS_OPT_UNSIGNED, "val": cs.CS_OPT_ON},
"CS_OPT_NO_BRANCH_OFFSET": {
"type": cs.CS_OPT_NO_BRANCH_OFFSET,
"CS_OPT_ONLY_OFFSET_BRANCH": {
"type": cs.CS_OPT_ONLY_OFFSET_BRANCH,
"val": cs.CS_OPT_ON,
},
"CS_OPT_SYNTAX_DEFAULT": {

View File

@@ -7,7 +7,6 @@ from __future__ import annotations
import argparse
import logging
import subprocess as sp
import sys
import os
import yaml
@@ -405,34 +404,16 @@ class CSTest:
self.stats.print_evaluate()
def get_repo_root() -> str | None:
res = sp.run(["git", "rev-parse", "--show-toplevel"], capture_output=True)
if res.stderr:
log.error("Could not get repository root directory.")
return None
return res.stdout.decode("utf8").strip()
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
prog="Python CSTest",
description="Pyton binding cstest implementation.",
description="Python binding cstest implementation.",
)
parser.add_argument(
dest="search_dir",
help="Directory to search for .yaml test files.",
type=Path,
)
repo_root = get_repo_root()
if repo_root:
parser.add_argument(
dest="search_dir",
help="Directory to search for .yaml test files.",
default=Path(f"{repo_root}/tests/"),
type=Path,
)
else:
parser.add_argument(
dest="search_dir",
help="Directory to search for .yaml test files.",
required=True,
type=Path,
)
parser.add_argument(
"-e",
dest="exclude",

View File

@@ -752,29 +752,34 @@ def test_expected_aarch64(actual: CsInsn, expected: dict) -> bool:
return False
elif aop.type == AARCH64_OP_SYSREG:
if not compare_enum(
aop.value.sysop.sub_type, eop.get("sub_type"), "sub_type"
aop.sysop.sub_type, eop.get("sub_type"), "sub_type"
):
return False
if not compare_uint64(
aop.value.sysop.reg.raw_val, eop.get("sys_raw_val"), "sys_raw_val"
if not compare_int32(
aop.sysop.reg.raw_val, eop.get("sys_raw_val"), "sys_raw_val"
):
return False
elif aop.type == AARCH64_OP_SYSIMM:
if not compare_enum(
aop.value.sysop.sub_type, eop.get("sub_type"), "sub_type"
aop.sysop.sub_type, eop.get("sub_type"), "sub_type"
):
return False
if not compare_uint64(
aop.value.sysop.imm.raw_val, eop.get("sys_raw_val"), "sys_raw_val"
if not compare_int32(
aop.sysop.imm.raw_val, eop.get("sys_raw_val"), "sys_raw_val"
):
return False
# EXACTFPIMM operands
if not compare_fp(
aop.fp, eop.get("fp"), "fp"
):
return False
elif aop.type == AARCH64_OP_SYSALIAS:
if not compare_enum(
aop.value.sysop.sub_type, eop.get("sub_type"), "sub_type"
aop.sysop.sub_type, eop.get("sub_type"), "sub_type"
):
return False
if not compare_uint64(
aop.value.sysop.alias.raw_val, eop.get("sys_raw_val"), "sys_raw_val"
if not compare_int32(
aop.sysop.alias.raw_val, eop.get("sys_raw_val"), "sys_raw_val"
):
return False
elif aop.type == AARCH64_OP_PRED:
@@ -1187,6 +1192,10 @@ def test_expected_bpf(actual: CsInsn, expected: dict) -> bool:
return False
if not compare_enum(aop.access, eop.get("access"), "access"):
return False
if not compare_tbool(aop.is_pkt, eop.get("is_pkt"), "is_pkt"):
return False
if not compare_tbool(aop.is_signed, eop.get("is_signed"), "is_signed"):
return False
if aop.type == BPF_OP_REG:
if not compare_reg(actual, aop.reg, eop.get("reg"), "reg"):