Skip to content

Commit

Permalink
Run the json tests when loading no files in r2 ##tests
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Jun 12, 2024
1 parent f98a9b7 commit 8c723d1
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 34 deletions.
4 changes: 0 additions & 4 deletions binr/r2r/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions libr/core/cmd_flag.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1756,6 +1757,8 @@ static int cmd_flag(void *data, const char *input) {
}
}
}
} else if (input[1] == 'j') {
r_cons_println ("{}");
}
}
break;
Expand Down
2 changes: 2 additions & 0 deletions libr/core/cmd_open.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions libr/core/cmd_print.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
26 changes: 26 additions & 0 deletions test/db/json/cmd_i
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion test/db/json/json1
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
iSj
&j
/ad/j push rbp
/adj push rbp
Expand Down
8 changes: 4 additions & 4 deletions test/db/json/json2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dbj
dbtj
dkj
dLj
dmhj
# dmhj
dmj
dplj
drj
Expand All @@ -29,8 +29,8 @@ fj
fdj
fd.j
fsj
iaj
iAj
iCj
# iaj
# iAj
# iCj
tj
ttj
25 changes: 0 additions & 25 deletions test/db/json/json3
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 8c723d1

Please sign in to comment.