summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/core/arm/arm_test_common.cpp15
-rw-r--r--src/tests/core/core_timing.cpp84
2 files changed, 26 insertions, 73 deletions
diff --git a/src/tests/core/arm/arm_test_common.cpp b/src/tests/core/arm/arm_test_common.cpp
index ac7ae3e52..17043346b 100644
--- a/src/tests/core/arm/arm_test_common.cpp
+++ b/src/tests/core/arm/arm_test_common.cpp
@@ -8,7 +8,6 @@
#include "core/core.h"
#include "core/hle/kernel/process.h"
#include "core/memory.h"
-#include "core/memory_setup.h"
#include "tests/core/arm/arm_test_common.h"
namespace ArmTests {
@@ -16,8 +15,9 @@ namespace ArmTests {
TestEnvironment::TestEnvironment(bool mutable_memory_)
: mutable_memory(mutable_memory_),
test_memory(std::make_shared<TestMemory>(this)), kernel{Core::System::GetInstance()} {
- auto process = Kernel::Process::Create(Core::System::GetInstance(), "",
- Kernel::Process::ProcessType::Userland);
+ auto& system = Core::System::GetInstance();
+
+ auto process = Kernel::Process::Create(system, "", Kernel::Process::ProcessType::Userland);
page_table = &process->VMManager().page_table;
std::fill(page_table->pointers.begin(), page_table->pointers.end(), nullptr);
@@ -25,15 +25,16 @@ TestEnvironment::TestEnvironment(bool mutable_memory_)
std::fill(page_table->attributes.begin(), page_table->attributes.end(),
Common::PageType::Unmapped);
- Memory::MapIoRegion(*page_table, 0x00000000, 0x80000000, test_memory);
- Memory::MapIoRegion(*page_table, 0x80000000, 0x80000000, test_memory);
+ system.Memory().MapIoRegion(*page_table, 0x00000000, 0x80000000, test_memory);
+ system.Memory().MapIoRegion(*page_table, 0x80000000, 0x80000000, test_memory);
kernel.MakeCurrentProcess(process.get());
}
TestEnvironment::~TestEnvironment() {
- Memory::UnmapRegion(*page_table, 0x80000000, 0x80000000);
- Memory::UnmapRegion(*page_table, 0x00000000, 0x80000000);
+ auto& system = Core::System::GetInstance();
+ system.Memory().UnmapRegion(*page_table, 0x80000000, 0x80000000);
+ system.Memory().UnmapRegion(*page_table, 0x00000000, 0x80000000);
}
void TestEnvironment::SetMemory64(VAddr vaddr, u64 value) {
diff --git a/src/tests/core/core_timing.cpp b/src/tests/core/core_timing.cpp
index 3443bf05e..1e3940801 100644
--- a/src/tests/core/core_timing.cpp
+++ b/src/tests/core/core_timing.cpp
@@ -7,7 +7,9 @@
#include <array>
#include <bitset>
#include <cstdlib>
+#include <memory>
#include <string>
+
#include "common/file_util.h"
#include "core/core.h"
#include "core/core_timing.h"
@@ -65,11 +67,16 @@ TEST_CASE("CoreTiming[BasicOrder]", "[core]") {
ScopeInit guard;
auto& core_timing = guard.core_timing;
- Core::Timing::EventType* cb_a = core_timing.RegisterEvent("callbackA", CallbackTemplate<0>);
- Core::Timing::EventType* cb_b = core_timing.RegisterEvent("callbackB", CallbackTemplate<1>);
- Core::Timing::EventType* cb_c = core_timing.RegisterEvent("callbackC", CallbackTemplate<2>);
- Core::Timing::EventType* cb_d = core_timing.RegisterEvent("callbackD", CallbackTemplate<3>);
- Core::Timing::EventType* cb_e = core_timing.RegisterEvent("callbackE", CallbackTemplate<4>);
+ std::shared_ptr<Core::Timing::EventType> cb_a =
+ Core::Timing::CreateEvent("callbackA", CallbackTemplate<0>);
+ std::shared_ptr<Core::Timing::EventType> cb_b =
+ Core::Timing::CreateEvent("callbackB", CallbackTemplate<1>);
+ std::shared_ptr<Core::Timing::EventType> cb_c =
+ Core::Timing::CreateEvent("callbackC", CallbackTemplate<2>);
+ std::shared_ptr<Core::Timing::EventType> cb_d =
+ Core::Timing::CreateEvent("callbackD", CallbackTemplate<3>);
+ std::shared_ptr<Core::Timing::EventType> cb_e =
+ Core::Timing::CreateEvent("callbackE", CallbackTemplate<4>);
// Enter slice 0
core_timing.ResetRun();
@@ -99,8 +106,8 @@ TEST_CASE("CoreTiming[FairSharing]", "[core]") {
ScopeInit guard;
auto& core_timing = guard.core_timing;
- Core::Timing::EventType* empty_callback =
- core_timing.RegisterEvent("empty_callback", EmptyCallback);
+ std::shared_ptr<Core::Timing::EventType> empty_callback =
+ Core::Timing::CreateEvent("empty_callback", EmptyCallback);
callbacks_done = 0;
u64 MAX_CALLBACKS = 10;
@@ -133,8 +140,10 @@ TEST_CASE("Core::Timing[PredictableLateness]", "[core]") {
ScopeInit guard;
auto& core_timing = guard.core_timing;
- Core::Timing::EventType* cb_a = core_timing.RegisterEvent("callbackA", CallbackTemplate<0>);
- Core::Timing::EventType* cb_b = core_timing.RegisterEvent("callbackB", CallbackTemplate<1>);
+ std::shared_ptr<Core::Timing::EventType> cb_a =
+ Core::Timing::CreateEvent("callbackA", CallbackTemplate<0>);
+ std::shared_ptr<Core::Timing::EventType> cb_b =
+ Core::Timing::CreateEvent("callbackB", CallbackTemplate<1>);
// Enter slice 0
core_timing.ResetRun();
@@ -145,60 +154,3 @@ TEST_CASE("Core::Timing[PredictableLateness]", "[core]") {
AdvanceAndCheck(core_timing, 0, 0, 10, -10); // (100 - 10)
AdvanceAndCheck(core_timing, 1, 1, 50, -50);
}
-
-namespace ChainSchedulingTest {
-static int reschedules = 0;
-
-static void RescheduleCallback(Core::Timing::CoreTiming& core_timing, u64 userdata,
- s64 cycles_late) {
- --reschedules;
- REQUIRE(reschedules >= 0);
- REQUIRE(lateness == cycles_late);
-
- if (reschedules > 0) {
- core_timing.ScheduleEvent(1000, reinterpret_cast<Core::Timing::EventType*>(userdata),
- userdata);
- }
-}
-} // namespace ChainSchedulingTest
-
-TEST_CASE("CoreTiming[ChainScheduling]", "[core]") {
- using namespace ChainSchedulingTest;
-
- ScopeInit guard;
- auto& core_timing = guard.core_timing;
-
- Core::Timing::EventType* cb_a = core_timing.RegisterEvent("callbackA", CallbackTemplate<0>);
- Core::Timing::EventType* cb_b = core_timing.RegisterEvent("callbackB", CallbackTemplate<1>);
- Core::Timing::EventType* cb_c = core_timing.RegisterEvent("callbackC", CallbackTemplate<2>);
- Core::Timing::EventType* cb_rs = core_timing.RegisterEvent(
- "callbackReschedule", [&core_timing](u64 userdata, s64 cycles_late) {
- RescheduleCallback(core_timing, userdata, cycles_late);
- });
-
- // Enter slice 0
- core_timing.ResetRun();
-
- core_timing.ScheduleEvent(800, cb_a, CB_IDS[0]);
- core_timing.ScheduleEvent(1000, cb_b, CB_IDS[1]);
- core_timing.ScheduleEvent(2200, cb_c, CB_IDS[2]);
- core_timing.ScheduleEvent(1000, cb_rs, reinterpret_cast<u64>(cb_rs));
- REQUIRE(800 == core_timing.GetDowncount());
-
- reschedules = 3;
- AdvanceAndCheck(core_timing, 0, 0); // cb_a
- AdvanceAndCheck(core_timing, 1, 1); // cb_b, cb_rs
- REQUIRE(2 == reschedules);
-
- core_timing.AddTicks(core_timing.GetDowncount());
- core_timing.Advance(); // cb_rs
- core_timing.SwitchContext(3);
- REQUIRE(1 == reschedules);
- REQUIRE(200 == core_timing.GetDowncount());
-
- AdvanceAndCheck(core_timing, 2, 3); // cb_c
-
- core_timing.AddTicks(core_timing.GetDowncount());
- core_timing.Advance(); // cb_rs
- REQUIRE(0 == reschedules);
-}