diff options
author | Subv <subv2112@gmail.com> | 2017-09-27 00:31:50 +0200 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2017-09-27 00:31:50 +0200 |
commit | a8d2f5787f998e08eccaa66c2fe0cdab997c2253 (patch) | |
tree | 88512c05bb39fc70043845d2c3c32fa18016619a /src/tests/core | |
parent | Tests: Fixed ARM VFP tests (diff) | |
download | yuzu-a8d2f5787f998e08eccaa66c2fe0cdab997c2253.tar yuzu-a8d2f5787f998e08eccaa66c2fe0cdab997c2253.tar.gz yuzu-a8d2f5787f998e08eccaa66c2fe0cdab997c2253.tar.bz2 yuzu-a8d2f5787f998e08eccaa66c2fe0cdab997c2253.tar.lz yuzu-a8d2f5787f998e08eccaa66c2fe0cdab997c2253.tar.xz yuzu-a8d2f5787f998e08eccaa66c2fe0cdab997c2253.tar.zst yuzu-a8d2f5787f998e08eccaa66c2fe0cdab997c2253.zip |
Diffstat (limited to 'src/tests/core')
-rw-r--r-- | src/tests/core/memory/memory.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/tests/core/memory/memory.cpp b/src/tests/core/memory/memory.cpp new file mode 100644 index 000000000..a01b896f7 --- /dev/null +++ b/src/tests/core/memory/memory.cpp @@ -0,0 +1,56 @@ +// Copyright 2017 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <catch.hpp> +#include "core/hle/kernel/memory.h" +#include "core/hle/kernel/process.h" +#include "core/memory.h" + +TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") { + SECTION("these regions should not be mapped on an empty process") { + auto process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::PROCESS_IMAGE_VADDR) == false); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::HEAP_VADDR) == false); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::LINEAR_HEAP_VADDR) == false); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::VRAM_VADDR) == false); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == false); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::TLS_AREA_VADDR) == false); + } + + SECTION("CONFIG_MEMORY_VADDR and SHARED_PAGE_VADDR should be valid after mapping them") { + auto process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); + Kernel::MapSharedPages(process->vm_manager); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == true); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == true); + } + + SECTION("special regions should be valid after mapping them") { + auto process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); + SECTION("VRAM") { + Kernel::HandleSpecialMapping(process->vm_manager, + {Memory::VRAM_VADDR, Memory::VRAM_SIZE, false, false}); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::VRAM_VADDR) == true); + } + + SECTION("IO (Not yet implemented)") { + Kernel::HandleSpecialMapping( + process->vm_manager, {Memory::IO_AREA_VADDR, Memory::IO_AREA_SIZE, false, false}); + CHECK_FALSE(Memory::IsValidVirtualAddress(*process, Memory::IO_AREA_VADDR) == true); + } + + SECTION("DSP") { + Kernel::HandleSpecialMapping( + process->vm_manager, {Memory::DSP_RAM_VADDR, Memory::DSP_RAM_SIZE, false, false}); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::DSP_RAM_VADDR) == true); + } + } + + SECTION("Unmapping a VAddr should make it invalid") { + auto process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); + Kernel::MapSharedPages(process->vm_manager); + process->vm_manager.UnmapRange(Memory::CONFIG_MEMORY_VADDR, Memory::CONFIG_MEMORY_SIZE); + CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false); + } +} |