Another way to solve when compare with issue (#1379)
* cstest: partial details are supported in issues.cs
This commit is contained in:
parent
74e15a0263
commit
c7fbb5d4cd
|
@ -275,6 +275,7 @@ void test_single_issue(csh *handle, cs_mode mode, char *line, int detail)
|
|||
{
|
||||
char **list_part, **list_byte, **list_part_cs_result, **list_part_issue_result;
|
||||
int size_part, size_byte, size_part_cs_result, size_part_issue_result;
|
||||
char *tmptmp;
|
||||
int i, count, j;
|
||||
unsigned char *code;
|
||||
cs_insn *insn;
|
||||
|
@ -326,34 +327,30 @@ void test_single_issue(csh *handle, cs_mode mode, char *line, int detail)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_part_cs_result = split(cs_result, " ; ", &size_part_cs_result);
|
||||
|
||||
trim_str(cs_result);
|
||||
add_str(&cs_result, " ;");
|
||||
// list_part_cs_result = split(cs_result, " ; ", &size_part_cs_result);
|
||||
list_part_issue_result = split(list_part[1], " ; ", &size_part_issue_result);
|
||||
|
||||
if (size_part_cs_result != size_part_issue_result) {
|
||||
fprintf(stderr, "[ ERROR ] --- %s --- Number of details( Capstone: %d --- Issue: %d ) doesn't match\n", list_part[0], size_part_cs_result, size_part_issue_result);
|
||||
cs_free(insn, count);
|
||||
free_strs(list_part, size_part);
|
||||
free_strs(list_byte, size_byte);
|
||||
free(cs_result);
|
||||
free_strs(list_part_cs_result, size_part_cs_result);
|
||||
free_strs(list_part_issue_result, size_part_issue_result);
|
||||
_fail(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
for (i = 0; i < size_part_cs_result; ++i) {
|
||||
trim_str(list_part_cs_result[i]);
|
||||
for (i = 0; i < size_part_issue_result; ++i) {
|
||||
trim_str(list_part_issue_result[i]);
|
||||
memset(tmptmp, MAXMEM, 0);
|
||||
|
||||
tmptmp = (char *)malloc(sizeof(char));
|
||||
tmptmp[0] = '\0';
|
||||
add_str(&tmptmp, "%s", list_part_issue_result[i]);
|
||||
add_str(&tmptmp, " ;");
|
||||
|
||||
if (strcmp(list_part_cs_result[i], list_part_issue_result[i])) {
|
||||
fprintf(stderr, "[ ERROR ] --- %s --- \"%s\" != \"%s\"\n", list_part[0], list_part_cs_result[i], list_part_issue_result[i]);
|
||||
if ((strstr(cs_result, tmptmp)) == NULL) {
|
||||
fprintf(stderr, "[ ERROR ] --- %s --- \"%s\" not in \"%s\"\n", list_part[0], list_part_issue_result[i], cs_result);
|
||||
cs_free(insn, count);
|
||||
free_strs(list_part, size_part);
|
||||
free_strs(list_byte, size_byte);
|
||||
free(cs_result);
|
||||
free_strs(list_part_cs_result, size_part_cs_result);
|
||||
// free_strs(list_part_cs_result, size_part_cs_result);
|
||||
free_strs(list_part_issue_result, size_part_issue_result);
|
||||
|
||||
free(tmptmp);
|
||||
_fail(__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
@ -362,6 +359,6 @@ void test_single_issue(csh *handle, cs_mode mode, char *line, int detail)
|
|||
free_strs(list_part, size_part);
|
||||
free_strs(list_byte, size_byte);
|
||||
free(cs_result);
|
||||
free_strs(list_part_cs_result, size_part_cs_result);
|
||||
// free_strs(list_part_cs_result, size_part_cs_result);
|
||||
free_strs(list_part_issue_result, size_part_issue_result);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ static void print_string_hex(char **result, const char *comment, unsigned char *
|
|||
|
||||
add_str(result, "%s", comment);
|
||||
for (c = str; c < str + len; c++) {
|
||||
add_str(result, "0x%02x ", *c & 0xff);
|
||||
add_str(result, "0x%02x", *c & 0xff);
|
||||
if (c < str + len - 1)
|
||||
add_str(result, " ");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue