summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-11-27 03:48:56 +0100
committerGitHub <noreply@github.com>2019-11-27 03:48:56 +0100
commitec0ce96c568b2b610c5218efd7faa5d9a19350f8 (patch)
tree61b5133e3cc6a9edf3b45c5fe6604493689f6769 /src/tests
parentMerge pull request #3164 from ReinUsesLisp/half-cast-float (diff)
downloadyuzu-ec0ce96c568b2b610c5218efd7faa5d9a19350f8.tar
yuzu-ec0ce96c568b2b610c5218efd7faa5d9a19350f8.tar.gz
yuzu-ec0ce96c568b2b610c5218efd7faa5d9a19350f8.tar.bz2
yuzu-ec0ce96c568b2b610c5218efd7faa5d9a19350f8.tar.lz
yuzu-ec0ce96c568b2b610c5218efd7faa5d9a19350f8.tar.xz
yuzu-ec0ce96c568b2b610c5218efd7faa5d9a19350f8.tar.zst
yuzu-ec0ce96c568b2b610c5218efd7faa5d9a19350f8.zip
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/core/core_timing.cpp84
1 files changed, 18 insertions, 66 deletions
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);
-}