aboutsummaryrefslogtreecommitdiffstats
path: root/capstone/suite/cstest/include
diff options
context:
space:
mode:
Diffstat (limited to 'capstone/suite/cstest/include')
-rw-r--r--capstone/suite/cstest/include/capstone_test.h62
-rw-r--r--capstone/suite/cstest/include/factory.h27
-rw-r--r--capstone/suite/cstest/include/helper.h32
3 files changed, 121 insertions, 0 deletions
diff --git a/capstone/suite/cstest/include/capstone_test.h b/capstone/suite/cstest/include/capstone_test.h
new file mode 100644
index 000000000..5936678f0
--- /dev/null
+++ b/capstone/suite/cstest/include/capstone_test.h
@@ -0,0 +1,62 @@
+/* Capstone testing regression */
+/* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
+
+
+#ifndef CAPSTONE_TEST_H
+#define CAPSTONE_TEST_H
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+#include <stdlib.h>
+#include <string.h>
+#include <capstone/capstone.h>
+#include "helper.h"
+#include "factory.h"
+
+#define cs_assert_err(expect, err) \
+ do { \
+ cs_err __err = err; \
+ if (__err != expect) { \
+ fail_msg("%s",cs_strerror(__err)); \
+ } \
+ } while (0)
+
+
+#define cs_assert_success(err) cs_assert_err(CS_ERR_OK, err)
+
+
+#define cs_assert_fail(err) \
+ do { \
+ cs_err __err = err; \
+ if (__err == CS_ERR_OK) { \
+ fail_msg("%s",cs_strerror(__err)); \
+ } \
+ } while (0)
+
+#define NUMARCH 10
+#define NUMMODE 35
+#define NUMOPTION 41
+#define MAXMEM 1024
+
+typedef struct {
+ const char *str;
+ unsigned int value;
+} single_dict;
+
+typedef struct {
+ const char *str;
+ unsigned int first_value;
+ unsigned int second_value;
+} double_dict;
+
+extern char *(*function)(csh *, cs_mode, cs_insn*);
+
+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, int mc_mode, char *line);
+void test_single_issue(csh *handle, cs_mode mode, char *line, int detail);
+int set_function(int arch);
+
+#endif /* CAPSTONE_TEST_H */
diff --git a/capstone/suite/cstest/include/factory.h b/capstone/suite/cstest/include/factory.h
new file mode 100644
index 000000000..7df6c7838
--- /dev/null
+++ b/capstone/suite/cstest/include/factory.h
@@ -0,0 +1,27 @@
+/* Capstone testing regression */
+/* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
+
+
+#ifndef FACTORY_H
+#define FACTORY_H
+
+#include <capstone/capstone.h>
+#include "helper.h"
+
+char *get_detail_evm(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_arm(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_arm64(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_m680x(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_mips(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_ppc(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_sparc(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_sysz(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_x86(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_xcore(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_riscv(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_m68k(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_mos65xx(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_tms320c64x(csh *handle, cs_mode mode, cs_insn *ins);
+char *get_detail_bpf(csh *handle, cs_mode mode, cs_insn *ins);
+
+#endif /* FACTORY_H */
diff --git a/capstone/suite/cstest/include/helper.h b/capstone/suite/cstest/include/helper.h
new file mode 100644
index 000000000..102230385
--- /dev/null
+++ b/capstone/suite/cstest/include/helper.h
@@ -0,0 +1,32 @@
+/* Capstone testing regression */
+/* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
+
+
+#ifndef HELPER_H
+#define HELPER_H
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <dirent.h>
+#include "capstone_test.h"
+
+#define X86_16 0
+#define X86_32 1
+#define X86_64 2
+
+char **split(char *str, char *delim, int *size);
+void print_strs(char **list_str, int size);
+void free_strs(char **list_str, int size);
+void add_str(char **src, const char *format, ...);
+void trim_str(char *src);
+void replace_hex(char *src);
+void replace_negative(char *src, int mode);
+const char *get_filename_ext(const char *filename);
+
+char *readfile(const char *filename);
+void listdir(const char *name, char ***files, int *num_files);
+
+#endif /* HELPER_H */