From 62ff5ca81d80258a55712411e5aa743612934328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Jun 2025 15:20:50 +0200 Subject: [PATCH] Unit test fix part #1: Get more information --- GPU/D3D11/D3D11Util.cpp | 6 +++--- unittest/UnitTest.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/GPU/D3D11/D3D11Util.cpp b/GPU/D3D11/D3D11Util.cpp index e232abb74d..fe63c99653 100644 --- a/GPU/D3D11/D3D11Util.cpp +++ b/GPU/D3D11/D3D11Util.cpp @@ -28,7 +28,7 @@ std::vector CompileShaderToBytecodeD3D11(const char *code, size_t codeS HRESULT result = ptr_D3DCompile(code, codeSize, nullptr, nullptr, nullptr, "main", target, flags, 0, &compiledCode, &errorMsgs); std::string errors; if (errorMsgs) { - errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize()); + errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize() > 1 ? (errorMsgs->GetBufferSize() - 1) : 0); std::string numberedCode = LineNumberString(code); if (SUCCEEDED(result)) { std::vector lines; @@ -45,9 +45,9 @@ std::vector CompileShaderToBytecodeD3D11(const char *code, size_t codeS } } else { ERROR_LOG(Log::G3D, "%s: %s\n\n%s", "errors", errors.c_str(), numberedCode.c_str()); + OutputDebugStringA(errors.c_str()); + OutputDebugStringA(numberedCode.c_str()); } - OutputDebugStringA(errors.c_str()); - OutputDebugStringA(numberedCode.c_str()); } if (compiledCode) { // Success! diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 6c977c6cc9..be4b2deabc 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -55,6 +55,7 @@ #include "Common/Data/Encoding/Utf8.h" #include "Common/Buffer.h" #include "Common/File/Path.h" +#include "Common/Log/LogManager.h" #include "Common/Math/SIMDHeaders.h" #include "Common/Math/CrossSIMD.h" // Get some more instructions for testing @@ -1311,6 +1312,7 @@ int main(int argc, const char *argv[]) { cpu_info.bVFPv3 = true; cpu_info.bVFPv4 = true; g_Config.bEnableLogging = true; + g_logManager.DisableOutput(LogOutput::DebugString); // not really needed bool allTests = false; TestFunc testFunc = nullptr; @@ -1329,7 +1331,8 @@ int main(int argc, const char *argv[]) { if (allTests) { int passes = 0; int fails = 0; - for (auto f : availableTests) { + for (const auto &f : availableTests) { + printf("\n**** Running test %s ****\n", f.name); if (f.func()) { ++passes; } else { @@ -1344,7 +1347,7 @@ int main(int argc, const char *argv[]) { printf("%d tests failed!\n", fails); return 2; } - } else if (testFunc == nullptr) { + } else if (!testFunc) { fprintf(stderr, "You may select a test to run by passing an argument, either \"all\" or one or more of the below.\n"); fprintf(stderr, "\n"); fprintf(stderr, "Available tests:\n");