Skip to content

Commit d604272

Browse files
committed
feat: added rd_reanalyze roundtrip tests
1 parent 393f924 commit d604272

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

rdtest_helpers.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,14 @@ int rdtest_check_types(RDContext* ctx, const RDTestType* types) {
216216
}
217217

218218
if(!rd_type_equals(&currt, &t)) {
219-
fprintf(stderr, " TEST FAIL type mismatch at 0x%08" PRIx64 "\n",
220-
tt->address);
219+
char* currt_str = rd_strdup(rd_type_to_str(&currt, ctx));
220+
221+
fprintf(stderr,
222+
" TEST FAIL type mismatch at 0x%08" PRIx64
223+
" (expected '%s', got '%s')\n",
224+
tt->address, rd_type_to_str(&t, ctx), currt_str);
225+
226+
rd_free(currt_str);
221227
return RDTEST_FAIL;
222228
}
223229

@@ -304,6 +310,11 @@ int rdtest_check_sample(RDTestSample* sample) {
304310
rd_disassemble(sample->ctx);
305311
rdtest_assert_pass(_rdtest_run(sample));
306312

313+
// immediate re-analysis shouldn't mutate anything
314+
rdtest_assert_true(rd_reanalyze(sample->ctx));
315+
rd_disassemble(sample->ctx);
316+
rdtest_assert_pass(_rdtest_run(sample));
317+
307318
// run again in project mode
308319
bool ok = rd_project_save(sample->ctx, RDTEST_PROJECT_FILE);
309320
rdtest_assert_true(ok);
@@ -318,5 +329,11 @@ int rdtest_check_sample(RDTestSample* sample) {
318329
remove(RDTEST_PROJECT_FILE);
319330

320331
rdtest_assert_pass(_rdtest_run(sample));
332+
333+
// re-analysis after project load shouldn't mutate anything
334+
rdtest_assert_true(rd_reanalyze(sample->ctx));
335+
rd_disassemble(sample->ctx);
336+
rdtest_assert_pass(_rdtest_run(sample));
337+
321338
return RDTEST_PASS;
322339
}

0 commit comments

Comments
 (0)