/* * 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 "include/binrec.h" #include "src/common.h" #include "tests/common.h" #include "tests/log-capture.h" int main(void) { binrec_setup_t setup; memset(&setup, 0, sizeof(setup)); setup.guest = BINREC_ARCH_PPC_7XX; setup.host = BINREC_ARCH_X86_64_SYSV; setup.log = log_capture; binrec_t *handle; EXPECT(handle = binrec_create_handle(&setup)); binrec_set_code_range(handle, 0x1000, 0x1FFF); EXPECT_FALSE(binrec_translate(handle, NULL, 0xFFF, 0x1FFF, (void *[1]){0}, (long[1]){0})); EXPECT_STREQ(get_log_messages(), "[error] Address 0xFFF not within code" " range 0x1000-0x1FFF\n"); clear_log_messages(); EXPECT_FALSE(binrec_translate(handle, NULL, 0x2000, 0x2FFF, (void *[1]){0}, (long[1]){0})); EXPECT_STREQ(get_log_messages(), "[error] Address 0x2000 not within code" " range 0x1000-0x1FFF\n"); clear_log_messages(); EXPECT_FALSE(binrec_translate(handle, NULL, 0x1001, 0x1000, (void *[1]){0}, (long[1]){0})); EXPECT_STREQ(get_log_messages(), "[error] Invalid translation range" " 0x1001-0x1000\n"); binrec_destroy_handle(handle); return EXIT_SUCCESS; }