mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
commit
05a38e307c
|
@ -301,9 +301,9 @@ get_git_head_revision(GIT_REF_SPEC GIT_REV)
|
||||||
git_describe(GIT_DESC --always --long --dirty)
|
git_describe(GIT_DESC --always --long --dirty)
|
||||||
git_branch_name(GIT_BRANCH)
|
git_branch_name(GIT_BRANCH)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
add_subdirectory(externals)
|
add_subdirectory(externals)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
enable_testing()
|
|
||||||
|
|
||||||
|
|
||||||
# Installation instructions
|
# Installation instructions
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
set(SRCS
|
set(SRCS
|
||||||
common/param_package.cpp
|
common/param_package.cpp
|
||||||
|
core/arm/arm_test_common.cpp
|
||||||
|
core/arm/dyncom/arm_dyncom_vfp_tests.cpp
|
||||||
core/file_sys/path_parser.cpp
|
core/file_sys/path_parser.cpp
|
||||||
core/hle/kernel/hle_ipc.cpp
|
core/hle/kernel/hle_ipc.cpp
|
||||||
glad.cpp
|
glad.cpp
|
||||||
|
@ -7,6 +9,7 @@ set(SRCS
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
|
core/arm/arm_test_common.h
|
||||||
)
|
)
|
||||||
|
|
||||||
create_directory_groups(${SRCS} ${HEADERS})
|
create_directory_groups(${SRCS} ${HEADERS})
|
||||||
|
|
123
src/tests/core/arm/arm_test_common.cpp
Normal file
123
src/tests/core/arm/arm_test_common.cpp
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
// Copyright 2016 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "core/core.h"
|
||||||
|
#include "core/memory_setup.h"
|
||||||
|
#include "tests/core/arm/arm_test_common.h"
|
||||||
|
|
||||||
|
namespace ArmTests {
|
||||||
|
|
||||||
|
TestEnvironment::TestEnvironment(bool mutable_memory_)
|
||||||
|
: mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) {
|
||||||
|
Memory::MapIoRegion(0x00000000, 0x80000000, test_memory);
|
||||||
|
Memory::MapIoRegion(0x80000000, 0x80000000, test_memory);
|
||||||
|
}
|
||||||
|
|
||||||
|
TestEnvironment::~TestEnvironment() {
|
||||||
|
Memory::UnmapRegion(0x80000000, 0x80000000);
|
||||||
|
Memory::UnmapRegion(0x00000000, 0x80000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::SetMemory64(VAddr vaddr, u64 value) {
|
||||||
|
SetMemory32(vaddr + 0, static_cast<u32>(value));
|
||||||
|
SetMemory32(vaddr + 4, static_cast<u32>(value >> 32));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::SetMemory32(VAddr vaddr, u32 value) {
|
||||||
|
SetMemory16(vaddr + 0, static_cast<u16>(value));
|
||||||
|
SetMemory16(vaddr + 2, static_cast<u16>(value >> 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::SetMemory16(VAddr vaddr, u16 value) {
|
||||||
|
SetMemory8(vaddr + 0, static_cast<u8>(value));
|
||||||
|
SetMemory8(vaddr + 1, static_cast<u8>(value >> 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::SetMemory8(VAddr vaddr, u8 value) {
|
||||||
|
test_memory->data[vaddr] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<WriteRecord> TestEnvironment::GetWriteRecords() const {
|
||||||
|
return write_records;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::ClearWriteRecords() {
|
||||||
|
write_records.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
TestEnvironment::TestMemory::~TestMemory() {}
|
||||||
|
|
||||||
|
bool TestEnvironment::TestMemory::IsValidAddress(VAddr addr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 TestEnvironment::TestMemory::Read8(VAddr addr) {
|
||||||
|
auto iter = data.find(addr);
|
||||||
|
if (iter == data.end()) {
|
||||||
|
return addr; // Some arbitrary data
|
||||||
|
}
|
||||||
|
return iter->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
u16 TestEnvironment::TestMemory::Read16(VAddr addr) {
|
||||||
|
return Read8(addr) | static_cast<u16>(Read8(addr + 1)) << 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 TestEnvironment::TestMemory::Read32(VAddr addr) {
|
||||||
|
return Read16(addr) | static_cast<u32>(Read16(addr + 2)) << 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 TestEnvironment::TestMemory::Read64(VAddr addr) {
|
||||||
|
return Read32(addr) | static_cast<u64>(Read32(addr + 4)) << 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TestEnvironment::TestMemory::ReadBlock(VAddr src_addr, void* dest_buffer, size_t size) {
|
||||||
|
VAddr addr = src_addr;
|
||||||
|
u8* data = static_cast<u8*>(dest_buffer);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < size; i++, addr++, data++) {
|
||||||
|
*data = Read8(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::TestMemory::Write8(VAddr addr, u8 data) {
|
||||||
|
env->write_records.emplace_back(8, addr, data);
|
||||||
|
if (env->mutable_memory)
|
||||||
|
env->SetMemory8(addr, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::TestMemory::Write16(VAddr addr, u16 data) {
|
||||||
|
env->write_records.emplace_back(16, addr, data);
|
||||||
|
if (env->mutable_memory)
|
||||||
|
env->SetMemory16(addr, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::TestMemory::Write32(VAddr addr, u32 data) {
|
||||||
|
env->write_records.emplace_back(32, addr, data);
|
||||||
|
if (env->mutable_memory)
|
||||||
|
env->SetMemory32(addr, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestEnvironment::TestMemory::Write64(VAddr addr, u64 data) {
|
||||||
|
env->write_records.emplace_back(64, addr, data);
|
||||||
|
if (env->mutable_memory)
|
||||||
|
env->SetMemory64(addr, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TestEnvironment::TestMemory::WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size) {
|
||||||
|
VAddr addr = dest_addr;
|
||||||
|
const u8* data = static_cast<const u8*>(src_buffer);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < size; i++, addr++, data++) {
|
||||||
|
env->write_records.emplace_back(8, addr, *data);
|
||||||
|
if (env->mutable_memory)
|
||||||
|
env->SetMemory8(addr, *data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ArmTests
|
84
src/tests/core/arm/arm_test_common.h
Normal file
84
src/tests/core/arm/arm_test_common.h
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
// Copyright 2016 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "common/common_types.h"
|
||||||
|
#include "core/mmio.h"
|
||||||
|
|
||||||
|
namespace ArmTests {
|
||||||
|
|
||||||
|
struct WriteRecord {
|
||||||
|
WriteRecord(size_t size, VAddr addr, u64 data) : size(size), addr(addr), data(data) {}
|
||||||
|
size_t size;
|
||||||
|
VAddr addr;
|
||||||
|
u64 data;
|
||||||
|
bool operator==(const WriteRecord& o) const {
|
||||||
|
return std::tie(size, addr, data) == std::tie(o.size, o.addr, o.data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class TestEnvironment final {
|
||||||
|
public:
|
||||||
|
/*
|
||||||
|
* Inititalise test environment
|
||||||
|
* @param mutable_memory If false, writes to memory can never be read back.
|
||||||
|
* (Memory is immutable.)
|
||||||
|
*/
|
||||||
|
explicit TestEnvironment(bool mutable_memory = false);
|
||||||
|
|
||||||
|
/// Shutdown test environment
|
||||||
|
~TestEnvironment();
|
||||||
|
|
||||||
|
/// Sets value at memory location vaddr.
|
||||||
|
void SetMemory8(VAddr vaddr, u8 value);
|
||||||
|
void SetMemory16(VAddr vaddr, u16 value);
|
||||||
|
void SetMemory32(VAddr vaddr, u32 value);
|
||||||
|
void SetMemory64(VAddr vaddr, u64 value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whenever Memory::Write{8,16,32,64} is called within the test environment,
|
||||||
|
* a new write-record is made.
|
||||||
|
* @returns A vector of write records made since they were last cleared.
|
||||||
|
*/
|
||||||
|
std::vector<WriteRecord> GetWriteRecords() const;
|
||||||
|
|
||||||
|
/// Empties the internal write-record store.
|
||||||
|
void ClearWriteRecords();
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend struct TestMemory;
|
||||||
|
struct TestMemory final : Memory::MMIORegion {
|
||||||
|
explicit TestMemory(TestEnvironment* env_) : env(env_) {}
|
||||||
|
TestEnvironment* env;
|
||||||
|
|
||||||
|
~TestMemory() override;
|
||||||
|
|
||||||
|
bool IsValidAddress(VAddr addr) override;
|
||||||
|
|
||||||
|
u8 Read8(VAddr addr) override;
|
||||||
|
u16 Read16(VAddr addr) override;
|
||||||
|
u32 Read32(VAddr addr) override;
|
||||||
|
u64 Read64(VAddr addr) override;
|
||||||
|
|
||||||
|
bool ReadBlock(VAddr src_addr, void* dest_buffer, size_t size) override;
|
||||||
|
|
||||||
|
void Write8(VAddr addr, u8 data) override;
|
||||||
|
void Write16(VAddr addr, u16 data) override;
|
||||||
|
void Write32(VAddr addr, u32 data) override;
|
||||||
|
void Write64(VAddr addr, u64 data) override;
|
||||||
|
|
||||||
|
bool WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size) override;
|
||||||
|
|
||||||
|
std::unordered_map<VAddr, u8> data;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool mutable_memory;
|
||||||
|
std::shared_ptr<TestMemory> test_memory;
|
||||||
|
std::vector<WriteRecord> write_records;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ArmTests
|
50
src/tests/core/arm/dyncom/arm_dyncom_vfp_tests.cpp
Normal file
50
src/tests/core/arm/dyncom/arm_dyncom_vfp_tests.cpp
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// Copyright 2016 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <catch.hpp>
|
||||||
|
|
||||||
|
#include "core/arm/dyncom/arm_dyncom.h"
|
||||||
|
#include "tests/core/arm/arm_test_common.h"
|
||||||
|
|
||||||
|
namespace ArmTests {
|
||||||
|
|
||||||
|
struct VfpTestCase {
|
||||||
|
u32 initial_fpscr;
|
||||||
|
u32 a;
|
||||||
|
u32 b;
|
||||||
|
u32 result;
|
||||||
|
u32 final_fpscr;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE("ARM_DynCom (vfp): vadd", "[arm_dyncom]") {
|
||||||
|
TestEnvironment test_env(false);
|
||||||
|
test_env.SetMemory32(0, 0xEE321A03); // vadd.f32 s2, s4, s6
|
||||||
|
test_env.SetMemory32(4, 0xEAFFFFFE); // b +#0
|
||||||
|
|
||||||
|
ARM_DynCom dyncom(USER32MODE);
|
||||||
|
|
||||||
|
std::vector<VfpTestCase> test_cases{{
|
||||||
|
#include "vfp_vadd_f32.inc"
|
||||||
|
}};
|
||||||
|
|
||||||
|
for (const auto& test_case : test_cases) {
|
||||||
|
dyncom.down_count = 1000; // Ensure that CoreTimeing will not be called.
|
||||||
|
dyncom.SetPC(0);
|
||||||
|
dyncom.SetVFPSystemReg(VFP_FPSCR, test_case.initial_fpscr);
|
||||||
|
dyncom.SetVFPReg(4, test_case.a);
|
||||||
|
dyncom.SetVFPReg(6, test_case.b);
|
||||||
|
dyncom.ExecuteInstructions(1);
|
||||||
|
if (dyncom.GetVFPReg(2) != test_case.result ||
|
||||||
|
dyncom.GetVFPSystemReg(VFP_FPSCR) != test_case.final_fpscr) {
|
||||||
|
printf("f: %x\n", test_case.initial_fpscr);
|
||||||
|
printf("a: %x\n", test_case.a);
|
||||||
|
printf("b: %x\n", test_case.b);
|
||||||
|
printf("c: %x (%x)\n", dyncom.GetVFPReg(2), test_case.result);
|
||||||
|
printf("f: %x (%x)\n", dyncom.GetVFPSystemReg(VFP_FPSCR), test_case.final_fpscr);
|
||||||
|
FAIL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ArmTests
|
13456
src/tests/core/arm/dyncom/vfp_vadd_f32.inc
Normal file
13456
src/tests/core/arm/dyncom/vfp_vadd_f32.inc
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue