Rizin
unix-like reverse engineering framework and cli tools
|
#include "rz_test.h"
#include <assert.h>
#include <rz_cons.h>
#include <rz_main.h>
#include <rz_windows.h>
Go to the source code of this file.
Classes | |
struct | rz_testfile_counts_t |
struct | rz_test_state_t |
Macros | |
#define | Color_INSERT Color_BGREEN |
#define | Color_DELETE Color_BRED |
#define | Color_BGINSERT "\x1b[48;5;22m" |
#define | Color_BGDELETE "\x1b[48;5;52m" |
#define | Color_HLINSERT Color_BGINSERT Color_INSERT |
#define | Color_HLDELETE Color_BGDELETE Color_DELETE |
#define | WORKERS_DEFAULT 8 |
#define | RIZIN_CMD_DEFAULT "rizin" |
#define | RZ_ASM_CMD_DEFAULT "rz-asm" |
#define | JSON_TEST_FILE_DEFAULT "bins/elf/crackme0x00b" |
#define | TIMEOUT_DEFAULT 960 |
#define | STRV(x) #x |
#define | STR(x) STRV(x) |
#define | WORKERS_DEFAULT_STR STR(WORKERS_DEFAULT) |
#define | TIMEOUT_DEFAULT_STR STR(TIMEOUT_DEFAULT) |
#define | DO_KEY_STR(key, field) |
#define | DO_KEY_BOOL(key, field) |
#define | DO_KEY_NUM(key, field) |
Typedefs | |
typedef struct rz_testfile_counts_t | RzTestFileCounts |
typedef struct rz_test_state_t | RzTestState |
Functions | |
static void * | worker_th (RzTestState *state) |
static void | print_state (RzTestState *state, ut64 prev_completed) |
static void | print_log (RzTestState *state, ut64 prev_completed, ut64 prev_paths_completed) |
static void | interact (RzTestState *state) |
static bool | interact_fix (RzTestResultInfo *result, RzPVector *fixup_results) |
static void | interact_break (RzTestResultInfo *result, RzPVector *fixup_results) |
static void | interact_commands (RzTestResultInfo *result, RzPVector *fixup_results) |
static int | help (bool verbose) |
static void | path_left_free_kv (HtPPKv *kv) |
static bool | rz_test_chdir (const char *argv0) |
static bool | rz_test_test_run_unit (void) |
static bool | rz_test_chdir_fromtest (const char *test_path) |
int | rz_test_main (int argc, const char **argv) |
static void | test_result_to_json (PJ *pj, RzTestResultInfo *result) |
static void | print_diff (const char *actual, const char *expected, const char *regexp) |
static RzSubprocessOutput * | print_runner (const char *file, const char *args[], size_t args_size, const char *envvars[], const char *envvals[], size_t env_size, ut64 timeout_ms, void *user) |
static void | print_result_diff (RzTestRunConfig *config, RzTestResultInfo *result) |
static void | print_new_results (RzTestState *state, ut64 prev_completed) |
static void | print_state_counts (RzTestState *state) |
static char * | format_cmd_kv (const char *key, const char *val) |
static char * | replace_lines (const char *src, size_t from, size_t to, const char *news) |
static void | fixup_tests (RzPVector *results, const char *edited_file, ut64 start_line, st64 delta) |
static char * | read_test_file_for_fix (const char *path) |
static void | save_test_file_for_fix (const char *path, const char *newc) |
static char * | replace_cmd_kv (const char *path, const char *content, size_t line_begin, size_t line_end, const char *key, const char *value, RzPVector *fixup_results) |
static void | replace_cmd_kv_file (const char *path, ut64 line_begin, ut64 line_end, const char *key, const char *value, RzPVector *fixup_results) |
static bool | interact_fix_cmd (RzTestResultInfo *result, RzPVector *fixup_results) |
static void | replace_file_line (const char *path, ut64 line_idx, const char *line_new) |
static void | replace_asm_test (RZ_NONNULL const char *path, ut64 line_idx, int mode, RZ_NONNULL const char *disasm, RZ_NONNULL const ut8 *bytes, size_t bytes_sz, ut64 offset, RZ_NULLABLE const char *il) |
static bool | asm_test_failed_both_ways (RzAsmTest *test, RzAsmTestOutput *out) |
static bool | interact_fix_asm (RzTestResultInfo *result) |
static void | interact_break_cmd (RzTestResultInfo *result, RzPVector *fixup_results) |
static void | interact_break_asm (RzTestResultInfo *result) |
int | MAIN_NAME (int argc, const ARGV_TYPE **argv) |
Variables | |
static bool | log_mode = false |
#define Color_DELETE Color_BRED |
#define Color_HLDELETE Color_BGDELETE Color_DELETE |
#define Color_HLINSERT Color_BGINSERT Color_INSERT |
#define Color_INSERT Color_BGREEN |
#define DO_KEY_BOOL | ( | key, | |
field | |||
) |
#define DO_KEY_NUM | ( | key, | |
field | |||
) |
#define DO_KEY_STR | ( | key, | |
field | |||
) |
#define TIMEOUT_DEFAULT_STR STR(TIMEOUT_DEFAULT) |
#define WORKERS_DEFAULT_STR STR(WORKERS_DEFAULT) |
typedef struct rz_testfile_counts_t RzTestFileCounts |
typedef struct rz_test_state_t RzTestState |
|
static |
Check if both assembly and disassembly passes failed, making it non-trivial to repair automatically.
Definition at line 1228 of file rz-test.c.
References out, and RZ_ASM_TEST_MODE_ASSEMBLE.
Referenced by interact_fix_asm().
|
static |
Definition at line 1078 of file rz-test.c.
References rz_test_test_t::cmd_test, delta, DO_KEY_BOOL, DO_KEY_NUM, DO_KEY_STR, rz_test_test_t::path, RZ_CMD_TEST_FOREACH_RECORD, rz_pvector_foreach, RZ_TEST_TYPE_CMD, rz_test_test_result_info_t::test, and rz_test_test_t::type.
Referenced by replace_cmd_kv().
Definition at line 1029 of file rz-test.c.
References key, rz_strbuf_append(), rz_strbuf_appendf(), rz_strbuf_drain_nofree(), rz_strbuf_init(), and val.
Referenced by replace_cmd_kv().
Definition at line 62 of file rz-test.c.
References JSON_TEST_FILE_DEFAULT, printf(), RIZIN_CMD_DEFAULT, RZ_ASM_CMD_DEFAULT, RZ_TEST_ARCH_OS, TIMEOUT_DEFAULT_STR, verbose, and WORKERS_DEFAULT_STR.
Referenced by rz_test_main().
|
static |
Definition at line 953 of file rz-test.c.
References interact_break(), interact_commands(), interact_fix(), NULL, PFMT64u, print_result_diff(), printf(), rz_test_test_result_info_t::result, rz_pvector_clear(), rz_pvector_empty(), rz_pvector_foreach, rz_pvector_init(), rz_pvector_len(), rz_pvector_push(), RZ_TEST_RESULT_FAILED, RZ_TEST_TYPE_ASM, RZ_TEST_TYPE_CMD, rz_test_test_result_info_t::test, rz_test_test_t::type, ut64(), UTF8_DOOR, UTF8_KEYBOARD, UTF8_POLICE_CARS_REVOLVING_LIGHT, UTF8_SEE_NO_EVIL_MONKEY, UTF8_SKULL_AND_CROSSBONES, UTF8_VS16, and UTF8_WHITE_HEAVY_CHECK_MARK.
Referenced by rz_test_main().
|
static |
Definition at line 1314 of file rz-test.c.
References interact_break_asm(), interact_break_cmd(), RZ_TEST_TYPE_ASM, RZ_TEST_TYPE_CMD, rz_test_test_result_info_t::test, and rz_test_test_t::type.
Referenced by interact().
|
static |
Definition at line 1307 of file rz-test.c.
References rz_test_test_t::asm_test, assert(), rz_test_test_t::path, replace_asm_test(), RZ_ASM_TEST_MODE_BROKEN, RZ_TEST_TYPE_ASM, rz_test_test_result_info_t::test, and rz_test_test_t::type.
Referenced by interact_break().
|
static |
Definition at line 1293 of file rz-test.c.
References assert(), rz_test_test_t::cmd_test, rz_test_test_t::path, replace_cmd_kv_file(), RZ_TEST_TYPE_CMD, rz_test_test_result_info_t::test, rz_test_test_t::type, and ut64().
Referenced by interact_break().
|
static |
Definition at line 1327 of file rz-test.c.
References assert(), close, rz_test_test_t::cmd_test, eprintf, fd, free(), NULL, rz_test_test_t::path, replace_cmd_kv_file(), rz_file_mkstemp(), rz_file_slurp(), rz_str_newf(), rz_str_trim(), rz_sys_cmdf(), rz_sys_getenv(), RZ_TEST_TYPE_CMD, strdup(), rz_test_test_result_info_t::test, autogen_x86imm::tmp, rz_test_test_t::type, and write.
Referenced by interact().
|
static |
Definition at line 1282 of file rz-test.c.
References interact_fix_asm(), interact_fix_cmd(), RZ_TEST_TYPE_ASM, RZ_TEST_TYPE_CMD, rz_test_test_result_info_t::test, and rz_test_test_t::type.
Referenced by interact().
|
static |
Definition at line 1245 of file rz-test.c.
References rz_test_test_result_info_t::asm_out, rz_test_test_t::asm_test, asm_test_failed_both_ways(), assert(), bytes, out, rz_test_test_t::path, replace_asm_test(), RZ_ASM_TEST_MODE_ASSEMBLE, RZ_ASM_TEST_MODE_DISASSEMBLE, RZ_TEST_TYPE_ASM, rz_test_test_result_info_t::test, and rz_test_test_t::type.
Referenced by interact_fix().
|
static |
Definition at line 1170 of file rz-test.c.
References assert(), rz_test_test_t::cmd_test, out, rz_test_test_t::path, rz_test_test_result_info_t::proc_out, replace_cmd_kv_file(), rz_process_output_t::ret, rz_test_test_result_info_t::run_failed, RZ_TEST_TYPE_CMD, rz_test_test_result_info_t::test, and rz_test_test_t::type.
Referenced by interact_fix().
Definition at line 1385 of file rz-test.c.
References argv, ARGV_TYPE_TO_UTF8, FREE_UTF8_ARGV, and rz_test_main().
|
static |
Definition at line 722 of file rz-test.c.
References cleanup(), d, free(), NULL, output, rz_diff_free(), rz_diff_lines_new(), rz_diff_unified_text(), rz_list_free(), rz_list_to_str(), and rz_regex_get_match_list().
Referenced by print_result_diff().
|
static |
Definition at line 929 of file rz-test.c.
References rz_testfile_counts_t::br, rz_testfile_counts_t::fx, NULL, rz_testfile_counts_t::ok, print_new_results(), print_state_counts(), printf(), rz_pvector_at(), rz_pvector_len(), ut64(), and rz_testfile_counts_t::xx.
Referenced by rz_test_main().
|
static |
Definition at line 861 of file rz-test.c.
References Color_BLUE, Color_CYAN, Color_GREEN, Color_RED, Color_RESET, Color_YELLOW, free(), i, rz_test_test_t::path, print_result_diff(), printf(), rz_test_test_result_info_t::result, RZ_CONS_CLEAR_LINE, RZ_CONS_CURSOR_UP, rz_pvector_at(), rz_pvector_len(), RZ_TEST_RESULT_BROKEN, RZ_TEST_RESULT_FAILED, RZ_TEST_RESULT_FIXED, RZ_TEST_RESULT_OK, rz_test_test_name(), rz_test_test_result_info_t::test, test_result_to_json(), rz_test_test_result_info_t::timeout, and ut64().
Referenced by print_log(), and print_state().
|
static |
Definition at line 771 of file rz-test.c.
References rz_test_test_result_info_t::asm_out, rz_test_test_t::asm_test, rz_test_test_t::cmd_test, Color_RED, Color_RESET, Color_YELLOW, err, rz_process_output_t::err, rz_test_cmd_test_t::expect, expect, rz_test_cmd_test_t::expect_err, free(), rz_test_test_t::fuzz_test, if(), NULL, rz_process_output_t::out, out, print_diff(), print_runner(), printf(), rz_test_test_result_info_t::proc_out, rz_test_cmd_test_t::regexp_err, rz_test_cmd_test_t::regexp_out, rz_process_output_t::ret, rz_test_test_result_info_t::run_failed, RZ_ASM_TEST_MODE_ASSEMBLE, RZ_ASM_TEST_MODE_DISASSEMBLE, rz_hex_bin2strdup(), rz_test_cmp_cmd_output(), rz_test_run_cmd_test(), rz_test_run_fuzz_test(), RZ_TEST_TYPE_ASM, RZ_TEST_TYPE_CMD, RZ_TEST_TYPE_FUZZ, RZ_TEST_TYPE_JSON, rz_test_test_result_info_t::test, rz_test_test_t::type, and rz_test_cmd_test_string_record::value.
Referenced by interact(), and print_new_results().
|
static |
Definition at line 752 of file rz-test.c.
References args, i, NULL, printf(), and cmd_descs_generate::str.
Referenced by print_result_diff().
|
static |
Definition at line 908 of file rz-test.c.
References NULL, PFMT64u, print_new_results(), print_state_counts(), printf(), RZ_CONS_CLEAR_LINE, rz_pvector_len(), ut64(), and w.
Referenced by rz_test_main().
|
static |
|
static |
Definition at line 1118 of file rz-test.c.
References eprintf, NULL, path, and rz_file_slurp().
Referenced by replace_cmd_kv_file(), and replace_file_line().
|
static |
Definition at line 1200 of file rz-test.c.
References bytes, free(), hex, setup::line, path, PFMT64x, replace_file_line(), RZ_ASM_TEST_MODE_ASSEMBLE, RZ_ASM_TEST_MODE_BIG_ENDIAN, RZ_ASM_TEST_MODE_BROKEN, RZ_ASM_TEST_MODE_DISASSEMBLE, rz_hex_bin2strdup(), rz_str_newf(), and snprintf.
Referenced by interact_break_asm(), and interact_fix_asm().
|
static |
Definition at line 1136 of file rz-test.c.
References delta, fixup_tests(), format_cmd_kv(), free(), key, NULL, path, replace_lines(), rz_str_char_count(), st64, and value.
Referenced by replace_cmd_kv_file().
|
static |
Definition at line 1156 of file rz-test.c.
References free(), key, path, read_test_file_for_fix(), replace_cmd_kv(), save_test_file_for_fix(), and value.
Referenced by interact_break_cmd(), interact_commands(), and interact_fix_cmd().
Definition at line 1186 of file rz-test.c.
References free(), path, read_test_file_for_fix(), replace_lines(), and save_test_file_for_fix().
Referenced by replace_asm_test().
Definition at line 1041 of file rz-test.c.
References test_evm::end, from, setup::line, NULL, rz_strbuf_append(), rz_strbuf_append_n(), rz_strbuf_drain_nofree(), rz_strbuf_init(), src, and to.
Referenced by replace_cmd_kv(), and replace_file_line().
Definition at line 96 of file rz-test.c.
References chdir, eprintf, found, free(), p, readlink, rz_file_is_directory(), rz_file_path(), and RZ_SYS_DIR.
Referenced by rz_test_main().
Definition at line 135 of file rz-test.c.
References chdir, test-lz4-speed::cwd, eprintf, found, free(), NULL, rz_file_abspath(), rz_file_is_directory(), rz_str_lchr(), rz_sys_chdir(), RZ_SYS_DIR, and rz_sys_getdir().
Referenced by rz_test_main().
Definition at line 187 of file rz-test.c.
References rz_getopt_t::arg, argv, c, calloc(), chdir, test-lz4-speed::cwd, DWORD, ENABLE_VIRTUAL_TERMINAL_PROCESSING, eprintf, test-lz4-list::exit, free(), HANDLE, help(), i, rz_getopt_t::ind, interact(), JSON_TEST_FILE_DEFAULT, log_mode, nothing(), NULL, p, path_left_free_kv(), PFMT64u, pj_a(), pj_drain(), pj_end(), pj_new(), print_log(), print_state(), printf(), RIZIN_CMD_DEFAULT, RZ_ARRAY_SIZE, RZ_ASM_CMD_DEFAULT, rz_file_abspath_rel(), rz_file_dump(), rz_file_is_abspath(), rz_file_path(), RZ_FREE, rz_getopt_init(), rz_getopt_next(), RZ_LOG_ERROR, rz_num_is_valid_input(), rz_num_math(), rz_pvector_at(), rz_pvector_clear(), rz_pvector_empty(), rz_pvector_foreach, rz_pvector_free(), rz_pvector_init(), rz_pvector_insert_range(), rz_pvector_len(), rz_pvector_new(), rz_pvector_push(), rz_pvector_remove_at(), rz_str_newf(), rz_str_startswith(), rz_str_version(), rz_subprocess_fini(), rz_subprocess_init(), rz_sys_cmdf(), rz_sys_getdir(), rz_sys_setenv(), rz_test_chdir(), rz_test_chdir_fromtest(), rz_test_check_jq_available(), rz_test_test_database_free(), rz_test_test_database_load(), rz_test_test_database_load_fuzz(), rz_test_test_database_new(), rz_test_test_free(), rz_test_test_result_info_free(), rz_test_test_run_unit(), RZ_TEST_TYPE_JSON, rz_th_cond_free(), rz_th_cond_new(), rz_th_cond_wait(), rz_th_free(), rz_th_lock_enter(), rz_th_lock_free(), rz_th_lock_leave(), rz_th_lock_new(), rz_th_new(), rz_th_wait(), rz_time_now_mono(), RZ_VERSION, s, st64, strdup(), streams, rz_testfile_counts_t::tests_left, TIMEOUT_DEFAULT, autogen_x86imm::tmp, ut64(), UT64_MAX, verbose, worker_th(), workers, and WORKERS_DEFAULT.
Referenced by MAIN_NAME().
|
static |
Definition at line 1126 of file rz-test.c.
References eprintf, path, and rz_file_dump().
Referenced by replace_cmd_kv_file(), and replace_file_line().
|
static |
Definition at line 618 of file rz-test.c.
References pj_end(), pj_k(), pj_kb(), pj_ki(), pj_kn(), pj_ks(), pj_o(), pj_s(), rz_test_test_result_info_t::result, rz_test_test_result_info_t::run_failed, rz_return_if_fail, RZ_TEST_RESULT_BROKEN, RZ_TEST_RESULT_FAILED, RZ_TEST_RESULT_FIXED, RZ_TEST_RESULT_OK, RZ_TEST_TYPE_ASM, RZ_TEST_TYPE_CMD, RZ_TEST_TYPE_FUZZ, RZ_TEST_TYPE_JSON, rz_test_test_result_info_t::test, rz_test_test_result_info_t::time_elapsed, and rz_test_test_result_info_t::timeout.
Referenced by print_new_results().
|
static |
Definition at line 664 of file rz-test.c.
References rz_testfile_counts_t::br, rz_testfile_counts_t::fx, log_mode, NULL, rz_testfile_counts_t::ok, rz_test_test_result_info_t::result, rz_pvector_empty(), rz_pvector_pop(), rz_pvector_push(), RZ_TEST_RESULT_BROKEN, RZ_TEST_RESULT_FAILED, RZ_TEST_RESULT_FIXED, RZ_TEST_RESULT_OK, rz_test_run_test(), rz_th_cond_signal(), rz_th_lock_enter(), rz_th_lock_leave(), rz_testfile_counts_t::tests_left, and rz_testfile_counts_t::xx.
Referenced by rz_test_main().
Definition at line 185 of file rz-test.c.
Referenced by rz_test_main(), and worker_th().