From e9f6e7c82c1a2c960a9ea5a3271047f489ab96d1 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 21 Jan 2018 17:46:18 +0000 Subject: [PATCH] tests/A64: Allow RunTestInstance to start from an arbitrary offset --- tests/A64/fuzz_with_unicorn.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/A64/fuzz_with_unicorn.cpp b/tests/A64/fuzz_with_unicorn.cpp index b7abd46f..99f7a598 100644 --- a/tests/A64/fuzz_with_unicorn.cpp +++ b/tests/A64/fuzz_with_unicorn.cpp @@ -54,24 +54,24 @@ restart: return instruction; } -static void RunTestInstance(const std::array& regs, const std::vector& instructions, u32 pstate) { +static void RunTestInstance(const std::array& regs, const size_t instructions_offset, const std::vector& instructions, const u32 pstate) { TestEnv jit_env; TestEnv uni_env; - std::copy(instructions.begin(), instructions.end(), jit_env.code_mem.begin()); - std::copy(instructions.begin(), instructions.end(), uni_env.code_mem.begin()); - jit_env.code_mem[instructions.size()] = 0x14000000; // B . - uni_env.code_mem[instructions.size()] = 0x14000000; // B . + std::copy(instructions.begin(), instructions.end(), jit_env.code_mem.begin() + instructions_offset); + std::copy(instructions.begin(), instructions.end(), uni_env.code_mem.begin() + instructions_offset); + jit_env.code_mem[instructions.size() + instructions_offset] = 0x14000000; // B . + uni_env.code_mem[instructions.size() + instructions_offset] = 0x14000000; // B . Dynarmic::A64::Jit jit{Dynarmic::A64::UserConfig{&jit_env}}; Unicorn uni{uni_env}; jit.SetRegisters(regs); - jit.SetPC(0); + jit.SetPC(instructions_offset * 4); jit.SetSP(0x8000000); jit.SetPstate(pstate); uni.SetRegisters(regs); - uni.SetPC(0); + uni.SetPC(instructions_offset * 4); uni.SetSP(0x8000000); uni.SetPstate(pstate); @@ -95,8 +95,8 @@ TEST_CASE("A64: Single random instruction", "[a64]") { instructions.push_back(GenRandomInst(0, true)); u32 pstate = RandInt(0, 0xF) << 28; - INFO("Instruction: " << instructions[0]); + INFO("Instruction: 0x" << std::hex << instructions[0]); - RunTestInstance(regs, instructions, pstate); + RunTestInstance(regs, 100, instructions, pstate); } }