From 2c40d164b5811204917cfbf2961564ea23a79ca8 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 31 Mar 2020 03:17:30 +0200 Subject: [PATCH] r2r new flags: -n to not run -v for version, add manpage ##tests --- binr/r2r/r2r.c | 17 +++++++++++-- man/r2r.1 | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ man/radare2.1 | 1 + 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 man/r2r.1 diff --git a/binr/r2r/r2r.c b/binr/r2r/r2r.c index 957a4aadf7..3d5df03382 100644 --- a/binr/r2r/r2r.c +++ b/binr/r2r/r2r.c @@ -38,7 +38,8 @@ static int help(bool verbose) { if (verbose) { printf ( " -h print this help\n" - " -v verbose\n" + " -v show version\n" + " -V verbose\n" " -L log mode (better printing for CI, logfiles, etc.)" " -j [threads] how many threads to use for running tests concurrently (default is "WORKERS_DEFAULT_STR")\n" " -r [radare2] path to radare2 executable (default is "RADARE2_CMD_DEFAULT")\n" @@ -121,6 +122,7 @@ static bool r2r_chdir_fromtest(const char *test_path) { int main(int argc, char **argv) { int workers_count = WORKERS_DEFAULT; bool verbose = false; + bool nothing = false; bool log_mode = false; char *radare2_cmd = NULL; char *rasm2_cmd = NULL; @@ -129,7 +131,7 @@ int main(int argc, char **argv) { int ret = 0; RGetopt opt; - r_getopt_init (&opt, argc, (const char **)argv, "hvj:r:m:f:C:L"); + r_getopt_init (&opt, argc, (const char **)argv, "hvj:r:m:f:C:LnV"); int c; while ((c = r_getopt_next (&opt)) != -1) { @@ -138,6 +140,9 @@ int main(int argc, char **argv) { ret = help (true); goto beach; case 'v': + printf (""R2_VERSION"\n"); + return 0; + case 'V': verbose = true; break; case 'L': @@ -158,6 +163,9 @@ int main(int argc, char **argv) { case 'C': r2r_dir = opt.arg; break; + case 'n': + nothing = true; + break; case 'm': free (rasm2_cmd); rasm2_cmd = strdup (opt.arg); @@ -236,6 +244,11 @@ int main(int argc, char **argv) { } R_FREE (cwd); + uint32_t loaded_tests = r_pvector_len (&state.db->tests); + printf ("Loaded %u tests.\n", loaded_tests); + if (nothing) { + return 0; + } bool jq_available = r2r_check_jq_available (); if (!jq_available) { diff --git a/man/r2r.1 b/man/r2r.1 new file mode 100644 index 0000000000..e37e7cef2e --- /dev/null +++ b/man/r2r.1 @@ -0,0 +1,65 @@ +.Dd Mar 31, 2020 +.Dt R2R 1 +.Sh NAME +.Nm r2r +.Nd radare2 regression testsuite +.Sh SYNOPSIS +.Nm r2r +.Op Fl h +.Op Fl n +.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 json-test-file +.Op Fl C Ar chdir +.Op [test-(dir|file) ...] +.Sh DESCRIPTION +Run all the radare2-regressions tests matching a specific word in the name. +.Pp +TODO: this manpage is work-in-progress +.Pp +You need radare2 to be available in $PATH. +.Sh OPTIONS +.Bl -tag -width Fl +.It Fl h +Show the help/usage message +.It Fl n +Do not run any test, just load/parse them +.It Fl v +Show version number +.It Fl V +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 f Ar json-test-file +Run the given test file as json +.It Fl C Ar directory +Early chdir before running any test +.El +.Sh USAGE +.Pp +Use the -n flag to dont run any test. Just load them. +.Pp + $ r2r -n + [r2r] Loading tests... +.Pp +.Sh SEE ALSO +.Pp +.Xr radare2(1) , +.Xr rahash2(1) , +.Xr rafind2(1) , +.Xr rabin2(1) , +.Xr rafind2(1) , +.Xr radiff2(1) , +.Xr rasm2(1) , +.Sh AUTHORS +.Pp +Written by pancake . diff --git a/man/radare2.1 b/man/radare2.1 index 27a433faa6..56ef63e3d9 100644 --- a/man/radare2.1 +++ b/man/radare2.1 @@ -132,6 +132,7 @@ In r2 the debugger commands are implemented under the 'd' command. Type 'd?' for path to the current working file. .Sh SEE ALSO .Pp +.Xr r2r(1) , .Xr rahash2(1) , .Xr rafind2(1) , .Xr rabin2(1) ,