mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
Remove the -r and -m flags from r2r ##tests
This commit is contained in:
parent
5054382ec2
commit
dca683e59c
@ -3,8 +3,6 @@
|
||||
#include "r2r.h"
|
||||
|
||||
#define WORKERS_DEFAULT 8
|
||||
#define RADARE2_CMD_DEFAULT "radare2"
|
||||
#define RASM2_CMD_DEFAULT "rasm2"
|
||||
#define JSON_TEST_FILE_DEFAULT "bins/elf/crackme0x00b"
|
||||
// 30 seconds is the maximum time a test can run
|
||||
#define TIMEOUT_DEFAULT (30*60)
|
||||
@ -32,6 +30,15 @@ typedef struct r2r_state_t {
|
||||
RPVector results;
|
||||
} R2RState;
|
||||
|
||||
static RThreadFunctionRet worker_th(RThread *th);
|
||||
static void print_state(R2RState *state, ut64 prev_completed);
|
||||
static void print_log(R2RState *state, ut64 prev_completed, ut64 prev_paths_completed);
|
||||
static void interact(R2RState *state);
|
||||
static void interact_fix(R2RTestResultInfo *result, RPVector *fixup_results);
|
||||
static void interact_break(R2RTestResultInfo *result, RPVector *fixup_results);
|
||||
static void interact_commands(R2RTestResultInfo *result, RPVector *fixup_results);
|
||||
static void interact_diffchar(R2RTestResultInfo *result);
|
||||
|
||||
static void parse_skip(const char *arg) {
|
||||
if (strstr (arg, "arch")) {
|
||||
r_sys_setenv ("R2R_SKIP_ARCHOS", "1");
|
||||
@ -50,15 +57,6 @@ static void parse_skip(const char *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
static RThreadFunctionRet worker_th(RThread *th);
|
||||
static void print_state(R2RState *state, ut64 prev_completed);
|
||||
static void print_log(R2RState *state, ut64 prev_completed, ut64 prev_paths_completed);
|
||||
static void interact(R2RState *state);
|
||||
static void interact_fix(R2RTestResultInfo *result, RPVector *fixup_results);
|
||||
static void interact_break(R2RTestResultInfo *result, RPVector *fixup_results);
|
||||
static void interact_commands(R2RTestResultInfo *result, RPVector *fixup_results);
|
||||
static void interact_diffchar(R2RTestResultInfo *result);
|
||||
|
||||
static int help(bool verbose) {
|
||||
printf ("Usage: r2r [-qvVnL] [-j threads] [test file/dir | @test-type]\n");
|
||||
if (verbose) {
|
||||
@ -71,12 +69,10 @@ static int help(bool verbose) {
|
||||
" -h print this help\n"
|
||||
" -i interactive mode\n"
|
||||
" -j [threads] how many threads to use for running tests concurrently (default is "WORKERS_DEFAULT_STR")\n"
|
||||
" -m [rasm2] path to rasm2 executable (default is "RASM2_CMD_DEFAULT")\n"
|
||||
" -n do nothing (don't run any test, just load/parse them)\n"
|
||||
" -o [file] output test run information in JSON format to file\n"
|
||||
" -q quiet\n"
|
||||
" -r [radare2] path to radare2 executable (default is "RADARE2_CMD_DEFAULT")\n"
|
||||
" -s [ignore] Set R2R_SKIP_(xxx)=1 to skip running those tests\n"
|
||||
" -s [ignore] set R2R_SKIP_(xxx)=1 to skip running those tests\n"
|
||||
" -t [seconds] timeout per test (default is "TIMEOUT_DEFAULT_STR")\n"
|
||||
" -u do not git pull/clone test/bins\n"
|
||||
" -v show version\n"
|
||||
@ -104,7 +100,14 @@ static bool r2r_chdir(const char *argv0) {
|
||||
return true;
|
||||
}
|
||||
char *src_path = malloc (PATH_MAX);
|
||||
if (!src_path) {
|
||||
return false;
|
||||
}
|
||||
char *r2r_path = r_file_path (argv0);
|
||||
if (!r2r_path) {
|
||||
free (src_path);
|
||||
return false;
|
||||
}
|
||||
bool found = false;
|
||||
if (readlink (r2r_path, src_path, PATH_MAX) != -1) {
|
||||
src_path[PATH_MAX - 1] = 0;
|
||||
@ -203,8 +206,6 @@ int main(int argc, char **argv) {
|
||||
bool quiet = false;
|
||||
bool log_mode = false;
|
||||
bool interactive = false;
|
||||
char *radare2_cmd = NULL;
|
||||
char *rasm2_cmd = NULL;
|
||||
char *json_test_file = NULL;
|
||||
char *output_file = NULL;
|
||||
char *fuzz_dir = NULL;
|
||||
@ -218,11 +219,11 @@ int main(int argc, char **argv) {
|
||||
{
|
||||
HANDLE streams[] = { GetStdHandle (STD_OUTPUT_HANDLE), GetStdHandle (STD_ERROR_HANDLE) };
|
||||
DWORD mode;
|
||||
DWORD mode_flags = ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||
int i;
|
||||
for (i = 0; i < R_ARRAY_SIZE (streams); i++) {
|
||||
GetConsoleMode (streams[i], &mode);
|
||||
SetConsoleMode (streams[i],
|
||||
mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||
SetConsoleMode (streams[i], mode | mode_flags);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -273,20 +274,12 @@ int main(int argc, char **argv) {
|
||||
goto beach;
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
free (radare2_cmd);
|
||||
radare2_cmd = strdup (opt.arg);
|
||||
break;
|
||||
case 'C':
|
||||
r2r_dir = opt.arg;
|
||||
break;
|
||||
case 'n':
|
||||
nothing = true;
|
||||
break;
|
||||
case 'm':
|
||||
free (rasm2_cmd);
|
||||
rasm2_cmd = strdup (opt.arg);
|
||||
break;
|
||||
case 'f':
|
||||
free (json_test_file);
|
||||
json_test_file = strdup (opt.arg);
|
||||
@ -353,8 +346,8 @@ int main(int argc, char **argv) {
|
||||
r_sys_setenv ("TZ", "UTC");
|
||||
ut64 time_start = r_time_now_mono ();
|
||||
R2RState state = {{0}};
|
||||
state.run_config.r2_cmd = radare2_cmd ? radare2_cmd : RADARE2_CMD_DEFAULT;
|
||||
state.run_config.rasm2_cmd = rasm2_cmd ? rasm2_cmd : RASM2_CMD_DEFAULT;
|
||||
state.run_config.r2_cmd = "radare2";
|
||||
state.run_config.rasm2_cmd = "rasm2";
|
||||
state.run_config.json_test_file = json_test_file ? json_test_file : JSON_TEST_FILE_DEFAULT;
|
||||
state.run_config.timeout_ms = timeout_sec > UT64_MAX / 1000 ? UT64_MAX : timeout_sec * 1000;
|
||||
state.verbose = verbose;
|
||||
@ -557,8 +550,6 @@ coast:
|
||||
r_th_lock_free (state.lock);
|
||||
r_th_cond_free (state.cond);
|
||||
beach:
|
||||
free (radare2_cmd);
|
||||
free (rasm2_cmd);
|
||||
free (json_test_file);
|
||||
free (fuzz_dir);
|
||||
#if __WINDOWS__
|
||||
|
15
man/r2r.1
15
man/r2r.1
@ -1,4 +1,4 @@
|
||||
.Dd Mar 31, 2020
|
||||
.Dd Jun 31, 2022
|
||||
.Dt R2R 1
|
||||
.Sh NAME
|
||||
.Nm r2r
|
||||
@ -12,9 +12,8 @@
|
||||
.Op Fl v
|
||||
.Op Fl V
|
||||
.Op Fl j Ar threads
|
||||
.Op Fl r Ar r2-path
|
||||
.Op Fl m Ar rasm2-pth
|
||||
.Op Fl f Ar bin-for-json-tests
|
||||
.Op Fl F Ar fuzzbindir
|
||||
.Op Fl C Ar chdir
|
||||
.Op [test-(dir|file) ...]
|
||||
.Sh DESCRIPTION
|
||||
@ -37,16 +36,14 @@ Show version number
|
||||
Be verbose
|
||||
.It Fl j Ar threads
|
||||
Specify the number of tasks to run in parallel
|
||||
.It Fl r Ar r2-path
|
||||
Set path to radare2 executable
|
||||
.It Fl n Ar rasm2-path
|
||||
Set path to rasm2executable
|
||||
.It Fl m Ar rasm2-path
|
||||
Set path to rasm2executable
|
||||
.It Fl n
|
||||
Do not run any test, just parse them for linting purposes
|
||||
.It Fl f Ar bin-for-json-tests
|
||||
Load the given binary when running the JSON tests
|
||||
.It Fl C Ar directory
|
||||
Early chdir before running any test
|
||||
.It Fl F Ar directory
|
||||
Specify the path where the fuzzed binaries are
|
||||
.El
|
||||
.Sh USAGE
|
||||
.Pp
|
||||
|
Loading…
Reference in New Issue
Block a user