Skip to content

Commit

Permalink
Add a test for the issue #22901
Browse files Browse the repository at this point in the history
  • Loading branch information
satk0 committed Jul 8, 2024
1 parent 7e2833d commit 65abfaa
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/unit/test_sign.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <r_core.h>
#include <r_anal.h>
#include <r_sign.h>

Expand Down Expand Up @@ -116,8 +117,32 @@ static bool test_anal_sign_get_set(void) {
mu_end;
}

bool test_anal_sign_avoid_dup_funcions(void) {
RCore *core = r_core_new ();

RAnalFunction *fcn1 = r_anal_create_function (core->anal, "fcn1", 0x2137, 0, NULL);
RAnalBlock *first_block = r_anal_create_block (core->anal, 0x2137, 13);
r_anal_function_add_block (fcn1, first_block);

RAnalFunction *fcn2 = r_anal_create_function (core->anal, "fcn2", 0xdeadbeef, 0, NULL);
RAnalBlock *second_block = r_anal_create_block (core->anal, 0xdeadbeef, 31);
r_anal_function_add_block (fcn2, second_block);

r_core_cmd0 (core, "aaa"); // find functions

int count = r_sign_all_functions (core->anal, false); // "zg"
mu_assert_eq (count, 2, "Should create 2 new zignatures for the unseen functions");

count = r_sign_all_functions (core->anal, false);
mu_assert_eq (count, 0, "Should not create new zignatures for the same functions");

r_core_free (core);
mu_end;
}

int all_tests(void) {
mu_run_test (test_anal_sign_get_set);
mu_run_test (test_anal_sign_avoid_dup_funcions);
return tests_passed != tests_run;
}

Expand Down

0 comments on commit 65abfaa

Please sign in to comment.