mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-06 22:48:25 +01:00
A64/tests: Split unicorn sanity checking from other tests
This commit is contained in:
parent
9d42bc3228
commit
7992a319ba
3 changed files with 85 additions and 70 deletions
81
tests/A64/verify_unicorn.cpp
Normal file
81
tests/A64/verify_unicorn.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2018 MerryMage
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "rand_int.h"
|
||||
#include "testenv.h"
|
||||
#include "unicorn_emu/unicorn.h"
|
||||
|
||||
using namespace Dynarmic;
|
||||
|
||||
TEST_CASE("Unicorn: Sanity test", "[a64]") {
|
||||
TestEnv env;
|
||||
env.code_mem[0] = 0x8b020020; // ADD X0, X1, X2
|
||||
env.code_mem[1] = 0x14000000; // B .
|
||||
|
||||
std::array<u64, 31> regs {
|
||||
0, 1, 2, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
Unicorn unicorn{env};
|
||||
|
||||
unicorn.SetRegisters(regs);
|
||||
unicorn.SetPC(0);
|
||||
|
||||
env.ticks_left = 2;
|
||||
unicorn.Run();
|
||||
|
||||
REQUIRE(unicorn.GetRegisters()[0] == 3);
|
||||
REQUIRE(unicorn.GetRegisters()[1] == 1);
|
||||
REQUIRE(unicorn.GetRegisters()[2] == 2);
|
||||
REQUIRE(unicorn.GetPC() == 4);
|
||||
}
|
||||
|
||||
TEST_CASE("Unicorn: Ensure 0xFFFF'FFFF'FFFF'FFFF is readable", "[a64]") {
|
||||
TestEnv env;
|
||||
|
||||
env.code_mem[0] = 0x385fed99; // LDRB W25, [X12, #0xfffffffffffffffe]!
|
||||
env.code_mem[1] = 0x14000000; // B .
|
||||
|
||||
std::array<u64, 31> regs{};
|
||||
regs[12] = 1;
|
||||
|
||||
Unicorn unicorn{env};
|
||||
|
||||
unicorn.SetRegisters(regs);
|
||||
unicorn.SetPC(0);
|
||||
|
||||
env.ticks_left = 2;
|
||||
unicorn.Run();
|
||||
|
||||
REQUIRE(unicorn.GetPC() == 4);
|
||||
}
|
||||
|
||||
TEST_CASE("Unicorn: Ensure is able to read across page boundaries", "[a64]") {
|
||||
TestEnv env;
|
||||
|
||||
env.code_mem[0] = 0xb85f93d9; // LDUR W25, [X30, #0xfffffffffffffff9]
|
||||
env.code_mem[1] = 0x14000000; // B .
|
||||
|
||||
std::array<u64, 31> regs{};
|
||||
regs[30] = 4;
|
||||
|
||||
Unicorn unicorn{env};
|
||||
|
||||
unicorn.SetRegisters(regs);
|
||||
unicorn.SetPC(0);
|
||||
|
||||
env.ticks_left = 2;
|
||||
unicorn.Run();
|
||||
|
||||
REQUIRE(unicorn.GetPC() == 4);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue