/* * libbinrec: a recompiling translator for machine code * Copyright (c) 2016 Andrew Church * * This software may be copied and redistributed under certain conditions; * see the file "COPYING" in the source code distribution for details. * NO WARRANTY is provided with this software. */ #include "src/rtl.h" #include "src/rtl-internal.h" #include "tests/common.h" #include "tests/log-capture.h" #include "tests/mem-wrappers.h" int main(void) { binrec_setup_t setup; memset(&setup, 0, sizeof(setup)); setup.malloc = mem_wrap_malloc; setup.realloc = mem_wrap_realloc; setup.free = mem_wrap_free; setup.log = log_capture; binrec_t *handle; EXPECT(handle = binrec_create_handle(&setup)); RTLUnit *unit; for (int count = 0; ; count++) { if (count >= 100) { FAIL("Failed to create a unit after 100 tries"); } mem_wrap_fail_after(count); unit = rtl_create_unit(handle); if (unit) { if (count == 0) { FAIL("Unit creation did not fail on memory allocation" " failure"); } break; } } rtl_destroy_unit(unit); binrec_destroy_handle(handle); return EXIT_SUCCESS; }