diff options
| author | 2017-09-29 14:58:42 -0400 | |
|---|---|---|
| committer | 2017-09-29 14:58:42 -0400 | |
| commit | b07af7dda822898e9c8f231c5ddcd1741d93dbef (patch) | |
| tree | d41c9221d6065b8cf9e6a2405565b675a9c83c51 /src/tests | |
| parent | Merge pull request #2907 from Subv/warnings3 (diff) | |
| parent | Loaders: Don't automatically set the current process every time we load an ap... (diff) | |
| download | yuzu-b07af7dda822898e9c8f231c5ddcd1741d93dbef.tar.gz yuzu-b07af7dda822898e9c8f231c5ddcd1741d93dbef.tar.xz yuzu-b07af7dda822898e9c8f231c5ddcd1741d93dbef.zip | |
Merge pull request #2961 from Subv/load_titles
Loaders: Don't automatically set the current process every time we load an application.
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/tests/core/arm/arm_test_common.cpp | 22 | ||||
| -rw-r--r-- | src/tests/core/memory/memory.cpp | 56 |
3 files changed, 70 insertions, 9 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 5e9c4c2bf..1aac0daa2 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt | |||
| @@ -4,6 +4,7 @@ set(SRCS | |||
| 4 | core/arm/dyncom/arm_dyncom_vfp_tests.cpp | 4 | core/arm/dyncom/arm_dyncom_vfp_tests.cpp |
| 5 | core/file_sys/path_parser.cpp | 5 | core/file_sys/path_parser.cpp |
| 6 | core/hle/kernel/hle_ipc.cpp | 6 | core/hle/kernel/hle_ipc.cpp |
| 7 | core/memory/memory.cpp | ||
| 7 | glad.cpp | 8 | glad.cpp |
| 8 | tests.cpp | 9 | tests.cpp |
| 9 | ) | 10 | ) |
diff --git a/src/tests/core/arm/arm_test_common.cpp b/src/tests/core/arm/arm_test_common.cpp index cfe0d503a..484713a92 100644 --- a/src/tests/core/arm/arm_test_common.cpp +++ b/src/tests/core/arm/arm_test_common.cpp | |||
| @@ -3,30 +3,34 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/core.h" | 5 | #include "core/core.h" |
| 6 | #include "core/hle/kernel/process.h" | ||
| 6 | #include "core/memory.h" | 7 | #include "core/memory.h" |
| 7 | #include "core/memory_setup.h" | 8 | #include "core/memory_setup.h" |
| 8 | #include "tests/core/arm/arm_test_common.h" | 9 | #include "tests/core/arm/arm_test_common.h" |
| 9 | 10 | ||
| 10 | namespace ArmTests { | 11 | namespace ArmTests { |
| 11 | 12 | ||
| 12 | static Memory::PageTable page_table; | 13 | static Memory::PageTable* page_table = nullptr; |
| 13 | 14 | ||
| 14 | TestEnvironment::TestEnvironment(bool mutable_memory_) | 15 | TestEnvironment::TestEnvironment(bool mutable_memory_) |
| 15 | : mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) { | 16 | : mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) { |
| 16 | 17 | ||
| 17 | page_table.pointers.fill(nullptr); | 18 | Kernel::g_current_process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); |
| 18 | page_table.attributes.fill(Memory::PageType::Unmapped); | 19 | page_table = &Kernel::g_current_process->vm_manager.page_table; |
| 19 | page_table.cached_res_count.fill(0); | ||
| 20 | 20 | ||
| 21 | Memory::MapIoRegion(page_table, 0x00000000, 0x80000000, test_memory); | 21 | page_table->pointers.fill(nullptr); |
| 22 | Memory::MapIoRegion(page_table, 0x80000000, 0x80000000, test_memory); | 22 | page_table->attributes.fill(Memory::PageType::Unmapped); |
| 23 | page_table->cached_res_count.fill(0); | ||
| 23 | 24 | ||
| 24 | Memory::SetCurrentPageTable(&page_table); | 25 | Memory::MapIoRegion(*page_table, 0x00000000, 0x80000000, test_memory); |
| 26 | Memory::MapIoRegion(*page_table, 0x80000000, 0x80000000, test_memory); | ||
| 27 | |||
| 28 | Memory::SetCurrentPageTable(page_table); | ||
| 25 | } | 29 | } |
| 26 | 30 | ||
| 27 | TestEnvironment::~TestEnvironment() { | 31 | TestEnvironment::~TestEnvironment() { |
| 28 | Memory::UnmapRegion(page_table, 0x80000000, 0x80000000); | 32 | Memory::UnmapRegion(*page_table, 0x80000000, 0x80000000); |
| 29 | Memory::UnmapRegion(page_table, 0x00000000, 0x80000000); | 33 | Memory::UnmapRegion(*page_table, 0x00000000, 0x80000000); |
| 30 | } | 34 | } |
| 31 | 35 | ||
| 32 | void TestEnvironment::SetMemory64(VAddr vaddr, u64 value) { | 36 | void TestEnvironment::SetMemory64(VAddr vaddr, u64 value) { |
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 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <catch.hpp> | ||
| 6 | #include "core/hle/kernel/memory.h" | ||
| 7 | #include "core/hle/kernel/process.h" | ||
| 8 | #include "core/memory.h" | ||
| 9 | |||
| 10 | TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") { | ||
| 11 | SECTION("these regions should not be mapped on an empty process") { | ||
| 12 | auto process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); | ||
| 13 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::PROCESS_IMAGE_VADDR) == false); | ||
| 14 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::HEAP_VADDR) == false); | ||
| 15 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::LINEAR_HEAP_VADDR) == false); | ||
| 16 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::VRAM_VADDR) == false); | ||
| 17 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false); | ||
| 18 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == false); | ||
| 19 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::TLS_AREA_VADDR) == false); | ||
| 20 | } | ||
| 21 | |||
| 22 | SECTION("CONFIG_MEMORY_VADDR and SHARED_PAGE_VADDR should be valid after mapping them") { | ||
| 23 | auto process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); | ||
| 24 | Kernel::MapSharedPages(process->vm_manager); | ||
| 25 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == true); | ||
| 26 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == true); | ||
| 27 | } | ||
| 28 | |||
| 29 | SECTION("special regions should be valid after mapping them") { | ||
| 30 | auto process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); | ||
| 31 | SECTION("VRAM") { | ||
| 32 | Kernel::HandleSpecialMapping(process->vm_manager, | ||
| 33 | {Memory::VRAM_VADDR, Memory::VRAM_SIZE, false, false}); | ||
| 34 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::VRAM_VADDR) == true); | ||
| 35 | } | ||
| 36 | |||
| 37 | SECTION("IO (Not yet implemented)") { | ||
| 38 | Kernel::HandleSpecialMapping( | ||
| 39 | process->vm_manager, {Memory::IO_AREA_VADDR, Memory::IO_AREA_SIZE, false, false}); | ||
| 40 | CHECK_FALSE(Memory::IsValidVirtualAddress(*process, Memory::IO_AREA_VADDR) == true); | ||
| 41 | } | ||
| 42 | |||
| 43 | SECTION("DSP") { | ||
| 44 | Kernel::HandleSpecialMapping( | ||
| 45 | process->vm_manager, {Memory::DSP_RAM_VADDR, Memory::DSP_RAM_SIZE, false, false}); | ||
| 46 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::DSP_RAM_VADDR) == true); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | SECTION("Unmapping a VAddr should make it invalid") { | ||
| 51 | auto process = Kernel::Process::Create(Kernel::CodeSet::Create("", 0)); | ||
| 52 | Kernel::MapSharedPages(process->vm_manager); | ||
| 53 | process->vm_manager.UnmapRange(Memory::CONFIG_MEMORY_VADDR, Memory::CONFIG_MEMORY_SIZE); | ||
| 54 | CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false); | ||
| 55 | } | ||
| 56 | } | ||