From 35aaee6cc663b57909a528937c7e0b79284b539b Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 21 Jan 2018 17:55:26 +0000 Subject: [PATCH] tests/A64: Randomize vectors --- tests/A64/fuzz_with_unicorn.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/A64/fuzz_with_unicorn.cpp b/tests/A64/fuzz_with_unicorn.cpp index 99f7a598..37415edb 100644 --- a/tests/A64/fuzz_with_unicorn.cpp +++ b/tests/A64/fuzz_with_unicorn.cpp @@ -17,6 +17,11 @@ #include "unicorn_emu/unicorn.h" using namespace Dynarmic; +using Vector = Dynarmic::A64::Jit::Vector; + +static Vector RandomVector() { + return {RandInt(0, ~u64(0)), RandInt(0, ~u64(0))}; +} static std::vector instruction_generators = []{ const std::vector> list { @@ -54,7 +59,7 @@ restart: return instruction; } -static void RunTestInstance(const std::array& regs, const size_t instructions_offset, const std::vector& instructions, const u32 pstate) { +static void RunTestInstance(const std::array& regs, const std::array& vecs, const size_t instructions_offset, const std::vector& instructions, const u32 pstate) { TestEnv jit_env; TestEnv uni_env; @@ -67,10 +72,12 @@ static void RunTestInstance(const std::array& regs, const size_t instru Unicorn uni{uni_env}; jit.SetRegisters(regs); + jit.SetVectors(vecs); jit.SetPC(instructions_offset * 4); jit.SetSP(0x8000000); jit.SetPstate(pstate); uni.SetRegisters(regs); + uni.SetVectors(vecs); uni.SetPC(instructions_offset * 4); uni.SetSP(0x8000000); uni.SetPstate(pstate); @@ -91,12 +98,14 @@ TEST_CASE("A64: Single random instruction", "[a64]") { for (size_t iteration = 0; iteration < 100000; ++iteration) { std::array regs; std::generate_n(regs.begin(), 31, []{ return RandInt(0, ~u64(0)); }); + std::array vecs; + std::generate_n(vecs.begin(), 32, []{ return RandomVector(); }); std::vector instructions; instructions.push_back(GenRandomInst(0, true)); u32 pstate = RandInt(0, 0xF) << 28; INFO("Instruction: 0x" << std::hex << instructions[0]); - RunTestInstance(regs, 100, instructions, pstate); + RunTestInstance(regs, vecs, 100, instructions, pstate); } }