From 70d071e6ab71a930100a24f2381c5a0ef5ec241b Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 21 Jun 2020 00:36:33 +0100 Subject: [PATCH] fuzz_arm: Test large random blocks --- tests/A32/fuzz_arm.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/A32/fuzz_arm.cpp b/tests/A32/fuzz_arm.cpp index 17eb987b..fb14b7ff 100644 --- a/tests/A32/fuzz_arm.cpp +++ b/tests/A32/fuzz_arm.cpp @@ -342,3 +342,33 @@ TEST_CASE("A32: Small random block", "[arm]") { RunTestInstance(jit, uni, jit_env, uni_env, regs, ext_reg, instructions, cpsr, fpcr); } } + +TEST_CASE("A32: Large random block", "[arm]") { + ArmTestEnv jit_env{}; + ArmTestEnv uni_env{}; + + Dynarmic::A32::Jit jit{GetUserConfig(jit_env)}; + A32Unicorn uni{uni_env}; + + A32Unicorn::RegisterArray regs; + A32Unicorn::ExtRegArray ext_reg; + + constexpr size_t instruction_count = 100; + std::vector instructions(instruction_count); + + for (size_t iteration = 0; iteration < 10000; ++iteration) { + std::generate(regs.begin(), regs.end(), [] { return RandInt(0, ~u32(0)); }); + std::generate(ext_reg.begin(), ext_reg.end(), [] { return RandInt(0, ~u32(0)); }); + + for (size_t j = 0; j < instruction_count; ++j) { + instructions[j] = GenRandomInst(j * 4, j == instruction_count - 1); + } + + const u64 start_address = 100; + const u32 cpsr = (RandInt(0, 0xF) << 28) | 0x10; + const u32 fpcr = RandomFpcr(); + + regs[15] = start_address; + RunTestInstance(jit, uni, jit_env, uni_env, regs, ext_reg, instructions, cpsr, fpcr); + } +}