Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Aug 3, 2024
1 parent b91d4bc commit df7e5db
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 237 deletions.
35 changes: 19 additions & 16 deletions suite/cstest/include/test_case.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

/// Input data for a test case.
typedef struct {
uint8_t *bytes; // mandatory
uint32_t bytes_count; // Filled by cyaml
char *arch; // mandatory
uint8_t *bytes; // mandatory
uint32_t bytes_count; // Filled by cyaml
char *arch; // mandatory
uint64_t address;
char **options; // mandatory
char **options; // mandatory
uint32_t options_count; // Filled by cyaml
} TestInput;

Expand Down Expand Up @@ -56,7 +56,7 @@ static const cyaml_schema_field_t test_input_mapping_schema[] = {
/// Data compared to the produced cs_insn.
typedef struct {
uint32_t id;
char *asm_text; // mandatory
char *asm_text; // mandatory
char *op_str;
int32_t is_alias; ///< 0 == not given, >0 == true, <0 == false
uint64_t alias_id;
Expand All @@ -73,18 +73,20 @@ static const cyaml_schema_field_t test_insn_data_mapping_schema[] = {
TestInsnData, id),
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_STRING_PTR(
"op_str", CYAML_FLAG_POINTER_NULL_STR | CYAML_FLAG_OPTIONAL,
TestInsnData, op_str, 0, CYAML_UNLIMITED),
CYAML_FIELD_UINT("is_alias", CYAML_FLAG_OPTIONAL, TestInsnData,
is_alias),
CYAML_FIELD_INT("alias_id",
CYAML_FLAG_SCALAR_PLAIN | CYAML_FLAG_OPTIONAL,
TestInsnData, alias_id),
CYAML_FLAG_SCALAR_PLAIN | CYAML_FLAG_OPTIONAL,
TestInsnData, alias_id),
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_MAPPING_PTR(
"details", CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL,
TestInsnData, details, test_detail_mapping_schema),
CYAML_FIELD_END
};

Expand Down Expand Up @@ -116,8 +118,8 @@ static const cyaml_schema_field_t test_expected_mapping_schema[] = {
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.
bool skip; ///< If set, the test is skipped
char *skip_reason; ///< Reason this test is skipped.
} TestCase;

TestCase *test_case_new();
Expand All @@ -130,9 +132,10 @@ static const cyaml_schema_field_t test_case_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_STRING_PTR("skip_reason",
CYAML_FLAG_POINTER_NULL_STR |
CYAML_FLAG_OPTIONAL,
TestCase, skip_reason, 0, CYAML_UNLIMITED),
CYAML_FIELD_END
};

Expand Down
45 changes: 26 additions & 19 deletions suite/cstest/include/test_compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ typedef int32_t tbool;
/// 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", \
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; \
}
Expand All @@ -41,8 +44,10 @@ typedef int32_t tbool;
/// 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", \
if (((uint8_t)actual) != ((uint8_t)expected)) { \
fprintf(stderr, \
#actual " != " #expected ": %" PRId8 " != %" PRId8 \
"\n", \
actual, expected); \
return ret_val; \
}
Expand All @@ -61,21 +66,21 @@ typedef int32_t tbool;
/// 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)) { \
if (((uint32_t)actual) != ((uint32_t)expected)) { \
fprintf(stderr, \
#actual " != " #expected ": 0x%" PRIx32 " != 0x%" PRIx32 \
"\n", \
#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)) { \
if (((uint64_t)actual) != ((uint64_t)expected)) { \
fprintf(stderr, \
#actual " != " #expected ": 0x%" PRIx64 " != 0x%" PRIx64 \
"\n", \
#actual " != " #expected ": 0x%" PRIx64 \
" != 0x%" PRIx64 "\n", \
actual, expected); \
return ret_val; \
}
Expand All @@ -94,7 +99,7 @@ typedef int32_t tbool;
/// 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)) { \
if (((int8_t)actual) != ((int8_t)expected)) { \
fprintf(stderr, \
#actual " != " #expected ": 0x%" PRIx8 " != 0x%" PRIx8 \
"\n", \
Expand All @@ -105,21 +110,21 @@ typedef int32_t tbool;
/// 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)) { \
if (((int32_t)actual) != ((int32_t)expected)) { \
fprintf(stderr, \
#actual " != " #expected ": 0x%" PRIx32 " != 0x%" PRIx32 \
"\n", \
#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)) { \
if (((int64_t)actual) != ((int64_t)expected)) { \
fprintf(stderr, \
#actual " != " #expected ": 0x%" PRIx64 " != 0x%" PRIx64 \
"\n", \
#actual " != " #expected ": 0x%" PRIx64 \
" != 0x%" PRIx64 "\n", \
actual, expected); \
return ret_val; \
}
Expand All @@ -139,12 +144,14 @@ typedef int32_t tbool;
#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); \
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"); \
actual, expected, \
found ? "" : " <== id not found"); \
return ret_val; \
} \
}
Expand Down
2 changes: 1 addition & 1 deletion suite/cstest/include/test_detail.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ TestDetail *test_detail_clone(TestDetail *detail);
void test_detail_free(TestDetail *detail);

bool test_expected_detail(csh *handle, const cs_insn *insn,
TestDetail *expected);
TestDetail *expected);

#endif // TEST_DETAIL_H
2 changes: 1 addition & 1 deletion suite/cstest/include/test_detail_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static const cyaml_schema_field_t test_detail_aarch64_op_mapping_schema[] = {
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),
TestDetailAArch64Op, vector_index_is_set),
CYAML_FIELD_INT("is_list_member", CYAML_FLAG_OPTIONAL,
TestDetailAArch64Op, is_list_member),
CYAML_FIELD_END
Expand Down
Loading

0 comments on commit df7e5db

Please sign in to comment.