From 1104b93ee4944313d39bb7869dcba1ff21758d6d Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 16 Aug 2023 23:28:33 +0200 Subject: [PATCH] UnitTests: Declare as CPU thread when using CPUThreadConfigCallback This fixes a bunch of DEBUG_ASSERTs in the unit tests. --- Source/UnitTests/Core/PageFaultTest.cpp | 5 +++++ .../Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp | 5 +++++ Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp | 5 +++++ .../Core/PowerPC/JitArm64/ConvertSingleDouble.cpp | 8 ++++++++ Source/UnitTests/Core/PowerPC/JitArm64/FPRF.cpp | 5 +++++ Source/UnitTests/Core/PowerPC/JitArm64/Fres.cpp | 5 +++++ Source/UnitTests/Core/PowerPC/JitArm64/Frsqrte.cpp | 5 +++++ 7 files changed, 38 insertions(+) diff --git a/Source/UnitTests/Core/PageFaultTest.cpp b/Source/UnitTests/Core/PageFaultTest.cpp index ab0cdd7bcc..3f693923e0 100644 --- a/Source/UnitTests/Core/PageFaultTest.cpp +++ b/Source/UnitTests/Core/PageFaultTest.cpp @@ -5,7 +5,9 @@ #include #include "Common/CommonTypes.h" +#include "Common/ScopeGuard.h" #include "Common/Timer.h" +#include "Core/Core.h" #include "Core/MemTools.h" #include "Core/PowerPC/JitCommon/JitBase.h" #include "Core/PowerPC/JitInterface.h" @@ -75,6 +77,9 @@ TEST(PageFault, PageFault) EXPECT_NE(data, nullptr); Common::WriteProtectMemory(data, PAGE_GRAN, false); + Core::DeclareAsCPUThread(); + Common::ScopeGuard cpu_thread_guard([] { Core::UndeclareAsCPUThread(); }); + auto& system = Core::System::GetInstance(); auto unique_pfjit = std::make_unique(system); auto& pfjit = *unique_pfjit; diff --git a/Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp b/Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp index bbf6445357..09c0f30169 100644 --- a/Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp +++ b/Source/UnitTests/Core/PowerPC/Jit64Common/ConvertDoubleToSingle.cpp @@ -5,7 +5,9 @@ #include #include "Common/CommonTypes.h" +#include "Common/ScopeGuard.h" #include "Common/x64ABI.h" +#include "Core/Core.h" #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" #include "Core/PowerPC/Jit64/Jit.h" @@ -52,6 +54,9 @@ public: TEST(Jit64, ConvertDoubleToSingle) { + Core::DeclareAsCPUThread(); + Common::ScopeGuard cpu_thread_guard([] { Core::UndeclareAsCPUThread(); }); + TestCommonAsmRoutines routines(Core::System::GetInstance()); for (const u64 input : double_test_values) diff --git a/Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp b/Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp index d0ce6b3653..3300c07541 100644 --- a/Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp +++ b/Source/UnitTests/Core/PowerPC/Jit64Common/Frsqrte.cpp @@ -6,7 +6,9 @@ #include "Common/BitUtils.h" #include "Common/CommonTypes.h" #include "Common/FloatUtils.h" +#include "Common/ScopeGuard.h" #include "Common/x64ABI.h" +#include "Core/Core.h" #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/Jit64/Jit.h" #include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h" @@ -59,6 +61,9 @@ public: TEST(Jit64, Frsqrte) { + Core::DeclareAsCPUThread(); + Common::ScopeGuard cpu_thread_guard([] { Core::UndeclareAsCPUThread(); }); + TestCommonAsmRoutines routines(Core::System::GetInstance()); UReg_FPSCR fpscr; diff --git a/Source/UnitTests/Core/PowerPC/JitArm64/ConvertSingleDouble.cpp b/Source/UnitTests/Core/PowerPC/JitArm64/ConvertSingleDouble.cpp index 0e87fddcda..588a1622ef 100644 --- a/Source/UnitTests/Core/PowerPC/JitArm64/ConvertSingleDouble.cpp +++ b/Source/UnitTests/Core/PowerPC/JitArm64/ConvertSingleDouble.cpp @@ -7,6 +7,8 @@ #include "Common/BitUtils.h" #include "Common/CommonTypes.h" #include "Common/FPURoundMode.h" +#include "Common/ScopeGuard.h" +#include "Core/Core.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" #include "Core/PowerPC/JitArm64/Jit.h" #include "Core/System.h" @@ -120,6 +122,9 @@ private: TEST(JitArm64, ConvertDoubleToSingle) { + Core::DeclareAsCPUThread(); + Common::ScopeGuard cpu_thread_guard([] { Core::UndeclareAsCPUThread(); }); + TestConversion test(Core::System::GetInstance()); for (const u64 input : double_test_values) @@ -155,6 +160,9 @@ TEST(JitArm64, ConvertDoubleToSingle) TEST(JitArm64, ConvertSingleToDouble) { + Core::DeclareAsCPUThread(); + Common::ScopeGuard cpu_thread_guard([] { Core::UndeclareAsCPUThread(); }); + TestConversion test(Core::System::GetInstance()); for (const u32 input : single_test_values) diff --git a/Source/UnitTests/Core/PowerPC/JitArm64/FPRF.cpp b/Source/UnitTests/Core/PowerPC/JitArm64/FPRF.cpp index 285469b90f..0b7e250ae6 100644 --- a/Source/UnitTests/Core/PowerPC/JitArm64/FPRF.cpp +++ b/Source/UnitTests/Core/PowerPC/JitArm64/FPRF.cpp @@ -7,6 +7,8 @@ #include "Common/Arm64Emitter.h" #include "Common/BitUtils.h" #include "Common/CommonTypes.h" +#include "Common/ScopeGuard.h" +#include "Core/Core.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" #include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/PowerPC.h" @@ -70,6 +72,9 @@ static u32 RunUpdateFPRF(PowerPC::PowerPCState& ppc_state, const std::function