cstest: rename some functions for better consistency
This commit is contained in:
parent
3d0b535cad
commit
a7943c960f
|
@ -51,10 +51,10 @@ extern single_dict modes[];
|
|||
extern double_dict options[];
|
||||
extern char *(*function)(csh *, cs_mode, cs_insn*);
|
||||
|
||||
int getIndex(double_dict d[], unsigned size, const char *str);
|
||||
int getValue(single_dict d[], unsigned size, const char *str);
|
||||
int get_index(double_dict d[], unsigned size, const char *str);
|
||||
int get_value(single_dict d[], unsigned size, const char *str);
|
||||
void test_single_MC(csh *handle, char *line);
|
||||
void test_single_issue(csh *handle, cs_mode mode, char *line, int detail);
|
||||
int setFunction(int arch);
|
||||
int set_function(int arch);
|
||||
|
||||
#endif /* CAPSTONE_TEST_H */
|
||||
|
|
|
@ -10,12 +10,13 @@
|
|||
|
||||
char **split(char *str, char *delim, int *size);
|
||||
void print_strs(char **list_str, int size);
|
||||
char *readfile(const char *filename);
|
||||
void free_strs(char **list_str, int size);
|
||||
void add_str(char **src, const char *format, ...);
|
||||
void replaceHex(char **src);
|
||||
void listdir(const char *name, char ***files, int *num_files);
|
||||
void trim_str(char **str);
|
||||
void replace_hex(char **src);
|
||||
const char *get_filename_ext(const char *filename);
|
||||
void trimwhitespace(char **str);
|
||||
|
||||
char *readfile(const char *filename);
|
||||
void listdir(const char *name, char ***files, int *num_files);
|
||||
|
||||
#endif /* HELPER_H */
|
||||
|
|
|
@ -147,11 +147,11 @@ void test_single_MC(csh *handle, char *line)
|
|||
}
|
||||
// printf("--------\nCapstone: %s\nUser: %s\n", tmp, list_data[i]);
|
||||
tmptmp = strdup(tmp);
|
||||
replaceHex(&tmp);
|
||||
replace_hex(&tmp);
|
||||
// assert_string_equal(tmp, list_data[i]);
|
||||
trimwhitespace(&tmp);
|
||||
trimwhitespace(&tmptmp);
|
||||
trimwhitespace(&list_data[i]);
|
||||
trim_str(&tmp);
|
||||
trim_str(&tmptmp);
|
||||
trim_str(&list_data[i]);
|
||||
if (!triple_compare(tmp, tmptmp, list_data[i]))
|
||||
_fail(__FILE__, __LINE__);
|
||||
free(tmp);
|
||||
|
@ -163,7 +163,7 @@ void test_single_MC(csh *handle, char *line)
|
|||
free(list_data);
|
||||
}
|
||||
|
||||
int getValue(single_dict d[], unsigned int size, const char *str)
|
||||
int get_value(single_dict d[], unsigned int size, const char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -173,7 +173,7 @@ int getValue(single_dict d[], unsigned int size, const char *str)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int getIndex(double_dict d[], unsigned int size, const char *s)
|
||||
int get_index(double_dict d[], unsigned int size, const char *s)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -184,7 +184,7 @@ int getIndex(double_dict d[], unsigned int size, const char *s)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int setFunction(int arch)
|
||||
int set_function(int arch)
|
||||
{
|
||||
switch(arch) {
|
||||
case CS_ARCH_ARM:
|
||||
|
@ -299,8 +299,8 @@ void test_single_issue(csh *handle, cs_mode mode, char *line, int detail)
|
|||
_fail(__FILE__, __LINE__);
|
||||
}
|
||||
for (i=0; i<size_part_cs_result; ++i) {
|
||||
trimwhitespace(&list_part_cs_result[i]);
|
||||
trimwhitespace(&list_part_issue_result[i]);
|
||||
trim_str(&list_part_cs_result[i]);
|
||||
trim_str(&list_part_issue_result[i]);
|
||||
assert_string_equal(list_part_cs_result[i], list_part_issue_result[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ void add_str(char **src, const char *format, ...)
|
|||
free(tmp);
|
||||
}
|
||||
|
||||
void replaceHex(char **src)
|
||||
void replace_hex(char **src)
|
||||
{
|
||||
char *tmp, *result, *found;
|
||||
int i;
|
||||
|
@ -158,7 +158,7 @@ void listdir(const char *name, char ***files, int *num_files)
|
|||
closedir(dir);
|
||||
}
|
||||
|
||||
void trimwhitespace(char **str)
|
||||
void trim_str(char **str)
|
||||
{
|
||||
char *end;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ static int setup_MC(void **state)
|
|||
return -1;
|
||||
|
||||
list_params = split(list_lines[0], ", ", &size_params);
|
||||
arch = getValue(arches, NUMARCH, list_params[0]);
|
||||
mode = getValue(modes, NUMMODE, list_params[1]);
|
||||
arch = get_value(arches, NUMARCH, list_params[0]);
|
||||
mode = get_value(modes, NUMMODE, list_params[1]);
|
||||
|
||||
if (arch == -1 || mode == -1) {
|
||||
printf("[-] Arch and/or Mode are not supported!\n");
|
||||
|
@ -35,7 +35,7 @@ static int setup_MC(void **state)
|
|||
cs_open(arch, mode, handle);
|
||||
for (i=2; i < size_params; ++i)
|
||||
if (strcmp(list_params[i], "None")) {
|
||||
index = getIndex(options, NUMOPTION, list_params[i]);
|
||||
index = get_index(options, NUMOPTION, list_params[i]);
|
||||
if (index == -1) {
|
||||
printf("[-] Option is not supported!\n");
|
||||
failed_setup = 1;
|
||||
|
@ -80,8 +80,8 @@ static int setup_issue(void **state)
|
|||
|
||||
list_params = split(list_lines[counter] + 2, ", ", &size_params);
|
||||
// print_strs(list_params, size_params);
|
||||
arch = getValue(arches, NUMARCH, list_params[0]);
|
||||
mode = getValue(modes, NUMMODE, list_params[1]);
|
||||
arch = get_value(arches, NUMARCH, list_params[0]);
|
||||
mode = get_value(modes, NUMMODE, list_params[1]);
|
||||
|
||||
if (arch == -1 || mode == -1) {
|
||||
printf("[-] Arch and/or Mode are not supported!\n");
|
||||
|
@ -94,14 +94,14 @@ static int setup_issue(void **state)
|
|||
cs_open(arch, mode, handle);
|
||||
for (i=2; i < size_params; ++i)
|
||||
if (strcmp(list_params[i], "None")) {
|
||||
index = getIndex(options, NUMOPTION, list_params[i]);
|
||||
index = get_index(options, NUMOPTION, list_params[i]);
|
||||
if (index == -1) {
|
||||
printf("[-] Option is not supported!\n");
|
||||
failed_setup = 1;
|
||||
return -1;
|
||||
}
|
||||
if (index == 0) {
|
||||
result = setFunction(arch);
|
||||
result = set_function(arch);
|
||||
if (result == -1) {
|
||||
printf("[-] Cannot get details\n");
|
||||
failed_setup = 1;
|
||||
|
|
Loading…
Reference in New Issue