mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-23 08:15:38 +00:00
tests: Resolve C4267 warning on MSVC
This commit is contained in:
parent
0d955c452b
commit
adcc786ef2
|
@ -142,8 +142,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
std::fill(buffer.GetPtr(), buffer.GetPtr() + buffer.GetSize(), 0xAB);
|
||||
|
||||
VAddr target_address = 0x10000000;
|
||||
auto result = process->vm_manager.MapBackingMemory(target_address, buffer, buffer.GetSize(),
|
||||
MemoryState::Private);
|
||||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address, buffer, static_cast<u32>(buffer.GetSize()), MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
const u32_le input[]{
|
||||
|
@ -156,7 +156,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
|
||||
CHECK(context.GetStaticBuffer(0) == mem->Vector());
|
||||
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address, buffer.GetSize()) == RESULT_SUCCESS);
|
||||
REQUIRE(process->vm_manager.UnmapRange(
|
||||
target_address, static_cast<u32>(buffer.GetSize())) == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
SECTION("translates MappedBuffer descriptors") {
|
||||
|
@ -165,8 +166,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
std::fill(buffer.GetPtr(), buffer.GetPtr() + buffer.GetSize(), 0xCD);
|
||||
|
||||
VAddr target_address = 0x10000000;
|
||||
auto result = process->vm_manager.MapBackingMemory(target_address, buffer, buffer.GetSize(),
|
||||
MemoryState::Private);
|
||||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address, buffer, static_cast<u32>(buffer.GetSize()), MemoryState::Private);
|
||||
|
||||
const u32_le input[]{
|
||||
IPC::MakeHeader(0, 0, 2),
|
||||
|
@ -181,7 +182,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
|
||||
CHECK(other_buffer == mem->Vector());
|
||||
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address, buffer.GetSize()) == RESULT_SUCCESS);
|
||||
REQUIRE(process->vm_manager.UnmapRange(
|
||||
target_address, static_cast<u32>(buffer.GetSize())) == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
SECTION("translates mixed params") {
|
||||
|
@ -195,12 +197,14 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
|
||||
VAddr target_address_static = 0x10000000;
|
||||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address_static, buffer_static, buffer_static.GetSize(), MemoryState::Private);
|
||||
target_address_static, buffer_static, static_cast<u32>(buffer_static.GetSize()),
|
||||
MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
VAddr target_address_mapped = 0x20000000;
|
||||
result = process->vm_manager.MapBackingMemory(
|
||||
target_address_mapped, buffer_mapped, buffer_mapped.GetSize(), MemoryState::Private);
|
||||
result = process->vm_manager.MapBackingMemory(target_address_mapped, buffer_mapped,
|
||||
static_cast<u32>(buffer_mapped.GetSize()),
|
||||
MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
auto a = MakeObject(kernel);
|
||||
|
@ -230,9 +234,11 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
context.GetMappedBuffer(0).Read(other_buffer.data(), 0, buffer_mapped.GetSize());
|
||||
CHECK(other_buffer == mem_mapped->Vector());
|
||||
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address_static, buffer_static.GetSize()) ==
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address_static,
|
||||
static_cast<u32>(buffer_static.GetSize())) ==
|
||||
RESULT_SUCCESS);
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address_mapped, buffer_mapped.GetSize()) ==
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address_mapped,
|
||||
static_cast<u32>(buffer_mapped.GetSize())) ==
|
||||
RESULT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
@ -325,7 +331,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
|
||||
VAddr target_address = 0x10000000;
|
||||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address, output_buffer, output_buffer.GetSize(), MemoryState::Private);
|
||||
target_address, output_buffer, static_cast<u32>(output_buffer.GetSize()),
|
||||
MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
input[0] = IPC::MakeHeader(0, 0, 2);
|
||||
|
@ -343,8 +350,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
context.WriteToOutgoingCommandBuffer(output_cmdbuff.data(), *process);
|
||||
|
||||
CHECK(output_mem->Vector() == input_buffer);
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address, output_buffer.GetSize()) ==
|
||||
RESULT_SUCCESS);
|
||||
REQUIRE(process->vm_manager.UnmapRange(
|
||||
target_address, static_cast<u32>(output_buffer.GetSize())) == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
SECTION("translates StaticBuffer descriptors") {
|
||||
|
@ -356,7 +363,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
|
||||
VAddr target_address = 0x10000000;
|
||||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address, output_buffer, output_buffer.GetSize(), MemoryState::Private);
|
||||
target_address, output_buffer, static_cast<u32>(output_buffer.GetSize()),
|
||||
MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
const u32_le input_cmdbuff[]{
|
||||
|
@ -378,8 +386,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
CHECK(output[1] == IPC::MappedBufferDesc(output_buffer.GetSize(), IPC::W));
|
||||
CHECK(output[2] == target_address);
|
||||
CHECK(output_mem->Vector() == input_buffer);
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address, output_buffer.GetSize()) ==
|
||||
RESULT_SUCCESS);
|
||||
REQUIRE(process->vm_manager.UnmapRange(
|
||||
target_address, static_cast<u32>(output_buffer.GetSize())) == RESULT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,14 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
SECTION("mapping memory") {
|
||||
// Because of the PageTable, Kernel::VMManager is too big to be created on the stack.
|
||||
auto manager = std::make_unique<Kernel::VMManager>(memory);
|
||||
auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block, block.GetSize(),
|
||||
Kernel::MemoryState::Private);
|
||||
auto result =
|
||||
manager->MapBackingMemory(Memory::HEAP_VADDR, block, static_cast<u32>(block.GetSize()),
|
||||
Kernel::MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
CHECK(vma->second.size == block.GetSize());
|
||||
CHECK(vma->second.size == static_cast<u32>(block.GetSize()));
|
||||
CHECK(vma->second.type == Kernel::VMAType::BackingMemory);
|
||||
CHECK(vma->second.backing_memory.GetPtr() == block.GetPtr());
|
||||
CHECK(vma->second.meminfo_state == Kernel::MemoryState::Private);
|
||||
|
@ -31,11 +32,13 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
SECTION("unmapping memory") {
|
||||
// Because of the PageTable, Kernel::VMManager is too big to be created on the stack.
|
||||
auto manager = std::make_unique<Kernel::VMManager>(memory);
|
||||
auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block, block.GetSize(),
|
||||
Kernel::MemoryState::Private);
|
||||
auto result =
|
||||
manager->MapBackingMemory(Memory::HEAP_VADDR, block, static_cast<u32>(block.GetSize()),
|
||||
Kernel::MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
ResultCode code = manager->UnmapRange(Memory::HEAP_VADDR, block.GetSize());
|
||||
ResultCode code =
|
||||
manager->UnmapRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()));
|
||||
REQUIRE(code == RESULT_SUCCESS);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
|
@ -47,36 +50,39 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
SECTION("changing memory permissions") {
|
||||
// Because of the PageTable, Kernel::VMManager is too big to be created on the stack.
|
||||
auto manager = std::make_unique<Kernel::VMManager>(memory);
|
||||
auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block, block.GetSize(),
|
||||
Kernel::MemoryState::Private);
|
||||
auto result =
|
||||
manager->MapBackingMemory(Memory::HEAP_VADDR, block, static_cast<u32>(block.GetSize()),
|
||||
Kernel::MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
ResultCode code = manager->ReprotectRange(Memory::HEAP_VADDR, block.GetSize(),
|
||||
Kernel::VMAPermission::Execute);
|
||||
ResultCode code = manager->ReprotectRange(
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::VMAPermission::Execute);
|
||||
CHECK(code == RESULT_SUCCESS);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
CHECK(vma->second.permissions == Kernel::VMAPermission::Execute);
|
||||
|
||||
code = manager->UnmapRange(Memory::HEAP_VADDR, block.GetSize());
|
||||
code = manager->UnmapRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()));
|
||||
REQUIRE(code == RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
SECTION("changing memory state") {
|
||||
// Because of the PageTable, Kernel::VMManager is too big to be created on the stack.
|
||||
auto manager = std::make_unique<Kernel::VMManager>(memory);
|
||||
auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block, block.GetSize(),
|
||||
Kernel::MemoryState::Private);
|
||||
auto result =
|
||||
manager->MapBackingMemory(Memory::HEAP_VADDR, block, static_cast<u32>(block.GetSize()),
|
||||
Kernel::MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
|
||||
ResultCode code = manager->ReprotectRange(Memory::HEAP_VADDR, block.GetSize(),
|
||||
Kernel::VMAPermission::ReadWrite);
|
||||
ResultCode code =
|
||||
manager->ReprotectRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()),
|
||||
Kernel::VMAPermission::ReadWrite);
|
||||
REQUIRE(code == RESULT_SUCCESS);
|
||||
|
||||
SECTION("with invalid address") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
0xFFFFFFFF, block.GetSize(), Kernel::MemoryState::Locked,
|
||||
0xFFFFFFFF, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Locked,
|
||||
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Aliased,
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == Kernel::ERR_INVALID_ADDRESS);
|
||||
|
@ -84,7 +90,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
|
||||
SECTION("ignoring the original permissions") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Memory::HEAP_VADDR, block.GetSize(), Kernel::MemoryState::Private,
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Private,
|
||||
Kernel::VMAPermission::None, Kernel::MemoryState::Locked,
|
||||
Kernel::VMAPermission::Write);
|
||||
CHECK(code == RESULT_SUCCESS);
|
||||
|
@ -97,7 +103,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
|
||||
SECTION("enforcing the original permissions with correct expectations") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Memory::HEAP_VADDR, block.GetSize(), Kernel::MemoryState::Private,
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Private,
|
||||
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Aliased,
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == RESULT_SUCCESS);
|
||||
|
@ -110,7 +116,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
|
||||
SECTION("with incorrect permission expectations") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Memory::HEAP_VADDR, block.GetSize(), Kernel::MemoryState::Private,
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Private,
|
||||
Kernel::VMAPermission::Execute, Kernel::MemoryState::Aliased,
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == Kernel::ERR_INVALID_ADDRESS_STATE);
|
||||
|
@ -123,7 +129,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
|
||||
SECTION("with incorrect state expectations") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Memory::HEAP_VADDR, block.GetSize(), Kernel::MemoryState::Locked,
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Locked,
|
||||
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Aliased,
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == Kernel::ERR_INVALID_ADDRESS_STATE);
|
||||
|
@ -134,7 +140,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
CHECK(vma->second.meminfo_state == Kernel::MemoryState::Private);
|
||||
}
|
||||
|
||||
code = manager->UnmapRange(Memory::HEAP_VADDR, block.GetSize());
|
||||
code = manager->UnmapRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()));
|
||||
REQUIRE(code == RESULT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue