From c330d9e0e30253ebf42eecfbdedc3c67f3d82caa Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 18 Jul 2016 16:10:35 -0500 Subject: [PATCH] Increase the chance of generating instructions without conditions in the REV/REVSH/REV16 tests. --- tests/arm/fuzz_arm.cpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/tests/arm/fuzz_arm.cpp b/tests/arm/fuzz_arm.cpp index d2834eb6..ae19305e 100644 --- a/tests/arm/fuzz_arm.cpp +++ b/tests/arm/fuzz_arm.cpp @@ -366,29 +366,44 @@ TEST_CASE("Fuzz ARM reversal instructions", "[JitX64]") { return Dynarmic::Common::Bits<0, 3>(instr) != 0b1111 && Dynarmic::Common::Bits<12, 15>(instr) != 0b1111; }; - const std::array reg_instructions = { + const std::array rev_instructions = { { - InstructionGenerator("cccc011010111111dddd11110011mmmm", is_valid), - InstructionGenerator("cccc011010111111dddd11111011mmmm", is_valid), - InstructionGenerator("cccc011011111111dddd11111011mmmm", is_valid), + InstructionGenerator("0000011010111111dddd11110011mmmm", is_valid), + InstructionGenerator("0000011010111111dddd11111011mmmm", is_valid), + InstructionGenerator("0000011011111111dddd11111011mmmm", is_valid), } }; SECTION("REV tests") { - FuzzJitArm(1, 1, 10000, [®_instructions]() -> u32 { - return reg_instructions[0].Generate(); + FuzzJitArm(1, 1, 10000, [&rev_instructions]() -> u32 { + u32 cond = 0xE; + // Have a one-in-twenty-five chance of actually having a cond. + if (RandInt(1, 25) == 1) { + cond = RandInt(0x0, 0xD); + } + return rev_instructions[0].Generate() | (cond << 28); }); } SECTION("REV16 tests") { - FuzzJitArm(1, 1, 10000, [®_instructions]() -> u32 { - return reg_instructions[1].Generate(); + FuzzJitArm(1, 1, 10000, [&rev_instructions]() -> u32 { + u32 cond = 0xE; + // Have a one-in-twenty-five chance of actually having a cond. + if (RandInt(1, 25) == 1) { + cond = RandInt(0x0, 0xD); + } + return rev_instructions[1].Generate() | (cond << 28); }); } SECTION("REVSH tests") { - FuzzJitArm(1, 1, 10000, [®_instructions]() -> u32 { - return reg_instructions[2].Generate(); + FuzzJitArm(1, 1, 10000, [&rev_instructions]() -> u32 { + u32 cond = 0xE; + // Have a one-in-twenty-five chance of actually having a cond. + if (RandInt(1, 25) == 1) { + cond = RandInt(0x0, 0xD); + } + return rev_instructions[2].Generate() | (cond << 28); }); } }