Squashed 'external/ircolib/' changes from ce3cd726c..de6e324bd
de6e324bdseparate emu thread10d3daf86Roms List improvements95d202f37Let's make the rom list process on a separate thread so the emulator doesnt take ages to load.fc306967fWow the ROM Header was just completely busted. Game list view works nowbad1691eefuck this shit2b59e5f46game list in progressd26417b83remappable inputs in progressac4af8106inpute72abc240update readme430139dc9Qt6 frontend3080d4d45Fix this small bug too08cd13b85Cop0 unused functions do not actually pose a threat (as per manual). They don't do anything, so shall we.61bb4fb44make idle loop detection a little more specific with where the load goesb037de4c3SAZDFsdff12e81e73eneed to figure out why n64-systemtest loops indefinitely at some address that appears to be valid (i think it's me not invalidating the cache properly)204f0e13bidle skipping seems to work!cb8bb634asdkfjlasdf58e5c89c1Fix compilation issue on my machine (no idea)24fb2898eattempting more serious idle skipping214719577Place rsp.Step inside cached interpreter. Gains about 3 more fpsbb97dcc23mmmmm920b77d38wjkhasdfjhkasdf430ccdab4it's a start...4f42a673aCached interpreter plays Mario 64. Start looking into RSP as wellc9a030787idle skipping works!5fbda03cenew idea366637abaIdle skipping... maybe?609fa2fb0Cache instructions implemented but broken lmao. Commented out for nowe140a6d12- Stop using inheritance for CPU, instead use composition. - Introduce KAIZEN_JIT_ENABLED optional define instead of relying on __aarch64__ and the like. - More cache work68e613057prep cache impl811b4d809fix clang formatfda755f7didkd5024ebbfsmall MI refactor in preparation of (eventually) implementing the RDRAM interface properly694b45341Merge commit '206dcdedf195fb320913584180edb12c7731e396' as 'external/SDL'206dcdedfSquashed 'external/SDL/' content from commit 4d17b99d0a4d16e1cb4need to update sdl848b19920Fix compilation errordb61b5299Merge commit 'e94a94559f28e49678fbcf72199a5258137b0fe9' as 'external/imgui'e94a94559Squashed 'external/imgui/' content from commit 02e9b8cac52edb3757need to update imguic1a705e86Emulate weird JALR behaviour4b4c32f4bFix exception for "unusable COP1" in 4 instructions i missed accidentally (again)df5828142Bug putting 0s in the log everywheref8b580048Make isviewer a sink to file8241e9735Fix exception for "unusable COP1" in 4 instructions i missed accidentallyb29715f20small changesd9a620bc1make use of my new small utility library0d1aa938eAdd 'external/ircolib/' from commit 'ce3cd726c8df8388d554abf8bb55d55020eb4450'e64eb40b3Fuck git git-subtree-dir: external/ircolib git-subtree-split:de6e324bde
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
/* Capstone testing regression */
|
||||
/* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
|
||||
|
||||
#ifndef HELPER_H
|
||||
#define HELPER_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define MAX_ASM_TXT_MEM 1024
|
||||
#define X86_16 0
|
||||
#define X86_32 1
|
||||
#define X86_64 2
|
||||
|
||||
void trim_str(char *str);
|
||||
void add_str(char **src, const char *format, ...);
|
||||
void replace_hex(char *src, size_t src_len);
|
||||
void replace_negative(char *src, size_t src_len, size_t arch_bits);
|
||||
void norm_spaces(char *str);
|
||||
void str_to_lower(char *str);
|
||||
|
||||
#endif /* HELPER_H */
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TESTCASE_H
|
||||
#define TESTCASE_H
|
||||
|
||||
#include "test_detail.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/// Input data for a test case.
|
||||
typedef struct {
|
||||
char *name;
|
||||
uint8_t *bytes; // mandatory
|
||||
uint32_t bytes_count; // Filled by cyaml
|
||||
char *arch; // mandatory
|
||||
uint64_t address;
|
||||
char **options; // mandatory
|
||||
uint32_t options_count; // Filled by cyaml
|
||||
} TestInput;
|
||||
|
||||
TestInput *test_input_new();
|
||||
void test_input_free(TestInput *test_input);
|
||||
TestInput *test_input_clone(TestInput *test_input);
|
||||
char *test_input_stringify(const TestInput *test_input, const char *postfix);
|
||||
cs_arch test_input_get_cs_arch(const TestInput *test_input);
|
||||
cs_mode test_input_get_cs_mode(const TestInput *test_input);
|
||||
void test_input_get_cs_option(const TestInput *test_input, cs_opt_type *otype,
|
||||
cs_opt_value *oval);
|
||||
|
||||
/// A single byte
|
||||
static const cyaml_schema_value_t byte_schema = {
|
||||
CYAML_VALUE_UINT(CYAML_FLAG_DEFAULT, uint8_t),
|
||||
};
|
||||
|
||||
/// A single option string
|
||||
static const cyaml_schema_value_t option_schema = {
|
||||
CYAML_VALUE_STRING(CYAML_FLAG_POINTER, char, 0, CYAML_UNLIMITED),
|
||||
};
|
||||
|
||||
static const cyaml_schema_field_t test_input_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("name", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestInput, name,
|
||||
0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_SEQUENCE("bytes", CYAML_FLAG_POINTER, TestInput, bytes,
|
||||
&byte_schema, 0, CYAML_UNLIMITED), // 0-MAX bytes
|
||||
CYAML_FIELD_STRING_PTR("arch", CYAML_FLAG_POINTER, TestInput, arch, 0,
|
||||
CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("address",
|
||||
CYAML_FLAG_SCALAR_PLAIN | CYAML_FLAG_OPTIONAL,
|
||||
TestInput, address),
|
||||
CYAML_FIELD_SEQUENCE("options", CYAML_FLAG_POINTER, TestInput, options,
|
||||
&option_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
/// Data compared to the produced cs_insn.
|
||||
typedef struct {
|
||||
char *id;
|
||||
char *asm_text; // mandatory
|
||||
char *op_str;
|
||||
int32_t is_alias; ///< 0 == not given, >0 == true, <0 == false
|
||||
int32_t illegal; ///< 0 == not given, >0 == true, <0 == false
|
||||
char *alias_id;
|
||||
char *mnemonic;
|
||||
TestDetail *details;
|
||||
} TestInsnData;
|
||||
|
||||
TestInsnData *test_insn_data_new();
|
||||
void test_insn_data_free(TestInsnData *test_insn_data);
|
||||
TestInsnData *test_insn_data_clone(TestInsnData *test_insn_data);
|
||||
|
||||
static const cyaml_schema_field_t test_insn_data_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("id", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestInsnData, id, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("asm_text", CYAML_FLAG_POINTER, TestInsnData,
|
||||
asm_text, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"op_str", CYAML_FLAG_POINTER_NULL_STR | CYAML_FLAG_OPTIONAL,
|
||||
TestInsnData, op_str, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("is_alias", CYAML_FLAG_OPTIONAL, TestInsnData,
|
||||
is_alias),
|
||||
CYAML_FIELD_INT("illegal", CYAML_FLAG_OPTIONAL, TestInsnData,
|
||||
illegal),
|
||||
CYAML_FIELD_STRING_PTR("alias_id",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestInsnData, alias_id, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mnemonic", CYAML_FLAG_POINTER_NULL_STR | CYAML_FLAG_OPTIONAL,
|
||||
TestInsnData, mnemonic, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"details", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestInsnData, details, test_detail_mapping_schema),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
/// The expected data for a test. This can hold multiple instructions
|
||||
/// if enough bytes were given.
|
||||
typedef struct {
|
||||
TestInsnData **insns; ///< Zero to N disassembled instructions.
|
||||
uint32_t insns_count; ///< Filled by cyaml.
|
||||
} TestExpected;
|
||||
|
||||
TestExpected *test_expected_new();
|
||||
void test_expected_free(TestExpected *test_expected);
|
||||
TestExpected *test_expected_clone(TestExpected *test_expected);
|
||||
void test_expected_compare(csh *handle, TestExpected *expected, cs_insn *insns,
|
||||
size_t insns_count, size_t arch_bits);
|
||||
|
||||
static const cyaml_schema_value_t insn_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestInsnData,
|
||||
test_insn_data_mapping_schema),
|
||||
};
|
||||
|
||||
static const cyaml_schema_field_t test_expected_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE("insns", CYAML_FLAG_POINTER, TestExpected, insns,
|
||||
&insn_schema, 0, CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
/// A single test case.
|
||||
typedef struct {
|
||||
TestInput *input; ///< Input data for a test case
|
||||
TestExpected *expected; ///< Expected data of the test case.
|
||||
bool skip; ///< If set, the test is skipped
|
||||
char *skip_reason; ///< Reason this test is skipped.
|
||||
} TestCase;
|
||||
|
||||
TestCase *test_case_new();
|
||||
void test_case_free(TestCase *test_case);
|
||||
TestCase *test_case_clone(TestCase *test_case);
|
||||
|
||||
static const cyaml_schema_field_t test_case_mapping_schema[] = {
|
||||
CYAML_FIELD_MAPPING_PTR("input", CYAML_FLAG_POINTER, TestCase, input,
|
||||
test_input_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR("expected", CYAML_FLAG_POINTER, TestCase,
|
||||
expected, test_expected_mapping_schema),
|
||||
CYAML_FIELD_BOOL("skip", CYAML_FLAG_OPTIONAL, TestCase, skip),
|
||||
CYAML_FIELD_STRING_PTR("skip_reason",
|
||||
CYAML_FLAG_POINTER_NULL_STR |
|
||||
CYAML_FLAG_OPTIONAL,
|
||||
TestCase, skip_reason, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_case_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestCase,
|
||||
test_case_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *filename; ///< Filename. NOT filled by cyaml.
|
||||
TestCase **test_cases;
|
||||
uint32_t test_cases_count;
|
||||
} TestFile;
|
||||
|
||||
TestFile *test_file_new();
|
||||
void test_file_free(TestFile *test_file);
|
||||
TestFile *test_file_clone(TestFile *test_file);
|
||||
|
||||
static const cyaml_schema_field_t test_file_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"filename", CYAML_FLAG_OPTIONAL | CYAML_FLAG_POINTER_NULL_STR,
|
||||
TestFile, filename, 0, 0),
|
||||
CYAML_FIELD_SEQUENCE("test_cases", CYAML_FLAG_POINTER, TestFile,
|
||||
test_cases, &test_case_schema, 1,
|
||||
CYAML_UNLIMITED), // 1-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_file_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestFile,
|
||||
test_file_mapping_schema),
|
||||
};
|
||||
|
||||
#endif // TESTCASE_H
|
||||
@@ -0,0 +1,233 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_COMPARE_H
|
||||
#define TEST_COMPARE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "test_mapping.h"
|
||||
#include "../../../utils.h"
|
||||
|
||||
/// An integer encoding a boolean value from the test files.
|
||||
/// libcyaml saves 0 by default, if an optional value was not set.
|
||||
/// Due to that, boolean values are represented as integer with the
|
||||
/// interpretation:
|
||||
///
|
||||
/// = 0 => unset
|
||||
/// < 0 => false
|
||||
/// > 0 => true
|
||||
typedef int32_t tbool;
|
||||
|
||||
#define CYAML_FIELD_TBOOL(name, flags, type, member) \
|
||||
CYAML_FIELD_INT(name, flags, type, member)
|
||||
|
||||
/// Compares the @actual bool against the @expected tbool:
|
||||
/// It returns with @ret_val, if expected is set but the values mismatch.
|
||||
#define compare_tbool_ret(actual, expected, ret_val) \
|
||||
if (expected != 0 && \
|
||||
((actual && expected <= 0) || (!actual && expected >= 0))) { \
|
||||
fprintf(stderr, \
|
||||
#actual " is %s but expected is %" PRId32 \
|
||||
" (=0 unset, >0 true, <0 false)\n", \
|
||||
actual ? "true" : "false", expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two unsigned int values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_uint_ret(actual, expected, ret_val) \
|
||||
if (((unsigned int)actual) != ((unsigned int)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx32 \
|
||||
" != 0x%" PRIx32 "\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two uint8_t values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_uint8_ret(actual, expected, ret_val) \
|
||||
if (((uint8_t)actual) != ((uint8_t)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": %" PRId8 " != %" PRId8 \
|
||||
"\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two uint16_t values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_uint16_ret(actual, expected, ret_val) \
|
||||
if (((uint16_t)actual) != ((uint16_t)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx16 \
|
||||
" != 0x%" PRIx16 "\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two uint32_t values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_uint32_ret(actual, expected, ret_val) \
|
||||
if (((uint32_t)actual) != ((uint32_t)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx32 \
|
||||
" != 0x%" PRIx32 "\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two uint64_t values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_uint64_ret(actual, expected, ret_val) \
|
||||
if (((uint64_t)actual) != ((uint64_t)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx64 \
|
||||
" != 0x%" PRIx64 "\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two int values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_int_ret(actual, expected, ret_val) \
|
||||
if (((int)actual) != ((int)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx32 \
|
||||
" != 0x%" PRIx32 "\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two int8_t values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_int8_ret(actual, expected, ret_val) \
|
||||
if (((int8_t)actual) != ((int8_t)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx8 " != 0x%" PRIx8 \
|
||||
"\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two int16_t values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_int16_ret(actual, expected, ret_val) \
|
||||
if (((int16_t)actual) != ((int16_t)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx16 \
|
||||
" != 0x%" PRIx16 "\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two int32_t values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_int32_ret(actual, expected, ret_val) \
|
||||
if (((int32_t)actual) != ((int32_t)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx32 \
|
||||
" != 0x%" PRIx32 "\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two int64_t values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_int64_ret(actual, expected, ret_val) \
|
||||
if (((int64_t)actual) != ((int64_t)expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": 0x%" PRIx64 \
|
||||
" != 0x%" PRIx64 "\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares two floating point values.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_fp_ret(actual, expected, ret_val) \
|
||||
if (actual != expected) { \
|
||||
fprintf(stderr, #actual " != " #expected ": %f != %f\n", \
|
||||
actual, expected); \
|
||||
return ret_val; \
|
||||
}
|
||||
|
||||
/// Compares enum id.
|
||||
/// Actual is the value, expected is the enum idetifer as string.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_enum_ret(actual, expected, ret_val) \
|
||||
if (expected) { \
|
||||
bool found = false; \
|
||||
uint32_t eval = enum_map_bin_search( \
|
||||
cs_enum_map, ARR_SIZE(cs_enum_map), expected, &found); \
|
||||
if (expected && (actual != eval || !found)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": %" PRId32 \
|
||||
" != %s%s\n", \
|
||||
actual, expected, \
|
||||
found ? "" : " <== id not found. Consider adding it in test_mapping.h::cs_enum_map."); \
|
||||
return ret_val; \
|
||||
} \
|
||||
}
|
||||
|
||||
/// Checks if all bit flags in @expected are set in @actual.
|
||||
/// Actual is the value with all bits set.
|
||||
/// @expected is a list the @len enum identifiers as string.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_bit_flags_ret(actual, expected, len, ret_val) \
|
||||
if (expected) { \
|
||||
for (size_t cmp_i = 0; cmp_i < len; ++cmp_i) { \
|
||||
bool found = false; \
|
||||
uint32_t eval = enum_map_bin_search( \
|
||||
cs_enum_map, ARR_SIZE(cs_enum_map), \
|
||||
expected[cmp_i], &found); \
|
||||
if (!(actual & eval) || !found) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": %" PRId32 \
|
||||
" != %s%s\n", \
|
||||
actual, expected[cmp_i], \
|
||||
found ? " <== Flag not set" : \
|
||||
" <== id not found"); \
|
||||
return ret_val; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/// Checks if all bit flags in @expected are set in @actual.
|
||||
/// Actual is the value with all bits set.
|
||||
/// @expected is a list the @len enum identifiers as string.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_bit_flags_64_ret(actual, expected, len, ret_val) \
|
||||
if (expected) { \
|
||||
for (size_t cmp_i = 0; cmp_i < len; ++cmp_i) { \
|
||||
bool found = false; \
|
||||
uint64_t eval = enum_map_bin_search( \
|
||||
cs_enum_map, ARR_SIZE(cs_enum_map), \
|
||||
expected[cmp_i], &found); \
|
||||
if (!(actual & eval) || !found) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": %" PRId64 \
|
||||
" != %s%s\n", \
|
||||
actual, expected[cmp_i], \
|
||||
found ? " <== Flag not set" : \
|
||||
" <== id not found"); \
|
||||
return ret_val; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/// Compares register names.
|
||||
/// Actual is the register id, expected is name as string.
|
||||
/// It returns with @ret_val if they mismatch.
|
||||
#define compare_reg_ret(handle, actual, expected, ret_val) \
|
||||
if (expected) { \
|
||||
const char *reg_name = cs_reg_name(handle, actual); \
|
||||
if (expected && !strings_match(reg_name, expected)) { \
|
||||
fprintf(stderr, \
|
||||
#actual " != " #expected ": '%s' != '%s'\n", \
|
||||
reg_name, expected); \
|
||||
return ret_val; \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // TEST_COMPARE_H
|
||||
@@ -0,0 +1,184 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
/// @file Defines all detail structures to test against and their yaml schemas.
|
||||
/// The structs currently need to be partially redefined, if they contain unions.
|
||||
/// And they won't be supported until libcyaml v2:
|
||||
/// https://github.com/tlsa/libcyaml/issues/186
|
||||
|
||||
#ifndef TEST_DETAIL_H
|
||||
#define TEST_DETAIL_H
|
||||
|
||||
#include "test_detail_aarch64.h"
|
||||
#include "test_detail_arm.h"
|
||||
#include "test_detail_evm.h"
|
||||
#include "test_detail_loongarch.h"
|
||||
#include "test_detail_mos65xx.h"
|
||||
#include "test_detail_ppc.h"
|
||||
#include "test_detail_riscv.h"
|
||||
#include "test_detail_tricore.h"
|
||||
#include "test_detail_systemz.h"
|
||||
#include "test_detail_sh.h"
|
||||
#include "test_detail_sparc.h"
|
||||
#include "test_detail_alpha.h"
|
||||
#include "test_detail_bpf.h"
|
||||
#include "test_detail_hppa.h"
|
||||
#include "test_detail_xcore.h"
|
||||
#include "test_detail_mips.h"
|
||||
#include "test_detail_riscv.h"
|
||||
#include "test_detail_m680x.h"
|
||||
#include "test_detail_tms320c64x.h"
|
||||
#include "test_detail_wasm.h"
|
||||
#include "test_detail_x86.h"
|
||||
#include "test_detail_m68k.h"
|
||||
#include "test_detail_xtensa.h"
|
||||
#include "test_detail_arc.h"
|
||||
#include "test_compare.h"
|
||||
#include <capstone/capstone.h>
|
||||
#include <cyaml/cyaml.h>
|
||||
|
||||
/// The equivalent to cs_detail in capstone.h
|
||||
/// but with pointers and no unions. Because cyaml does not support them.
|
||||
typedef struct {
|
||||
TestDetailAArch64 *aarch64;
|
||||
TestDetailARM *arm;
|
||||
TestDetailPPC *ppc;
|
||||
TestDetailTriCore *tricore;
|
||||
TestDetailAlpha *alpha;
|
||||
TestDetailHPPA *hppa;
|
||||
TestDetailBPF *bpf;
|
||||
TestDetailSystemZ *systemz;
|
||||
TestDetailSparc *sparc;
|
||||
TestDetailXCore *xcore;
|
||||
TestDetailSH *sh;
|
||||
TestDetailMips *mips;
|
||||
TestDetailRISCV *riscv;
|
||||
TestDetailM680x *m680x;
|
||||
TestDetailTMS320c64x *tms320c64x;
|
||||
TestDetailMos65xx *mos65xx;
|
||||
TestDetailEVM *evm;
|
||||
TestDetailLoongArch *loongarch;
|
||||
TestDetailWASM *wasm;
|
||||
TestDetailX86 *x86;
|
||||
TestDetailM68K *m68k;
|
||||
TestDetailXtensa *xtensa;
|
||||
TestDetailARC *arc;
|
||||
|
||||
char **regs_read;
|
||||
uint8_t regs_read_count;
|
||||
|
||||
char **regs_write;
|
||||
uint8_t regs_write_count;
|
||||
|
||||
// Implicit read/writes only
|
||||
char **regs_impl_read;
|
||||
uint8_t regs_impl_read_count;
|
||||
char **regs_impl_write;
|
||||
uint8_t regs_impl_write_count;
|
||||
|
||||
char **groups;
|
||||
uint8_t groups_count;
|
||||
|
||||
tbool writeback;
|
||||
} TestDetail;
|
||||
|
||||
static const cyaml_schema_value_t single_string_schema = {
|
||||
CYAML_VALUE_STRING(CYAML_FLAG_POINTER, char, 0, CYAML_UNLIMITED),
|
||||
};
|
||||
|
||||
static const cyaml_schema_field_t test_detail_mapping_schema[] = {
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"aarch64", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
aarch64, test_detail_aarch64_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR("arm", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, arm,
|
||||
test_detail_arm_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR("ppc", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, ppc,
|
||||
test_detail_ppc_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"tricore", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
tricore, test_detail_tricore_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"alpha", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
alpha, test_detail_alpha_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"hppa", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
hppa, test_detail_hppa_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR("bpf", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, bpf,
|
||||
test_detail_bpf_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"systemz", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
systemz, test_detail_systemz_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"sparc", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
sparc, test_detail_sparc_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"xcore", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
xcore, test_detail_xcore_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR("sh", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, sh, test_detail_sh_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"mips", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
mips, test_detail_mips_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"riscv", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
riscv, test_detail_riscv_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"m680x", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
m680x, test_detail_m680x_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"tms320c64x", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, tms320c64x, test_detail_tms320c64x_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"mos65xx", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
mos65xx, test_detail_mos65xx_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR("evm", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, evm,
|
||||
test_detail_evm_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"loongarch", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, loongarch, test_detail_loongarch_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"wasm", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
wasm, test_detail_wasm_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR("x86", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, x86,
|
||||
test_detail_x86_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"m68k", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
m68k, test_detail_m68k_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"xtensa", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
xtensa, test_detail_xtensa_mapping_schema),
|
||||
CYAML_FIELD_MAPPING_PTR(
|
||||
"arc", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
arc, test_detail_arc_mapping_schema),
|
||||
CYAML_FIELD_SEQUENCE("regs_read",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, regs_read, &single_string_schema, 0, 255),
|
||||
CYAML_FIELD_SEQUENCE("regs_write",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, regs_write, &single_string_schema, 0, 255),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"regs_impl_read", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, regs_impl_read, &single_string_schema, 0, 255),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"regs_impl_write", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, regs_impl_write, &single_string_schema, 0, 255),
|
||||
CYAML_FIELD_SEQUENCE("groups", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetail, groups, &single_string_schema, 0, 255),
|
||||
CYAML_FIELD_INT("writeback", CYAML_FLAG_OPTIONAL, TestDetail,
|
||||
writeback),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetail *test_detail_new();
|
||||
TestDetail *test_detail_clone(TestDetail *detail);
|
||||
void test_detail_free(TestDetail *detail);
|
||||
|
||||
bool test_expected_detail(csh *handle, const cs_insn *insn,
|
||||
TestDetail *expected);
|
||||
|
||||
#endif // TEST_DETAIL_H
|
||||
@@ -0,0 +1,184 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_AARCH64_H
|
||||
#define TEST_DETAIL_AARCH64_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *tile;
|
||||
char *slice_reg;
|
||||
int8_t slice_offset_imm;
|
||||
int8_t slice_offset_ir_first;
|
||||
int8_t slice_offset_ir_offset;
|
||||
bool slice_offset_ir_set;
|
||||
tbool has_range_offset;
|
||||
tbool is_vertical;
|
||||
} TestDetailAArch64SME;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_aarch64_sme_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("tile", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, tile, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"slice_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, slice_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("slice_offset_imm", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, slice_offset_imm),
|
||||
CYAML_FIELD_INT("slice_offset_ir_first", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, slice_offset_ir_first),
|
||||
CYAML_FIELD_INT("slice_offset_ir_offset", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, slice_offset_ir_offset),
|
||||
CYAML_FIELD_BOOL("slice_offset_ir_set", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, slice_offset_ir_set),
|
||||
CYAML_FIELD_INT("has_range_offset", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, has_range_offset),
|
||||
CYAML_FIELD_INT("is_vertical", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64SME, is_vertical),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *sub_type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
char *mem_base;
|
||||
char *mem_index;
|
||||
int32_t mem_disp;
|
||||
|
||||
int8_t imm_range_first;
|
||||
int8_t imm_range_offset;
|
||||
double fp;
|
||||
bool fp_set; /// Only relevant for SysOps with EXACTFPIMM
|
||||
int sys_raw_val;
|
||||
|
||||
TestDetailAArch64SME *sme;
|
||||
|
||||
char *pred_reg;
|
||||
char *pred_vec_select;
|
||||
int32_t pred_imm_index;
|
||||
bool pred_imm_index_set;
|
||||
|
||||
char *shift_type;
|
||||
uint32_t shift_value;
|
||||
char *ext;
|
||||
|
||||
char *vas;
|
||||
tbool is_vreg;
|
||||
int vector_index;
|
||||
bool vector_index_is_set;
|
||||
|
||||
tbool is_list_member;
|
||||
} TestDetailAArch64Op;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_aarch64_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"sub_type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, sub_type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailAArch64Op, imm),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_base", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_index", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, mem_index, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailAArch64Op,
|
||||
mem_disp),
|
||||
CYAML_FIELD_INT("imm_range_first", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, imm_range_first),
|
||||
CYAML_FIELD_INT("imm_range_offset", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, imm_range_offset),
|
||||
CYAML_FIELD_FLOAT("fp", CYAML_FLAG_OPTIONAL, TestDetailAArch64Op, fp),
|
||||
CYAML_FIELD_BOOL("fp_set", CYAML_FLAG_OPTIONAL, TestDetailAArch64Op, fp_set),
|
||||
CYAML_FIELD_UINT("sys_raw_val", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, sys_raw_val),
|
||||
CYAML_FIELD_MAPPING_PTR("sme", CYAML_FLAG_OPTIONAL, TestDetailAArch64Op,
|
||||
sme, test_detail_aarch64_sme_mapping_schema),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"pred_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, pred_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"pred_vec_select", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, pred_vec_select, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("pred_imm_index", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, pred_imm_index),
|
||||
CYAML_FIELD_BOOL("pred_imm_index_set", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, pred_imm_index_set),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"shift_type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, shift_type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("shift_value", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, shift_value),
|
||||
CYAML_FIELD_STRING_PTR("ext", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, ext, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("vas", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, vas, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("is_vreg", CYAML_FLAG_OPTIONAL, TestDetailAArch64Op,
|
||||
is_vreg),
|
||||
CYAML_FIELD_INT("vector_index", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, vector_index),
|
||||
CYAML_FIELD_BOOL("vector_index_is_set", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, vector_index_is_set),
|
||||
CYAML_FIELD_INT("is_list_member", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64Op, is_list_member),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_aarch64_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailAArch64Op,
|
||||
test_detail_aarch64_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *cc;
|
||||
tbool update_flags;
|
||||
tbool post_indexed;
|
||||
TestDetailAArch64Op **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailAArch64;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_aarch64_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("cc", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64, cc, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("update_flags", CYAML_FLAG_OPTIONAL, TestDetailAArch64,
|
||||
update_flags),
|
||||
CYAML_FIELD_INT("post_indexed", CYAML_FLAG_OPTIONAL, TestDetailAArch64,
|
||||
post_indexed),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAArch64, operands, &test_detail_aarch64_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailAArch64 *test_detail_aarch64_new();
|
||||
TestDetailAArch64 *test_detail_aarch64_clone(TestDetailAArch64 *detail);
|
||||
void test_detail_aarch64_free(TestDetailAArch64 *detail);
|
||||
|
||||
TestDetailAArch64Op *test_detail_aarch64_op_new();
|
||||
TestDetailAArch64Op *test_detail_aarch64_op_clone(TestDetailAArch64Op *detail);
|
||||
void test_detail_aarch64_op_free(TestDetailAArch64Op *detail);
|
||||
|
||||
TestDetailAArch64SME *test_detail_aarch64_op_sme_new();
|
||||
TestDetailAArch64SME *test_detail_aarch64_op_sme_clone(TestDetailAArch64SME *sme);
|
||||
void test_detail_aarch64_op_sme_free(TestDetailAArch64SME *sme);
|
||||
|
||||
bool test_expected_aarch64(csh *handle, cs_aarch64 *actual,
|
||||
TestDetailAArch64 *expected);
|
||||
|
||||
#endif // TEST_DETAIL_AARCH64_H
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_ALPHA_H
|
||||
#define TEST_DETAIL_ALPHA_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int32_t imm;
|
||||
} TestDetailAlphaOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_alpha_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAlphaOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAlphaOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAlphaOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailAlphaOp, imm),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_alpha_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailAlphaOp,
|
||||
test_detail_alpha_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailAlphaOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailAlpha;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_alpha_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailAlpha, operands, &test_detail_alpha_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailAlpha *test_detail_alpha_new();
|
||||
TestDetailAlpha *test_detail_alpha_clone(const TestDetailAlpha *detail);
|
||||
void test_detail_alpha_free(TestDetailAlpha *detail);
|
||||
|
||||
TestDetailAlphaOp *test_detail_alpha_op_new();
|
||||
TestDetailAlphaOp *test_detail_alpha_op_clone(const TestDetailAlphaOp *detail);
|
||||
void test_detail_alpha_op_free(TestDetailAlphaOp *detail);
|
||||
|
||||
bool test_expected_alpha(csh *handle, const cs_alpha *actual,
|
||||
const TestDetailAlpha *expected);
|
||||
|
||||
#endif // TEST_DETAIL_ALPHA_H
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright © 2024 Sibirtsev Dmitry <sibirtsevdl@gmail.com>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_ARC_H
|
||||
#define TEST_DETAIL_ARC_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
} TestDetailARCOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_arc_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARCOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARCOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARCOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailARCOp, imm),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_arc_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailARCOp,
|
||||
test_detail_arc_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailARCOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailARC;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_arc_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARC, operands, &test_detail_arc_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailARC *test_detail_arc_new();
|
||||
TestDetailARC *test_detail_arc_clone(const TestDetailARC *detail);
|
||||
void test_detail_arc_free(TestDetailARC *detail);
|
||||
|
||||
TestDetailARCOp *test_detail_arc_op_new();
|
||||
TestDetailARCOp *test_detail_arc_op_clone(const TestDetailARCOp *detail);
|
||||
void test_detail_arc_op_free(TestDetailARCOp *detail);
|
||||
|
||||
bool test_expected_arc(csh *handle, const cs_arc *actual,
|
||||
const TestDetailARC *expected);
|
||||
|
||||
#endif // TEST_DETAIL_ARC_H
|
||||
@@ -0,0 +1,165 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_ARM_H
|
||||
#define TEST_DETAIL_ARM_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
char *setend;
|
||||
int pred;
|
||||
double fp;
|
||||
char *mem_base;
|
||||
char *mem_index;
|
||||
int32_t mem_scale;
|
||||
int32_t mem_disp;
|
||||
uint32_t mem_align;
|
||||
char *sys_reg;
|
||||
char **sys_psr_bits;
|
||||
uint32_t sys_psr_bits_count;
|
||||
int sys_sysm;
|
||||
int sys_msr_mask;
|
||||
|
||||
char *shift_type;
|
||||
uint32_t shift_value;
|
||||
|
||||
int8_t neon_lane;
|
||||
int vector_index;
|
||||
bool vector_index_is_set;
|
||||
|
||||
tbool subtracted;
|
||||
} TestDetailARMOp;
|
||||
|
||||
static const cyaml_schema_value_t test_detail_arm_op_sys_psr_schema = {
|
||||
CYAML_VALUE_STRING(CYAML_FLAG_POINTER, char, 0, CYAML_UNLIMITED),
|
||||
};
|
||||
|
||||
static const cyaml_schema_field_t test_detail_arm_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailARMOp, imm),
|
||||
CYAML_FIELD_STRING_PTR("setend",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, setend, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("pred", CYAML_FLAG_OPTIONAL, TestDetailARMOp, pred),
|
||||
CYAML_FIELD_FLOAT("fp", CYAML_FLAG_OPTIONAL, TestDetailARMOp, fp),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("mem_index",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, mem_index, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_INT("mem_scale", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
mem_scale),
|
||||
CYAML_FIELD_UINT("mem_align", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
mem_align),
|
||||
CYAML_FIELD_STRING_PTR("sys_reg",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, sys_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"sys_psr_bits", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, sys_psr_bits,
|
||||
&test_detail_arm_op_sys_psr_schema, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("sys_sysm", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
sys_sysm),
|
||||
CYAML_FIELD_INT("sys_msr_mask", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
sys_msr_mask),
|
||||
CYAML_FIELD_STRING_PTR("shift_type",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, shift_type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("shift_value", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
shift_value),
|
||||
CYAML_FIELD_INT("neon_lane", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
neon_lane),
|
||||
CYAML_FIELD_INT("vector_index", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
vector_index),
|
||||
CYAML_FIELD_BOOL("vector_index_is_set", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARMOp, vector_index_is_set),
|
||||
CYAML_FIELD_INT("subtracted", CYAML_FLAG_OPTIONAL, TestDetailARMOp,
|
||||
subtracted),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_arm_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailARMOp,
|
||||
test_detail_arm_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int vector_size;
|
||||
char *vector_data;
|
||||
char *cps_mode;
|
||||
char *cps_flag;
|
||||
char *cc;
|
||||
char *vcc;
|
||||
char *mem_barrier;
|
||||
uint8_t pred_mask;
|
||||
|
||||
tbool usermode;
|
||||
tbool update_flags;
|
||||
tbool post_indexed;
|
||||
|
||||
TestDetailARMOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailARM;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_arm_mapping_schema[] = {
|
||||
CYAML_FIELD_INT("vector_size", CYAML_FLAG_OPTIONAL, TestDetailARM,
|
||||
vector_size),
|
||||
CYAML_FIELD_STRING_PTR("vector_data",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARM, vector_data, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("cps_mode",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARM, cps_mode, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("cps_flag",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARM, cps_flag, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("cc", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARM, cc, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("vcc", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARM, vcc, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("mem_barrier",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARM, mem_barrier, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("pred_mask", CYAML_FLAG_OPTIONAL, TestDetailARM,
|
||||
pred_mask),
|
||||
CYAML_FIELD_INT("usermode", CYAML_FLAG_OPTIONAL, TestDetailARM,
|
||||
usermode),
|
||||
CYAML_FIELD_INT("update_flags", CYAML_FLAG_OPTIONAL, TestDetailARM,
|
||||
update_flags),
|
||||
CYAML_FIELD_INT("post_indexed", CYAML_FLAG_OPTIONAL, TestDetailARM,
|
||||
post_indexed),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailARM, operands, &test_detail_arm_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailARM *test_detail_arm_new();
|
||||
TestDetailARM *test_detail_arm_clone(TestDetailARM *detail);
|
||||
void test_detail_arm_free(TestDetailARM *detail);
|
||||
|
||||
TestDetailARMOp *test_detail_arm_op_new();
|
||||
TestDetailARMOp *test_detail_arm_op_clone(TestDetailARMOp *detail);
|
||||
void test_detail_arm_op_free(TestDetailARMOp *detail);
|
||||
|
||||
bool test_expected_arm(csh *handle, cs_arm *actual, TestDetailARM *expected);
|
||||
|
||||
#endif // TEST_DETAIL_ARM_H
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_BPF_H
|
||||
#define TEST_DETAIL_BPF_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
uint64_t imm;
|
||||
uint32_t off;
|
||||
uint32_t mmem;
|
||||
uint32_t msh;
|
||||
char *ext;
|
||||
char *mem_base;
|
||||
uint32_t mem_disp;
|
||||
tbool is_pkt;
|
||||
tbool is_signed;
|
||||
} TestDetailBPFOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_bpf_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailBPFOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailBPFOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailBPFOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("imm", CYAML_FLAG_OPTIONAL, TestDetailBPFOp, imm),
|
||||
CYAML_FIELD_UINT("off", CYAML_FLAG_OPTIONAL, TestDetailBPFOp, off),
|
||||
CYAML_FIELD_UINT("mmem", CYAML_FLAG_OPTIONAL, TestDetailBPFOp, mmem),
|
||||
CYAML_FIELD_UINT("msh", CYAML_FLAG_OPTIONAL, TestDetailBPFOp, msh),
|
||||
CYAML_FIELD_STRING_PTR("ext", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailBPFOp, ext, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailBPFOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailBPFOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_TBOOL("is_pkt", CYAML_FLAG_OPTIONAL, TestDetailBPFOp,
|
||||
is_pkt),
|
||||
CYAML_FIELD_TBOOL("is_signed", CYAML_FLAG_OPTIONAL, TestDetailBPFOp,
|
||||
is_signed),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_bpf_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailBPFOp,
|
||||
test_detail_bpf_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailBPFOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailBPF;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_bpf_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailBPF, operands, &test_detail_bpf_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailBPF *test_detail_bpf_new();
|
||||
TestDetailBPF *test_detail_bpf_clone(const TestDetailBPF *detail);
|
||||
void test_detail_bpf_free(TestDetailBPF *detail);
|
||||
|
||||
TestDetailBPFOp *test_detail_bpf_op_new();
|
||||
TestDetailBPFOp *test_detail_bpf_op_clone(const TestDetailBPFOp *detail);
|
||||
void test_detail_bpf_op_free(TestDetailBPFOp *detail);
|
||||
|
||||
bool test_expected_bpf(csh *handle, const cs_bpf *actual,
|
||||
const TestDetailBPF *expected);
|
||||
|
||||
#endif // TEST_DETAIL_BPF_H
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_EVM_H
|
||||
#define TEST_DETAIL_EVM_H
|
||||
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
unsigned char pop;
|
||||
unsigned char push;
|
||||
unsigned int fee;
|
||||
} TestDetailEVM;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_evm_mapping_schema[] = {
|
||||
CYAML_FIELD_UINT("pop", CYAML_FLAG_OPTIONAL, TestDetailEVM, pop),
|
||||
CYAML_FIELD_UINT("push", CYAML_FLAG_OPTIONAL, TestDetailEVM, push),
|
||||
CYAML_FIELD_UINT("fee", CYAML_FLAG_OPTIONAL, TestDetailEVM, fee),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailEVM *test_detail_evm_new();
|
||||
TestDetailEVM *test_detail_evm_clone(const TestDetailEVM *detail);
|
||||
void test_detail_evm_free(TestDetailEVM *detail);
|
||||
|
||||
bool test_expected_evm(csh *handle, const cs_evm *actual,
|
||||
const TestDetailEVM *expected);
|
||||
|
||||
#endif // TEST_DETAIL_EVM_H
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_HPPA_H
|
||||
#define TEST_DETAIL_HPPA_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
char *mem_base;
|
||||
char *mem_space;
|
||||
char *mem_base_access;
|
||||
} TestDetailHPPAOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_hppa_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailHPPAOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailHPPAOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailHPPAOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailHPPAOp, imm),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailHPPAOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("mem_space",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailHPPAOp, mem_space, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_base_access", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailHPPAOp, mem_base_access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_hppa_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailHPPAOp,
|
||||
test_detail_hppa_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailHPPAOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailHPPA;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_hppa_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailHPPA, operands, &test_detail_hppa_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailHPPA *test_detail_hppa_new();
|
||||
TestDetailHPPA *test_detail_hppa_clone(const TestDetailHPPA *detail);
|
||||
void test_detail_hppa_free(TestDetailHPPA *detail);
|
||||
|
||||
TestDetailHPPAOp *test_detail_hppa_op_new();
|
||||
TestDetailHPPAOp *test_detail_hppa_op_clone(const TestDetailHPPAOp *detail);
|
||||
void test_detail_hppa_op_free(TestDetailHPPAOp *detail);
|
||||
|
||||
bool test_expected_hppa(csh *handle, const cs_hppa *actual,
|
||||
const TestDetailHPPA *expected);
|
||||
|
||||
#endif // TEST_DETAIL_HPPA_H
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_LOONGARCH_H
|
||||
#define TEST_DETAIL_LOONGARCH_H
|
||||
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
uint64_t imm;
|
||||
char *mem_base;
|
||||
char *mem_index;
|
||||
int64_t mem_disp;
|
||||
} TestDetailLoongArchOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_loongarch_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailLoongArchOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"access", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailLoongArchOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailLoongArchOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailLoongArchOp, imm),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_base", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailLoongArchOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_index", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailLoongArchOp, mem_index, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailLoongArchOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_loongarch_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailLoongArchOp,
|
||||
test_detail_loongarch_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *format;
|
||||
TestDetailLoongArchOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailLoongArch;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_loongarch_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("format",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailLoongArch, format, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_SEQUENCE("operands",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailLoongArch, operands,
|
||||
&test_detail_loongarch_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailLoongArch *test_detail_loongarch_new();
|
||||
TestDetailLoongArch *
|
||||
test_detail_loongarch_clone(const TestDetailLoongArch *detail);
|
||||
void test_detail_loongarch_free(TestDetailLoongArch *detail);
|
||||
|
||||
TestDetailLoongArchOp *test_detail_loongarch_op_new();
|
||||
TestDetailLoongArchOp *
|
||||
test_detail_loongarch_op_clone(const TestDetailLoongArchOp *detail);
|
||||
void test_detail_loongarch_op_free(TestDetailLoongArchOp *detail);
|
||||
|
||||
bool test_expected_loongarch(csh *handle, const cs_loongarch *actual,
|
||||
const TestDetailLoongArch *expected);
|
||||
|
||||
#endif // TEST_DETAIL_LOONGARCH_H
|
||||
@@ -0,0 +1,133 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_M680X_H
|
||||
#define TEST_DETAIL_M680X_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *base_reg;
|
||||
char *offset_reg;
|
||||
int16_t offset;
|
||||
uint16_t offset_addr;
|
||||
uint8_t offset_bits;
|
||||
int8_t inc_dec;
|
||||
char **flags;
|
||||
uint32_t flags_count;
|
||||
} TestDetailM680xIdx;
|
||||
|
||||
static const cyaml_schema_value_t flag_schema = {
|
||||
CYAML_VALUE_STRING(CYAML_FLAG_POINTER, char, 0, CYAML_UNLIMITED),
|
||||
};
|
||||
|
||||
static const cyaml_schema_field_t test_detail_m680x_idx_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"base_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680xIdx, base_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"offset_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680xIdx, offset_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("offset", CYAML_FLAG_OPTIONAL, TestDetailM680xIdx,
|
||||
offset),
|
||||
CYAML_FIELD_UINT("offset_addr", CYAML_FLAG_OPTIONAL, TestDetailM680xIdx,
|
||||
offset_addr),
|
||||
CYAML_FIELD_UINT("offset_bits", CYAML_FLAG_OPTIONAL, TestDetailM680xIdx,
|
||||
offset_bits),
|
||||
CYAML_FIELD_INT("inc_dec", CYAML_FLAG_OPTIONAL, TestDetailM680xIdx,
|
||||
inc_dec),
|
||||
CYAML_FIELD_SEQUENCE("flags", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680xIdx, flags, &flag_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX flags
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
TestDetailM680xIdx *idx;
|
||||
char *reg;
|
||||
int32_t imm;
|
||||
uint16_t rel_address;
|
||||
uint16_t ext_address;
|
||||
int16_t rel_offset;
|
||||
tbool ext_indirect;
|
||||
uint8_t direct_addr;
|
||||
bool direct_addr_set;
|
||||
uint8_t const_val;
|
||||
uint8_t size;
|
||||
} TestDetailM680xOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_m680x_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680xOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680xOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_MAPPING_PTR("idx", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680xOp, idx,
|
||||
test_detail_m680x_idx_mapping_schema),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680xOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailM680xOp, imm),
|
||||
CYAML_FIELD_UINT("rel_address", CYAML_FLAG_OPTIONAL, TestDetailM680xOp,
|
||||
rel_address),
|
||||
CYAML_FIELD_UINT("ext_address", CYAML_FLAG_OPTIONAL, TestDetailM680xOp,
|
||||
ext_address),
|
||||
CYAML_FIELD_INT("rel_offset", CYAML_FLAG_OPTIONAL, TestDetailM680xOp,
|
||||
rel_offset),
|
||||
CYAML_FIELD_INT("ext_indirect", CYAML_FLAG_OPTIONAL, TestDetailM680xOp,
|
||||
ext_indirect),
|
||||
CYAML_FIELD_UINT("direct_addr", CYAML_FLAG_OPTIONAL, TestDetailM680xOp,
|
||||
direct_addr),
|
||||
CYAML_FIELD_BOOL("direct_addr_set", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680xOp, direct_addr_set),
|
||||
CYAML_FIELD_UINT("const_val", CYAML_FLAG_OPTIONAL, TestDetailM680xOp,
|
||||
const_val),
|
||||
CYAML_FIELD_UINT("size", CYAML_FLAG_OPTIONAL, TestDetailM680xOp, size),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_m680x_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailM680xOp,
|
||||
test_detail_m680x_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char **flags;
|
||||
size_t flags_count;
|
||||
TestDetailM680xOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailM680x;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_m680x_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE("flags", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680x, flags, &flag_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX flags
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM680x, operands, &test_detail_m680x_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailM680x *test_detail_m680x_new();
|
||||
TestDetailM680x *test_detail_m680x_clone(const TestDetailM680x *detail);
|
||||
void test_detail_m680x_free(TestDetailM680x *detail);
|
||||
|
||||
TestDetailM680xOp *test_detail_m680x_op_new();
|
||||
TestDetailM680xOp *test_detail_m680x_op_clone(const TestDetailM680xOp *detail);
|
||||
void test_detail_m680x_op_free(TestDetailM680xOp *detail);
|
||||
|
||||
TestDetailM680xIdx *test_detail_m680x_idx_new();
|
||||
TestDetailM680xIdx *
|
||||
test_detail_m680x_idx_clone(const TestDetailM680xIdx *detail);
|
||||
void test_detail_m680x_idx_free(TestDetailM680xIdx *detail);
|
||||
|
||||
bool test_expected_m680x(csh *handle, const cs_m680x *actual,
|
||||
const TestDetailM680x *expected);
|
||||
|
||||
#endif // TEST_DETAIL_M680X_H
|
||||
@@ -0,0 +1,151 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_M68K_H
|
||||
#define TEST_DETAIL_M68K_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *base_reg;
|
||||
char *index_reg;
|
||||
char *in_base_reg;
|
||||
tbool index_size; // -1 == word, 1 == long
|
||||
int16_t disp;
|
||||
uint32_t in_disp;
|
||||
uint32_t out_disp;
|
||||
uint8_t scale;
|
||||
uint8_t bitfield;
|
||||
uint8_t width;
|
||||
uint8_t offset;
|
||||
} TestDetailM68KOpMem;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_m68k_op_mem_mapping_schema[] = {
|
||||
CYAML_FIELD_INT("disp", CYAML_FLAG_OPTIONAL, TestDetailM68KOpMem, disp),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"base_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOpMem, base_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"index_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOpMem, index_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"in_base_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOpMem, in_base_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("index_size", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOpMem, index_size),
|
||||
CYAML_FIELD_INT("disp", CYAML_FLAG_OPTIONAL, TestDetailM68KOpMem, disp),
|
||||
CYAML_FIELD_UINT("in_disp", CYAML_FLAG_OPTIONAL, TestDetailM68KOpMem,
|
||||
in_disp),
|
||||
CYAML_FIELD_UINT("out_disp", CYAML_FLAG_OPTIONAL, TestDetailM68KOpMem,
|
||||
out_disp),
|
||||
CYAML_FIELD_UINT("scale", CYAML_FLAG_OPTIONAL, TestDetailM68KOpMem,
|
||||
scale),
|
||||
CYAML_FIELD_UINT("bitfield", CYAML_FLAG_OPTIONAL, TestDetailM68KOpMem,
|
||||
bitfield),
|
||||
CYAML_FIELD_UINT("width", CYAML_FLAG_OPTIONAL, TestDetailM68KOpMem,
|
||||
width),
|
||||
CYAML_FIELD_UINT("offset", CYAML_FLAG_OPTIONAL, TestDetailM68KOpMem,
|
||||
offset),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *address_mode;
|
||||
|
||||
char *reg;
|
||||
char *reg_pair_0;
|
||||
char *reg_pair_1;
|
||||
|
||||
uint64_t imm;
|
||||
int32_t br_disp;
|
||||
uint8_t br_disp_size;
|
||||
|
||||
uint32_t register_bits;
|
||||
|
||||
double dimm;
|
||||
float simm;
|
||||
|
||||
TestDetailM68KOpMem *mem;
|
||||
} TestDetailM68KOp;
|
||||
|
||||
static const cyaml_schema_value_t test_detail_m68k_op_sys_psr_schema = {
|
||||
CYAML_VALUE_STRING(CYAML_FLAG_POINTER, char, 0, CYAML_UNLIMITED),
|
||||
};
|
||||
|
||||
static const cyaml_schema_field_t test_detail_m68k_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"address_mode", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOp, address_mode, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"reg_pair_0", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOp, reg_pair_0, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"reg_pair_1", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68KOp, reg_pair_1, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailM68KOp, imm),
|
||||
CYAML_FIELD_INT("br_disp", CYAML_FLAG_OPTIONAL, TestDetailM68KOp,
|
||||
br_disp),
|
||||
CYAML_FIELD_UINT("br_disp_size", CYAML_FLAG_OPTIONAL, TestDetailM68KOp,
|
||||
br_disp_size),
|
||||
CYAML_FIELD_UINT("register_bits", CYAML_FLAG_OPTIONAL, TestDetailM68KOp,
|
||||
register_bits),
|
||||
CYAML_FIELD_FLOAT("dimm", CYAML_FLAG_OPTIONAL, TestDetailM68KOp, dimm),
|
||||
CYAML_FIELD_FLOAT("simm", CYAML_FLAG_OPTIONAL, TestDetailM68KOp, simm),
|
||||
CYAML_FIELD_MAPPING_PTR("mem", CYAML_FLAG_OPTIONAL, TestDetailM68KOp,
|
||||
mem, test_detail_m68k_op_mem_mapping_schema),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_m68k_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailM68KOp,
|
||||
test_detail_m68k_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *op_size_type;
|
||||
char *op_size_fpu;
|
||||
char *op_size_cpu;
|
||||
|
||||
TestDetailM68KOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailM68K;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_m68k_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"op_size_type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68K, op_size_type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("op_size_fpu",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68K, op_size_fpu, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("op_size_cpu",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68K, op_size_cpu, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailM68K, operands, &test_detail_m68k_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailM68K *test_detail_m68k_new();
|
||||
TestDetailM68K *test_detail_m68k_clone(TestDetailM68K *detail);
|
||||
void test_detail_m68k_free(TestDetailM68K *detail);
|
||||
|
||||
TestDetailM68KOp *test_detail_m68k_op_new();
|
||||
TestDetailM68KOp *test_detail_m68k_op_clone(TestDetailM68KOp *detail);
|
||||
void test_detail_m68k_op_free(TestDetailM68KOp *detail);
|
||||
|
||||
TestDetailM68KOpMem *test_detail_m68k_op_mem_new();
|
||||
TestDetailM68KOpMem *test_detail_m68k_op_mem_clone(TestDetailM68KOpMem *detail);
|
||||
void test_detail_m68k_op_mem_free(TestDetailM68KOpMem *detail);
|
||||
|
||||
bool test_expected_m68k(csh *handle, cs_m68k *actual, TestDetailM68K *expected);
|
||||
|
||||
#endif // TEST_DETAIL_M68K_H
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_MIPS_H
|
||||
#define TEST_DETAIL_MIPS_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
char *reg;
|
||||
uint64_t imm;
|
||||
char *mem_base;
|
||||
int64_t mem_disp;
|
||||
} TestDetailMipsOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_mips_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMipsOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"access", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMipsOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMipsOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailMipsOp, imm),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMipsOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailMipsOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_mips_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailMipsOp,
|
||||
test_detail_mips_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailMipsOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailMips;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_mips_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMips, operands, &test_detail_mips_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailMips *test_detail_mips_new();
|
||||
TestDetailMips *test_detail_mips_clone(const TestDetailMips *detail);
|
||||
void test_detail_mips_free(TestDetailMips *detail);
|
||||
|
||||
TestDetailMipsOp *test_detail_mips_op_new();
|
||||
TestDetailMipsOp *test_detail_mips_op_clone(const TestDetailMipsOp *detail);
|
||||
void test_detail_mips_op_free(TestDetailMipsOp *detail);
|
||||
|
||||
bool test_expected_mips(csh *handle, const cs_mips *actual,
|
||||
const TestDetailMips *expected);
|
||||
|
||||
#endif // TEST_DETAIL_MIPS_H
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_MOS65XX_H
|
||||
#define TEST_DETAIL_MOS65XX_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
|
||||
char *reg;
|
||||
uint16_t imm;
|
||||
uint32_t mem;
|
||||
} TestDetailMos65xxOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_mos65xx_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMos65xxOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMos65xxOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("imm", CYAML_FLAG_OPTIONAL, TestDetailMos65xxOp, imm),
|
||||
CYAML_FIELD_UINT("mem", CYAML_FLAG_OPTIONAL, TestDetailMos65xxOp, mem),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_mos65xx_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailMos65xxOp,
|
||||
test_detail_mos65xx_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *am;
|
||||
tbool modifies_flags;
|
||||
|
||||
TestDetailMos65xxOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailMos65xx;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_mos65xx_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("am", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMos65xx, am, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("modifies_flags", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMos65xx, modifies_flags),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailMos65xx, operands, &test_detail_mos65xx_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailMos65xx *test_detail_mos65xx_new();
|
||||
TestDetailMos65xx *test_detail_mos65xx_clone(const TestDetailMos65xx *detail);
|
||||
void test_detail_mos65xx_free(TestDetailMos65xx *detail);
|
||||
|
||||
TestDetailMos65xxOp *test_detail_mos65xx_op_new();
|
||||
TestDetailMos65xxOp *
|
||||
test_detail_mos65xx_op_clone(const TestDetailMos65xxOp *detail);
|
||||
void test_detail_mos65xx_op_free(TestDetailMos65xxOp *detail);
|
||||
|
||||
bool test_expected_mos65xx(csh *handle, const cs_mos65xx *actual,
|
||||
const TestDetailMos65xx *expected);
|
||||
|
||||
#endif // TEST_DETAIL_MOS65XX_H
|
||||
@@ -0,0 +1,124 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_PPC_H
|
||||
#define TEST_DETAIL_PPC_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
char *mem_base;
|
||||
char *mem_offset;
|
||||
int32_t mem_disp;
|
||||
} TestDetailPPCOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_ppc_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailPPCOp, imm),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("mem_offset",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCOp, mem_offset, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailPPCOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_ppc_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailPPCOp,
|
||||
test_detail_ppc_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint8_t bo;
|
||||
bool bo_set;
|
||||
uint8_t bi;
|
||||
bool bi_set;
|
||||
|
||||
char *crX_bit;
|
||||
char *crX;
|
||||
char *hint;
|
||||
char *pred_cr;
|
||||
char *pred_ctr;
|
||||
char *bh;
|
||||
} TestDetailPPCBC;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_ppc_bc_mapping_schema[] = {
|
||||
CYAML_FIELD_INT("bi", CYAML_FLAG_OPTIONAL, TestDetailPPCBC, bi),
|
||||
CYAML_FIELD_BOOL("bi_set", CYAML_FLAG_OPTIONAL, TestDetailPPCBC,
|
||||
bi_set),
|
||||
CYAML_FIELD_INT("bo", CYAML_FLAG_OPTIONAL, TestDetailPPCBC, bo),
|
||||
CYAML_FIELD_BOOL("bo_set", CYAML_FLAG_OPTIONAL, TestDetailPPCBC,
|
||||
bo_set),
|
||||
CYAML_FIELD_STRING_PTR("crX_bit",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCBC, crX_bit, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("crX", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCBC, crX, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("hint", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCBC, hint, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("pred_cr",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCBC, pred_cr, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("pred_ctr",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCBC, pred_ctr, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("bh", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPCBC, bh, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailPPCBC *bc;
|
||||
tbool update_cr0;
|
||||
char *format;
|
||||
TestDetailPPCOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailPPC;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_ppc_mapping_schema[] = {
|
||||
CYAML_FIELD_MAPPING_PTR("bc", CYAML_FLAG_OPTIONAL, TestDetailPPC, bc,
|
||||
test_detail_ppc_bc_mapping_schema),
|
||||
CYAML_FIELD_STRING_PTR("format",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPC, format, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("update_cr0", CYAML_FLAG_OPTIONAL, TestDetailPPC,
|
||||
update_cr0),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailPPC, operands, &test_detail_ppc_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailPPC *test_detail_ppc_new();
|
||||
TestDetailPPC *test_detail_ppc_clone(const TestDetailPPC *detail);
|
||||
void test_detail_ppc_free(TestDetailPPC *detail);
|
||||
|
||||
TestDetailPPCOp *test_detail_ppc_op_new();
|
||||
TestDetailPPCOp *test_detail_ppc_op_clone(const TestDetailPPCOp *detail);
|
||||
void test_detail_ppc_op_free(TestDetailPPCOp *detail);
|
||||
|
||||
TestDetailPPCBC *test_detail_ppc_bc_new();
|
||||
TestDetailPPCBC *test_detail_ppc_bc_clone(const TestDetailPPCBC *detail);
|
||||
void test_detail_ppc_bc_free(TestDetailPPCBC *detail);
|
||||
|
||||
bool test_expected_ppc(csh *handle, const cs_ppc *actual,
|
||||
const TestDetailPPC *expected);
|
||||
|
||||
#endif // TEST_DETAIL_PPC_H
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_RISCV_H
|
||||
#define TEST_DETAIL_RISCV_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
uint64_t imm;
|
||||
char *mem_base;
|
||||
int64_t mem_disp;
|
||||
} TestDetailRISCVOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_riscv_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailRISCVOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailRISCVOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailRISCVOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailRISCVOp, imm),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailRISCVOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailRISCVOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_riscv_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailRISCVOp,
|
||||
test_detail_riscv_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailRISCVOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailRISCV;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_riscv_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailRISCV, operands, &test_detail_riscv_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailRISCV *test_detail_riscv_new();
|
||||
TestDetailRISCV *test_detail_riscv_clone(const TestDetailRISCV *detail);
|
||||
void test_detail_riscv_free(TestDetailRISCV *detail);
|
||||
|
||||
TestDetailRISCVOp *test_detail_riscv_op_new();
|
||||
TestDetailRISCVOp *test_detail_riscv_op_clone(const TestDetailRISCVOp *detail);
|
||||
void test_detail_riscv_op_free(TestDetailRISCVOp *detail);
|
||||
|
||||
bool test_expected_riscv(csh *handle, const cs_riscv *actual,
|
||||
const TestDetailRISCV *expected);
|
||||
|
||||
#endif // TEST_DETAIL_RISCV_H
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_SH_H
|
||||
#define TEST_DETAIL_SH_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
|
||||
char *reg;
|
||||
uint64_t imm;
|
||||
char *mem_reg;
|
||||
char *mem_address;
|
||||
int32_t mem_disp;
|
||||
} TestDetailSHOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_sh_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSHOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSHOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailSHOp, imm),
|
||||
CYAML_FIELD_STRING_PTR("mem_reg",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSHOp, mem_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("mem_address",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSHOp, mem_address, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailSHOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_sh_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailSHOp,
|
||||
test_detail_sh_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailSHOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailSH;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_sh_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSH, operands, &test_detail_sh_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailSH *test_detail_sh_new();
|
||||
TestDetailSH *test_detail_sh_clone(const TestDetailSH *detail);
|
||||
void test_detail_sh_free(TestDetailSH *detail);
|
||||
|
||||
TestDetailSHOp *test_detail_sh_op_new();
|
||||
TestDetailSHOp *test_detail_sh_op_clone(const TestDetailSHOp *detail);
|
||||
void test_detail_sh_op_free(TestDetailSHOp *detail);
|
||||
|
||||
bool test_expected_sh(csh *handle, const cs_sh *actual,
|
||||
const TestDetailSH *expected);
|
||||
|
||||
#endif // TEST_DETAIL_SH_H
|
||||
@@ -0,0 +1,87 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_SPARC_H
|
||||
#define TEST_DETAIL_SPARC_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
char *mem_base;
|
||||
char *mem_index;
|
||||
int32_t mem_disp;
|
||||
char *asi;
|
||||
char *membar_tag;
|
||||
} TestDetailSparcOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_sparc_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparcOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparcOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparcOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailSparcOp, imm),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparcOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_index", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparcOp, mem_index, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailSparcOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_STRING_PTR("asi",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparcOp, asi, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("membar_tag",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparcOp, membar_tag, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_sparc_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailSparcOp,
|
||||
test_detail_sparc_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *cc;
|
||||
char *cc_field;
|
||||
char *hint;
|
||||
TestDetailSparcOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailSparc;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_sparc_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("cc", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparc, cc, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("cc_field", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparc, cc_field, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("hint", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparc, hint, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSparc, operands, &test_detail_sparc_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailSparc *test_detail_sparc_new();
|
||||
TestDetailSparc *test_detail_sparc_clone(const TestDetailSparc *detail);
|
||||
void test_detail_sparc_free(TestDetailSparc *detail);
|
||||
|
||||
TestDetailSparcOp *test_detail_sparc_op_new();
|
||||
TestDetailSparcOp *test_detail_sparc_op_clone(const TestDetailSparcOp *detail);
|
||||
void test_detail_sparc_op_free(TestDetailSparcOp *detail);
|
||||
|
||||
bool test_expected_sparc(csh *handle, const cs_sparc *actual,
|
||||
const TestDetailSparc *expected);
|
||||
|
||||
#endif // TEST_DETAIL_SPARC_H
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_SYSTEMZ_H
|
||||
#define TEST_DETAIL_SYSTEMZ_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
uint8_t imm_width;
|
||||
char *mem_am;
|
||||
char *mem_base;
|
||||
char *mem_index;
|
||||
int64_t mem_disp;
|
||||
uint64_t mem_length;
|
||||
} TestDetailSystemZOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_systemz_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSystemZOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSystemZOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSystemZOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailSystemZOp, imm),
|
||||
CYAML_FIELD_UINT("imm_width", CYAML_FLAG_OPTIONAL, TestDetailSystemZOp,
|
||||
imm_width),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_am", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSystemZOp, mem_am, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_base", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSystemZOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_index", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSystemZOp, mem_index, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailSystemZOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_INT("mem_length", CYAML_FLAG_OPTIONAL, TestDetailSystemZOp,
|
||||
mem_length),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_systemz_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailSystemZOp,
|
||||
test_detail_systemz_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *format;
|
||||
TestDetailSystemZOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailSystemZ;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_systemz_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"format", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSystemZ, format, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailSystemZ, operands, &test_detail_systemz_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailSystemZ *test_detail_systemz_new();
|
||||
TestDetailSystemZ *test_detail_systemz_clone(const TestDetailSystemZ *detail);
|
||||
void test_detail_systemz_free(TestDetailSystemZ *detail);
|
||||
|
||||
TestDetailSystemZOp *test_detail_systemz_op_new();
|
||||
TestDetailSystemZOp *
|
||||
test_detail_systemz_op_clone(const TestDetailSystemZOp *detail);
|
||||
void test_detail_systemz_op_free(TestDetailSystemZOp *detail);
|
||||
|
||||
bool test_expected_systemz(csh *handle, const cs_systemz *actual,
|
||||
const TestDetailSystemZ *expected);
|
||||
|
||||
#endif // TEST_DETAIL_SYSTEMZ_H
|
||||
@@ -0,0 +1,134 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_TMS320C64X_H
|
||||
#define TEST_DETAIL_TMS320C64X_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
|
||||
char *reg;
|
||||
char *reg_pair_0;
|
||||
char *reg_pair_1;
|
||||
int32_t imm;
|
||||
char *mem_base;
|
||||
tbool mem_scaled;
|
||||
char *mem_disptype;
|
||||
char *mem_direction;
|
||||
char *mem_modify;
|
||||
char *mem_disp_reg;
|
||||
unsigned int mem_disp_const;
|
||||
unsigned int mem_unit;
|
||||
} TestDetailTMS320c64xOp;
|
||||
|
||||
static const cyaml_schema_value_t test_detail_tms320c64x_op_sys_psr_schema = {
|
||||
CYAML_VALUE_STRING(CYAML_FLAG_POINTER, char, 0, CYAML_UNLIMITED),
|
||||
};
|
||||
|
||||
static const cyaml_schema_field_t test_detail_tms320c64x_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, type, 0,
|
||||
CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"reg_pair_0", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, reg_pair_0, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"reg_pair_1", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, reg_pair_1, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailTMS320c64xOp,
|
||||
imm),
|
||||
CYAML_FIELD_INT("mem_scaled", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, mem_scaled),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_base", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_disptype", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, mem_disptype, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_direction", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, mem_direction, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_modify", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, mem_modify, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("mem_disp_const", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, mem_disp_const),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_disp_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, mem_disp_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("mem_unit", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64xOp, mem_unit),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_tms320c64x_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailTMS320c64xOp,
|
||||
test_detail_tms320c64x_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *cond_reg;
|
||||
tbool cond_zero;
|
||||
|
||||
char *funit_unit;
|
||||
uint8_t funit_side;
|
||||
bool funit_side_set;
|
||||
uint8_t funit_crosspath;
|
||||
bool funit_crosspath_set;
|
||||
|
||||
int8_t parallel;
|
||||
bool parallel_set;
|
||||
|
||||
TestDetailTMS320c64xOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailTMS320c64x;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_tms320c64x_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"cond_reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64x, cond_reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("cond_zero", CYAML_FLAG_OPTIONAL, TestDetailTMS320c64x,
|
||||
cond_zero),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"funit_unit", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64x, funit_unit, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("funit_side", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64x, funit_side),
|
||||
CYAML_FIELD_BOOL("funit_side_set", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64x, funit_side_set),
|
||||
CYAML_FIELD_UINT("funit_crosspath", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64x, funit_crosspath),
|
||||
CYAML_FIELD_BOOL("funit_crosspath_set", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64x, funit_crosspath_set),
|
||||
CYAML_FIELD_INT("parallel", CYAML_FLAG_OPTIONAL, TestDetailTMS320c64x,
|
||||
parallel),
|
||||
CYAML_FIELD_BOOL("parallel_set", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64x, parallel_set),
|
||||
CYAML_FIELD_SEQUENCE("operands",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTMS320c64x, operands,
|
||||
&test_detail_tms320c64x_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailTMS320c64x *test_detail_tms320c64x_new();
|
||||
TestDetailTMS320c64x *
|
||||
test_detail_tms320c64x_clone(TestDetailTMS320c64x *detail);
|
||||
void test_detail_tms320c64x_free(TestDetailTMS320c64x *detail);
|
||||
|
||||
TestDetailTMS320c64xOp *test_detail_tms320c64x_op_new();
|
||||
TestDetailTMS320c64xOp *
|
||||
test_detail_tms320c64x_op_clone(TestDetailTMS320c64xOp *detail);
|
||||
void test_detail_tms320c64x_op_free(TestDetailTMS320c64xOp *detail);
|
||||
|
||||
bool test_expected_tms320c64x(csh *handle, cs_tms320c64x *actual,
|
||||
TestDetailTMS320c64x *expected);
|
||||
|
||||
#endif // TEST_DETAIL_TMS320C64X_H
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_TRICORE_H
|
||||
#define TEST_DETAIL_TRICORE_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
char *mem_base;
|
||||
int64_t mem_disp;
|
||||
} TestDetailTriCoreOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_tricore_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTriCoreOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTriCoreOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTriCoreOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailTriCoreOp, imm),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_base", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTriCoreOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailTriCoreOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_tricore_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailTriCoreOp,
|
||||
test_detail_tricore_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
tbool update_flags;
|
||||
TestDetailTriCoreOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailTriCore;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_tricore_mapping_schema[] = {
|
||||
CYAML_FIELD_INT("update_flags", CYAML_FLAG_OPTIONAL, TestDetailTriCore,
|
||||
update_flags),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailTriCore, operands, &test_detail_tricore_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailTriCore *test_detail_tricore_new();
|
||||
TestDetailTriCore *test_detail_tricore_clone(const TestDetailTriCore *detail);
|
||||
void test_detail_tricore_free(TestDetailTriCore *detail);
|
||||
|
||||
TestDetailTriCoreOp *test_detail_tricore_op_new();
|
||||
TestDetailTriCoreOp *
|
||||
test_detail_tricore_op_clone(const TestDetailTriCoreOp *detail);
|
||||
void test_detail_tricore_op_free(TestDetailTriCoreOp *detail);
|
||||
|
||||
bool test_expected_tricore(csh *handle, const cs_tricore *actual,
|
||||
const TestDetailTriCore *expected);
|
||||
|
||||
#endif // TEST_DETAIL_TRICORE_H
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_WASM_H
|
||||
#define TEST_DETAIL_WASM_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
|
||||
uint32_t size;
|
||||
int8_t int7;
|
||||
uint32_t varuint32;
|
||||
uint64_t varuint64;
|
||||
uint32_t uint32;
|
||||
uint64_t uint64;
|
||||
uint32_t immediate_0;
|
||||
uint32_t immediate_1;
|
||||
uint32_t brt_length;
|
||||
uint64_t brt_address;
|
||||
uint32_t brt_default_target;
|
||||
} TestDetailWASMOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_wasm_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailWASMOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("size", CYAML_FLAG_OPTIONAL, TestDetailWASMOp, size),
|
||||
CYAML_FIELD_INT("int7", CYAML_FLAG_OPTIONAL, TestDetailWASMOp, int7),
|
||||
CYAML_FIELD_UINT("varuint32", CYAML_FLAG_OPTIONAL, TestDetailWASMOp,
|
||||
varuint32),
|
||||
CYAML_FIELD_UINT("varuint64", CYAML_FLAG_OPTIONAL, TestDetailWASMOp,
|
||||
varuint64),
|
||||
CYAML_FIELD_UINT("uint64", CYAML_FLAG_OPTIONAL, TestDetailWASMOp,
|
||||
uint64),
|
||||
CYAML_FIELD_UINT("uint32", CYAML_FLAG_OPTIONAL, TestDetailWASMOp,
|
||||
uint32),
|
||||
CYAML_FIELD_UINT("immediate_0", CYAML_FLAG_OPTIONAL, TestDetailWASMOp,
|
||||
immediate_0),
|
||||
CYAML_FIELD_UINT("immediate_1", CYAML_FLAG_OPTIONAL, TestDetailWASMOp,
|
||||
immediate_1),
|
||||
CYAML_FIELD_UINT("brt_length", CYAML_FLAG_OPTIONAL, TestDetailWASMOp,
|
||||
brt_length),
|
||||
CYAML_FIELD_UINT("brt_address", CYAML_FLAG_OPTIONAL, TestDetailWASMOp,
|
||||
brt_address),
|
||||
CYAML_FIELD_UINT("brt_default_target", CYAML_FLAG_OPTIONAL,
|
||||
TestDetailWASMOp, brt_default_target),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_wasm_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailWASMOp,
|
||||
test_detail_wasm_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailWASMOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailWASM;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_wasm_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailWASM, operands, &test_detail_wasm_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailWASM *test_detail_wasm_new();
|
||||
TestDetailWASM *test_detail_wasm_clone(const TestDetailWASM *detail);
|
||||
void test_detail_wasm_free(TestDetailWASM *detail);
|
||||
|
||||
TestDetailWASMOp *test_detail_wasm_op_new();
|
||||
TestDetailWASMOp *test_detail_wasm_op_clone(const TestDetailWASMOp *detail);
|
||||
void test_detail_wasm_op_free(TestDetailWASMOp *detail);
|
||||
|
||||
bool test_expected_wasm(csh *handle, const cs_wasm *actual,
|
||||
const TestDetailWASM *expected);
|
||||
|
||||
#endif // TEST_DETAIL_WASM_H
|
||||
@@ -0,0 +1,178 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_X86_H
|
||||
#define TEST_DETAIL_X86_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
uint8_t size;
|
||||
|
||||
char *reg;
|
||||
int64_t imm;
|
||||
char *mem_segment;
|
||||
char *mem_base;
|
||||
char *mem_index;
|
||||
int mem_scale;
|
||||
int64_t mem_disp;
|
||||
|
||||
char *avx_bcast;
|
||||
tbool avx_zero_opmask;
|
||||
} TestDetailX86Op;
|
||||
|
||||
static const cyaml_schema_value_t test_detail_x86_op_sys_psr_schema = {
|
||||
CYAML_VALUE_STRING(CYAML_FLAG_POINTER, char, 0, CYAML_UNLIMITED),
|
||||
};
|
||||
|
||||
static const cyaml_schema_field_t test_detail_x86_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86Op, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86Op, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("size", CYAML_FLAG_OPTIONAL, TestDetailX86Op, size),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86Op, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailX86Op, imm),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_segment", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86Op, mem_segment, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86Op, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("mem_index",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86Op, mem_index, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailX86Op,
|
||||
mem_disp),
|
||||
CYAML_FIELD_INT("mem_scale", CYAML_FLAG_OPTIONAL, TestDetailX86Op,
|
||||
mem_scale),
|
||||
CYAML_FIELD_INT("avx_zero_opmask", CYAML_FLAG_OPTIONAL, TestDetailX86Op,
|
||||
avx_zero_opmask),
|
||||
CYAML_FIELD_STRING_PTR("avx_bcast",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86Op, avx_bcast, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_x86_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailX86Op,
|
||||
test_detail_x86_op_mapping_schema),
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_x86_opcode_schema = {
|
||||
CYAML_VALUE_UINT(CYAML_FLAG_DEFAULT, uint8_t),
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_x86_string_schema = {
|
||||
CYAML_VALUE_STRING(CYAML_FLAG_POINTER, char, 0, CYAML_UNLIMITED),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *sib_index;
|
||||
char *sib_base;
|
||||
char *xop_cc;
|
||||
char *sse_cc;
|
||||
char *avx_cc;
|
||||
char *avx_rm;
|
||||
|
||||
char *prefix[4];
|
||||
uint8_t opcode[4];
|
||||
|
||||
uint8_t rex;
|
||||
uint8_t addr_size;
|
||||
uint8_t modrm;
|
||||
uint8_t sib;
|
||||
int64_t disp;
|
||||
int8_t sib_scale;
|
||||
tbool avx_sae;
|
||||
|
||||
char **eflags;
|
||||
size_t eflags_count;
|
||||
char **fpu_flags;
|
||||
size_t fpu_flags_count;
|
||||
|
||||
uint8_t enc_modrm_offset;
|
||||
uint8_t enc_disp_offset;
|
||||
uint8_t enc_disp_size;
|
||||
uint8_t enc_imm_offset;
|
||||
uint8_t enc_imm_size;
|
||||
|
||||
TestDetailX86Op **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailX86;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_x86_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("sib_index",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, sib_index, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("sib_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, sib_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("xop_cc",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, xop_cc, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("sse_cc",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, sse_cc, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("avx_cc",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, avx_cc, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("avx_rm",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, avx_rm, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_SEQUENCE_FIXED("prefix", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
prefix, &test_detail_x86_string_schema, 4),
|
||||
CYAML_FIELD_SEQUENCE_FIXED("opcode", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
opcode, &test_detail_x86_opcode_schema, 4),
|
||||
CYAML_FIELD_UINT("rex", CYAML_FLAG_OPTIONAL, TestDetailX86, rex),
|
||||
CYAML_FIELD_UINT("addr_size", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
addr_size),
|
||||
CYAML_FIELD_UINT("modrm", CYAML_FLAG_OPTIONAL, TestDetailX86, modrm),
|
||||
CYAML_FIELD_UINT("sib", CYAML_FLAG_OPTIONAL, TestDetailX86, sib),
|
||||
CYAML_FIELD_INT("disp", CYAML_FLAG_OPTIONAL, TestDetailX86, disp),
|
||||
CYAML_FIELD_INT("sib_scale", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
sib_scale),
|
||||
CYAML_FIELD_INT("avx_sae", CYAML_FLAG_OPTIONAL, TestDetailX86, avx_sae),
|
||||
CYAML_FIELD_SEQUENCE("eflags", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, eflags,
|
||||
&test_detail_x86_string_schema, 0,
|
||||
CYAML_UNLIMITED),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"fpu_flags", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, fpu_flags, &test_detail_x86_string_schema, 0,
|
||||
CYAML_UNLIMITED),
|
||||
CYAML_FIELD_UINT("enc_modrm_offset", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
enc_modrm_offset),
|
||||
CYAML_FIELD_UINT("enc_disp_offset", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
enc_disp_offset),
|
||||
CYAML_FIELD_UINT("enc_disp_size", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
enc_disp_size),
|
||||
CYAML_FIELD_UINT("enc_imm_offset", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
enc_imm_offset),
|
||||
CYAML_FIELD_UINT("enc_imm_size", CYAML_FLAG_OPTIONAL, TestDetailX86,
|
||||
enc_imm_size),
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailX86, operands, &test_detail_x86_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailX86 *test_detail_x86_new();
|
||||
TestDetailX86 *test_detail_x86_clone(TestDetailX86 *detail);
|
||||
void test_detail_x86_free(TestDetailX86 *detail);
|
||||
|
||||
TestDetailX86Op *test_detail_x86_op_new();
|
||||
TestDetailX86Op *test_detail_x86_op_clone(TestDetailX86Op *detail);
|
||||
void test_detail_x86_op_free(TestDetailX86Op *detail);
|
||||
|
||||
bool test_expected_x86(csh *handle, cs_x86 *actual, TestDetailX86 *expected);
|
||||
|
||||
#endif // TEST_DETAIL_X86_H
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_XCORE_H
|
||||
#define TEST_DETAIL_XCORE_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
|
||||
char *reg;
|
||||
int32_t imm;
|
||||
char *mem_base;
|
||||
char *mem_index;
|
||||
int32_t mem_disp;
|
||||
int32_t mem_direct;
|
||||
} TestDetailXCoreOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_xcore_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXCoreOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXCoreOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailXCoreOp, imm),
|
||||
CYAML_FIELD_STRING_PTR("mem_base",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXCoreOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_index", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXCoreOp, mem_index, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailXCoreOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_INT("mem_direct", CYAML_FLAG_OPTIONAL, TestDetailXCoreOp,
|
||||
mem_direct),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_xcore_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailXCoreOp,
|
||||
test_detail_xcore_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailXCoreOp **operands;
|
||||
uint32_t operands_count;
|
||||
} TestDetailXCore;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_xcore_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXCore, operands, &test_detail_xcore_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailXCore *test_detail_xcore_new();
|
||||
TestDetailXCore *test_detail_xcore_clone(const TestDetailXCore *detail);
|
||||
void test_detail_xcore_free(TestDetailXCore *detail);
|
||||
|
||||
TestDetailXCoreOp *test_detail_xcore_op_new();
|
||||
TestDetailXCoreOp *test_detail_xcore_op_clone(const TestDetailXCoreOp *detail);
|
||||
void test_detail_xcore_op_free(TestDetailXCoreOp *detail);
|
||||
|
||||
bool test_expected_xcore(csh *handle, const cs_xcore *actual,
|
||||
const TestDetailXCore *expected);
|
||||
|
||||
#endif // TEST_DETAIL_XCORE_H
|
||||
@@ -0,0 +1,73 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// Copyright © 2024 Billow <billow.fun@gmail.com>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TEST_DETAIL_XTENSA_H
|
||||
#define TEST_DETAIL_XTENSA_H
|
||||
|
||||
#include "test_compare.h"
|
||||
#include <cyaml/cyaml.h>
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
typedef struct {
|
||||
char *type;
|
||||
char *access;
|
||||
|
||||
char *reg;
|
||||
int32_t imm;
|
||||
char *mem_base;
|
||||
int32_t mem_disp;
|
||||
} TestDetailXtensaOp;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_xtensa_op_mapping_schema[] = {
|
||||
CYAML_FIELD_STRING_PTR("type", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXtensaOp, type, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("access",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXtensaOp, access, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_STRING_PTR("reg", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXtensaOp, reg, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("imm", CYAML_FLAG_OPTIONAL, TestDetailXtensaOp, imm),
|
||||
CYAML_FIELD_STRING_PTR(
|
||||
"mem_base", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXtensaOp, mem_base, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_INT("mem_disp", CYAML_FLAG_OPTIONAL, TestDetailXtensaOp,
|
||||
mem_disp),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t test_detail_xtensa_op_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, TestDetailXtensaOp,
|
||||
test_detail_xtensa_op_mapping_schema),
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
TestDetailXtensaOp **operands;
|
||||
uint32_t operands_count;
|
||||
char *format;
|
||||
} TestDetailXtensa;
|
||||
|
||||
static const cyaml_schema_field_t test_detail_xtensa_mapping_schema[] = {
|
||||
CYAML_FIELD_SEQUENCE(
|
||||
"operands", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXtensa, operands, &test_detail_xtensa_op_schema, 0,
|
||||
CYAML_UNLIMITED), // 0-MAX options
|
||||
CYAML_FIELD_STRING_PTR("format",
|
||||
CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
|
||||
TestDetailXtensa, format, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
TestDetailXtensa *test_detail_xtensa_new();
|
||||
TestDetailXtensa *test_detail_xtensa_clone(const TestDetailXtensa *detail);
|
||||
void test_detail_xtensa_free(TestDetailXtensa *detail);
|
||||
|
||||
TestDetailXtensaOp *test_detail_xtensa_op_new();
|
||||
TestDetailXtensaOp *
|
||||
test_detail_xtensa_op_clone(const TestDetailXtensaOp *detail);
|
||||
void test_detail_xtensa_op_free(TestDetailXtensaOp *detail);
|
||||
|
||||
bool test_expected_xtensa(csh *handle, const cs_xtensa *actual,
|
||||
const TestDetailXtensa *expected);
|
||||
|
||||
#endif // TEST_DETAIL_XTENSA_H
|
||||
+1752
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
// Copyright © 2024 Rot127 <unisono@quyllur.org>
|
||||
// SPDX-License-Identifier: BSD-3
|
||||
|
||||
#ifndef TESTRUN_H
|
||||
#define TESTRUN_H
|
||||
|
||||
#include "test_case.h"
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
TEST_RUN_SUCCESS = 0, ///< All test cases succeeded.
|
||||
TEST_RUN_FAILURE = 1, ///< At least one test case failed.
|
||||
TEST_RUN_ERROR = 2, ///< Test run had errors.
|
||||
} TestRunResult;
|
||||
|
||||
typedef struct {
|
||||
uint32_t valid_test_files; ///< Total number of test files.
|
||||
uint32_t invalid_files; ///< Number of invalid files.
|
||||
uint32_t tc_total; ///< Total number of test cases.
|
||||
uint32_t successful; ///< Number of successful test cases.
|
||||
uint32_t failed; ///< Number of failed test cases.
|
||||
uint32_t errors; ///< Number errors (parsing errors etc).
|
||||
uint32_t skipped; ///< Number skipped test cases.
|
||||
uint32_t decoded_insns; ///< Number of total decoded instructions.
|
||||
} TestRunStats;
|
||||
|
||||
typedef struct {
|
||||
uint32_t case_cnt;
|
||||
TestCase *cases;
|
||||
} TestRun;
|
||||
|
||||
/* CYAML configuration. */
|
||||
static const cyaml_config_t cyaml_config = {
|
||||
.log_fn = cyaml_log, /* Use the default logging function. */
|
||||
.mem_fn = cyaml_mem, /* Use the default memory allocator. */
|
||||
.log_level = CYAML_LOG_WARNING, /* Logging errors and warnings only. */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
size_t arch_bits; ///< Bits of the architecture.
|
||||
TestCase *tcase; ///< The test case to check.
|
||||
csh handle; ///< The Capstone instance for this test. Setup and teared down by the cmocka handlers.
|
||||
uint32_t decoded_insns; ///< Counts the number of decoded instructions of this test case.
|
||||
} UnitTestState;
|
||||
|
||||
TestRunResult cstest_run_tests(char **test_file_paths, uint32_t path_count,
|
||||
TestRunStats *stats);
|
||||
|
||||
#endif // TESTRUN_H
|
||||
Reference in New Issue
Block a user