From 8c723d1df87928650204c934aa439fa3fbef4011 Mon Sep 17 00:00:00 2001 From: pancake Date: Wed, 12 Jun 2024 15:16:10 +0200 Subject: [PATCH] Run the json tests when loading no files in r2 ##tests --- binr/r2r/run.c | 4 ---- libr/core/cmd_flag.inc.c | 3 +++ libr/core/cmd_open.inc.c | 2 ++ libr/core/cmd_print.inc.c | 6 ++++++ test/db/json/cmd_i | 26 ++++++++++++++++++++++++++ test/db/json/json1 | 1 - test/db/json/json2 | 8 ++++---- test/db/json/json3 | 25 ------------------------- 8 files changed, 41 insertions(+), 34 deletions(-) create mode 100644 test/db/json/cmd_i diff --git a/binr/r2r/run.c b/binr/r2r/run.c index 104d183718f1d..ee577549327db 100644 --- a/binr/r2r/run.c +++ b/binr/r2r/run.c @@ -1403,9 +1403,6 @@ R_API R2RTestResultInfo *r2r_run_test(R2RRunConfig *config, R2RTest *test) { R2RJsonTest *json_test = test->json_test; R2RProcessOutput *out = r2r_run_json_test (config, json_test, subprocess_runner, NULL); success = r2r_check_json_test (out, json_test); -#define TEST_JSON_WITH_NO_FILES 0 -#if TEST_JSON_WITH_NO_FILES -// R2_590 - enable these tests if (strchr (json_test->cmd, '@')) { // ignore json tests with @ when running r2 with no files } else { @@ -1416,7 +1413,6 @@ R_API R2RTestResultInfo *r2r_run_test(R2RRunConfig *config, R2RTest *test) { success = false; } } -#endif ret->proc_out = out; ret->timeout = out->timeout; ret->run_failed = !out; diff --git a/libr/core/cmd_flag.inc.c b/libr/core/cmd_flag.inc.c index c9a1c0e783de9..f811edc468406 100644 --- a/libr/core/cmd_flag.inc.c +++ b/libr/core/cmd_flag.inc.c @@ -105,6 +105,7 @@ static RCoreHelpMessage help_msg_fd = { "Usage: fd[d]", " [offset|flag|expression]", " # Describe flags", "fd", " $$" , "# describe flag + delta for given offset", "fd.", " $$", "# check flags in current address (no delta)", + "fdj", " $$", "# describe current flag in json", "fdd", " $$", "# describe flag without space restrictions", "fdw", " [string]", "# filter closest flag by string for current offset", NULL @@ -1756,6 +1757,8 @@ static int cmd_flag(void *data, const char *input) { } } } + } else if (input[1] == 'j') { + r_cons_println ("{}"); } } break; diff --git a/libr/core/cmd_open.inc.c b/libr/core/cmd_open.inc.c index 7b32a876759a4..e8ee3b40ab890 100644 --- a/libr/core/cmd_open.inc.c +++ b/libr/core/cmd_open.inc.c @@ -974,6 +974,8 @@ static void cmd_open_map(RCore *core, const char *input) { map->delta, r_io_map_begin (map), r_io_map_to (map), r_str_rwx_i (map->perm), r_str_get (map->name)); } + } else if (input[2] == 'j') { + r_cons_println ("{}"); } break; case 'r': // "omr" diff --git a/libr/core/cmd_print.inc.c b/libr/core/cmd_print.inc.c index b8396884f946e..2af656ef0148a 100644 --- a/libr/core/cmd_print.inc.c +++ b/libr/core/cmd_print.inc.c @@ -4038,6 +4038,9 @@ static bool cmd_print_blocks(RCore *core, const char *input) { list = r_core_get_boundaries_prot (core, -1, NULL, "search"); if (!list) { result = true; + if (mode == 'j') { + r_cons_println ("{}"); + } goto cleanup; } RListIter *iter; @@ -4057,6 +4060,9 @@ static bool cmd_print_blocks(RCore *core, const char *input) { ut64 piece = R_MAX ((to - from) / R_MAX (cols, w), 1); as = r_core_anal_get_stats (core, from, to, piece); if (!as) { + if (mode == 'j') { + r_cons_println ("{}"); + } goto cleanup; } diff --git a/test/db/json/cmd_i b/test/db/json/cmd_i new file mode 100644 index 0000000000000..ab3df3af99b2f --- /dev/null +++ b/test/db/json/cmd_i @@ -0,0 +1,26 @@ +# iSj +icj +idj +iEj +iej +ihj +# iIj +iij +ij +# ilj +iLj +# iMj +# imj +iRj +# irj +# iSj +is.j @ 0xffffffffffffffff +isj +iSj entropy +iSj sha1 +# iSSj +# itj +# iVj +# izj +izzj +iZj diff --git a/test/db/json/json1 b/test/db/json/json1 index 99b74dd842191..1785fab5b0ae8 100644 --- a/test/db/json/json1 +++ b/test/db/json/json1 @@ -1,4 +1,3 @@ -iSj &j /ad/j push rbp /adj push rbp diff --git a/test/db/json/json2 b/test/db/json/json2 index c2d163fea8283..981039f0eb913 100644 --- a/test/db/json/json2 +++ b/test/db/json/json2 @@ -16,7 +16,7 @@ dbj dbtj dkj dLj -dmhj +# dmhj dmj dplj drj @@ -29,8 +29,8 @@ fj fdj fd.j fsj -iaj -iAj -iCj +# iaj +# iAj +# iCj tj ttj diff --git a/test/db/json/json3 b/test/db/json/json3 index 1a0b6b0f3ab7a..677b95592e90b 100644 --- a/test/db/json/json3 +++ b/test/db/json/json3 @@ -1,28 +1,3 @@ -icj -idj -iEj -iej -ihj -iIj -iij -ij -ilj -iLj -iMj -imj -iRj -irj -iSj -is.j @ 0xffffffffffffffff -isj -iSj entropy -iSj sha1 -iSSj -itj -iVj -izj -izzj -iZj Lcj # Lsj obj