fixing
This commit is contained in:
parent
f649fe4a2e
commit
9f51a86ba3
|
@ -33,18 +33,19 @@ def get_report_file(toolpath, filepath, getDetails):
|
|||
elif 'LINE' in line:
|
||||
continue
|
||||
elif 'ERROR' in line and ' --- ' in line:
|
||||
parts = line.split(' --- ')
|
||||
try:
|
||||
details.append((failed_tests[counter], line.split(' --- ')[1]))
|
||||
details.append((parts[1], failed_tests[counter], parts[2]))
|
||||
except IndexError:
|
||||
details.append(('Unknown test', line.split(' --- ')[1]))
|
||||
details.append(('', 'Unknown test', line.split(' --- ')[1]))
|
||||
counter += 1
|
||||
else:
|
||||
continue
|
||||
print '\n[-] There are/is {} failed test(s)'.format(len(details))
|
||||
if len(details) > 0 and getDetails:
|
||||
print '[-] Detailed report for {}:\n'.format(filepath)
|
||||
for f, d in details:
|
||||
print '\t[+] {}:\n\t\t{}\n'.format(f, d)
|
||||
for c, f, d in details:
|
||||
print '\t[+] {}: {}\n\t\t{}\n'.format(f, c, d)
|
||||
print '\n'
|
||||
|
||||
def get_report_folder(toolpath, folderpath, details):
|
||||
|
|
|
@ -84,14 +84,14 @@ double_dict options[] = {
|
|||
|
||||
char *(*function)(csh *, cs_mode, cs_insn*) = NULL;
|
||||
|
||||
static int quadruple_compare(const char *src1, const char *src2, const char *des1, const char *des2)
|
||||
static int quadruple_compare(const char *src1, const char *src2, const char *des1, const char *des2, const char *opcode)
|
||||
{
|
||||
if (strcmp(src1, des2) && strcmp(src2, des2) && strcmp(src1, des1) && strcmp(src1, des2)) {
|
||||
fprintf(stderr,"[ ERROR ] --- \"%s\" != \"%s\"", src1, des2);
|
||||
fprintf(stderr,"[ ERROR ] --- %s --- \"%s\" != \"%s\"", src2, des2, opcode);
|
||||
if (strcmp(src1, src2))
|
||||
fprintf(stderr, " (\"%s\" != \"%s\")", src2, des2);
|
||||
fprintf(stderr, " (\"%s\" != \"%s\")", src1, des2);
|
||||
else if (strcmp(des1, des2))
|
||||
fprintf(stderr, " (\"%s\" != \"%s\")", src1, des1);
|
||||
fprintf(stderr, " (\"%s\" != \"%s\")", src2, des1);
|
||||
fprintf(stderr, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -133,11 +133,11 @@ void test_single_MC(csh *handle, char *line)
|
|||
// printf("====\nCount: %d\nSize_data: %d\n", count, size_data);
|
||||
// assert_int_equal(size_data, count);
|
||||
if (count == 0) {
|
||||
fprintf(stderr, "[ ERROR ] --- Failed to disassemble given code!\n");
|
||||
fprintf(stderr, "[ ERROR ] --- %s --- Failed to disassemble given code!\n", list_part[0]);
|
||||
_fail(__FILE__, __LINE__);
|
||||
}
|
||||
if (count > 1) {
|
||||
fprintf(stderr, "[ ERROR ] --- Multiple instructions(%d) disassembling doesn't support!\n", count);
|
||||
fprintf(stderr, "[ ERROR ] --- %s --- Multiple instructions(%d) disassembling doesn't support!\n", list_part[0], count);
|
||||
_fail(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ void test_single_MC(csh *handle, char *line)
|
|||
// assert_string_equal(tmp, list_data[i]);
|
||||
|
||||
|
||||
if (cs_option(*handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_NOREGNAME) == CS_ERR_OK) {
|
||||
if ( cs_option(*handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_NOREGNAME) == CS_ERR_OK ) {
|
||||
count_noreg = cs_disasm(*handle, code, size_byte, offset, 0, &insn);
|
||||
tmp_noreg = (char *)malloc(strlen(insn[0].mnemonic) + strlen(insn[0].op_str) + 100);
|
||||
strcpy(tmp_noreg, insn[0].mnemonic);
|
||||
|
@ -177,7 +177,7 @@ void test_single_MC(csh *handle, char *line)
|
|||
|
||||
if (strcmp(tmp, mc_hex) && strcmp(cs_hex, mc_hex) && strcmp(tmp, mc_dec) && strcmp(tmp, mc_hex)
|
||||
&& strcmp(tmp_noreg, mc_hex_noreg) && strcmp(cs_hex_noreg, mc_hex_noreg) && strcmp(tmp_noreg, mc_dec_noreg) && strcmp(tmp_noreg, mc_hex_noreg)) {
|
||||
fprintf(stderr, "[ ERROR ] --- \"%s\" != \"%s\"\n", tmp, list_data[0]);
|
||||
fprintf(stderr, "[ ERROR ] --- %s --- \"%s\" != \"%s\"\n", list_part[0], cs_hex, list_data[0]);
|
||||
_fail(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,8 @@ void test_single_MC(csh *handle, char *line)
|
|||
free(mc_dec_noreg);
|
||||
|
||||
cs_option(*handle, CS_OPT_SYNTAX, 0);
|
||||
} else if (!quadruple_compare(tmp, cs_hex, mc_dec, mc_hex))
|
||||
}
|
||||
else if (!quadruple_compare(tmp, cs_hex, mc_dec, mc_hex, list_part[0]))
|
||||
_fail(__FILE__, __LINE__);
|
||||
|
||||
free(tmp);
|
||||
|
@ -335,7 +336,7 @@ void test_single_issue(csh *handle, cs_mode mode, char *line, int detail)
|
|||
list_part_issue_result = split(list_part[1], " ; ", &size_part_issue_result);
|
||||
|
||||
if (size_part_cs_result != size_part_issue_result) {
|
||||
fprintf(stderr, "[ ERROR ] --- Number of details doesn't match\n");
|
||||
fprintf(stderr, "[ ERROR ] --- %s --- Number of details doesn't match\n", list_part[0]);
|
||||
_fail(__FILE__, __LINE__);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,14 +15,17 @@ static int setup_MC(void **state)
|
|||
char **list_params;
|
||||
int size_params;
|
||||
int arch, mode;
|
||||
int i, index;
|
||||
int i, index, tmp_counter;
|
||||
|
||||
if (failed_setup) {
|
||||
fprintf(stderr, "[ ERROR ] --- Invalid file to setup\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
list_params = split(list_lines[0], ", ", &size_params);
|
||||
tmp_counter = 0;
|
||||
while (tmp_counter < size_lines && list_lines[tmp_counter][0] != '#') tmp_counter++; // get issue line
|
||||
|
||||
list_params = split(list_lines[tmp_counter] + 2, ", ", &size_params);
|
||||
arch = get_value(arches, NUMARCH, list_params[0]);
|
||||
mode = get_value(modes, NUMMODE, list_params[1]);
|
||||
|
||||
|
@ -46,7 +49,8 @@ static int setup_MC(void **state)
|
|||
cs_option(*handle, options[index].first_value, options[index].second_value);
|
||||
}
|
||||
*state = (void *)handle;
|
||||
counter ++;
|
||||
counter++;
|
||||
while (counter < size_lines && list_lines[counter][0] != '0') counter++;
|
||||
free_strs(list_params, size_params);
|
||||
return 0;
|
||||
}
|
||||
|
@ -169,15 +173,20 @@ static void test_file(const char *filename)
|
|||
}
|
||||
_cmocka_run_group_tests("Testing issues", tests, number_of_tests, NULL, NULL);
|
||||
} else {
|
||||
list_lines = split(content + 2, "\n", &size_lines);
|
||||
number_of_tests = size_lines - 1;
|
||||
list_lines = split(content, "\n", &size_lines);
|
||||
number_of_tests = 0;
|
||||
|
||||
tests = (struct CMUnitTest *)malloc(sizeof(struct CMUnitTest) * (size_lines - 1));
|
||||
tests = NULL;
|
||||
// tests = (struct CMUnitTest *)malloc(sizeof(struct CMUnitTest) * (size_lines - 1));
|
||||
for (i=0; i < size_lines - 1; ++i) {
|
||||
char *tmp = (char *)malloc(sizeof(char) * 100);
|
||||
sprintf(tmp, "Line %d", i+2);
|
||||
tests[i] = (struct CMUnitTest)cmocka_unit_test_setup_teardown(test_MC, setup_MC, teardown_MC);
|
||||
tests[i].name = tmp;
|
||||
if (list_lines[i][0] == '#' || list_lines[i][0] == '0') {
|
||||
char *tmp = (char *)malloc(sizeof(char) * 100);
|
||||
sprintf(tmp, "Line %d", i+2);
|
||||
tests = (struct CMUnitTest *)realloc(tests, sizeof(struct CMUnitTest) * (number_of_tests + 1));
|
||||
tests[number_of_tests] = (struct CMUnitTest)cmocka_unit_test_setup_teardown(test_MC, setup_MC, teardown_MC);
|
||||
tests[number_of_tests].name = tmp;
|
||||
number_of_tests ++;
|
||||
}
|
||||
}
|
||||
_cmocka_run_group_tests("Testing", tests, size_lines-1, NULL, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue