diff --git a/tests/A64/fuzz_with_unicorn.cpp b/tests/A64/fuzz_with_unicorn.cpp index a5b25302..21d36f2b 100644 --- a/tests/A64/fuzz_with_unicorn.cpp +++ b/tests/A64/fuzz_with_unicorn.cpp @@ -368,3 +368,28 @@ TEST_CASE("A64: Floating point instructions", "[a64]") { RunTestInstance(regs, vecs, 100, instructions, pstate, fpcr); } } + +TEST_CASE("A64: Small random block", "[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, false)); + instructions.push_back(GenRandomInst(4, false)); + instructions.push_back(GenRandomInst(8, false)); + instructions.push_back(GenRandomInst(12, false)); + instructions.push_back(GenRandomInst(16, true)); + u32 pstate = RandInt(0, 0xF) << 28; + u32 fpcr = RandInt(0, 0x3) << 22; // randomize RMode + + INFO("Instruction 1: 0x" << std::hex << instructions[0]); + INFO("Instruction 2: 0x" << std::hex << instructions[1]); + INFO("Instruction 3: 0x" << std::hex << instructions[2]); + INFO("Instruction 4: 0x" << std::hex << instructions[3]); + INFO("Instruction 5: 0x" << std::hex << instructions[4]); + + RunTestInstance(regs, vecs, 100, instructions, pstate, fpcr); + } +} diff --git a/tests/A64/unicorn_emu/unicorn.cpp b/tests/A64/unicorn_emu/unicorn.cpp index 41aec0c3..26e20aed 100644 --- a/tests/A64/unicorn_emu/unicorn.cpp +++ b/tests/A64/unicorn_emu/unicorn.cpp @@ -35,8 +35,10 @@ Unicorn::~Unicorn() { } void Unicorn::Run() { - CHECKED(uc_emu_start(uc, GetPC(), END_ADDRESS, 0, testenv.ticks_left)); - testenv.ticks_left = 0; + while (testenv.ticks_left > 0) { + CHECKED(uc_emu_start(uc, GetPC(), END_ADDRESS, 0, 1)); + testenv.ticks_left--; + } } u64 Unicorn::GetSP() const {