Skip to content

Commit 62ff5ca

Browse files
committed
Unit test fix part #1: Get more information
1 parent 57cdda5 commit 62ff5ca

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

GPU/D3D11/D3D11Util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ std::vector<uint8_t> CompileShaderToBytecodeD3D11(const char *code, size_t codeS
2828
HRESULT result = ptr_D3DCompile(code, codeSize, nullptr, nullptr, nullptr, "main", target, flags, 0, &compiledCode, &errorMsgs);
2929
std::string errors;
3030
if (errorMsgs) {
31-
errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize());
31+
errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize() > 1 ? (errorMsgs->GetBufferSize() - 1) : 0);
3232
std::string numberedCode = LineNumberString(code);
3333
if (SUCCEEDED(result)) {
3434
std::vector<std::string_view> lines;
@@ -45,9 +45,9 @@ std::vector<uint8_t> CompileShaderToBytecodeD3D11(const char *code, size_t codeS
4545
}
4646
} else {
4747
ERROR_LOG(Log::G3D, "%s: %s\n\n%s", "errors", errors.c_str(), numberedCode.c_str());
48+
OutputDebugStringA(errors.c_str());
49+
OutputDebugStringA(numberedCode.c_str());
4850
}
49-
OutputDebugStringA(errors.c_str());
50-
OutputDebugStringA(numberedCode.c_str());
5151
}
5252
if (compiledCode) {
5353
// Success!

unittest/UnitTest.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "Common/Data/Encoding/Utf8.h"
5656
#include "Common/Buffer.h"
5757
#include "Common/File/Path.h"
58+
#include "Common/Log/LogManager.h"
5859
#include "Common/Math/SIMDHeaders.h"
5960
#include "Common/Math/CrossSIMD.h"
6061
// Get some more instructions for testing
@@ -1311,6 +1312,7 @@ int main(int argc, const char *argv[]) {
13111312
cpu_info.bVFPv3 = true;
13121313
cpu_info.bVFPv4 = true;
13131314
g_Config.bEnableLogging = true;
1315+
g_logManager.DisableOutput(LogOutput::DebugString); // not really needed
13141316

13151317
bool allTests = false;
13161318
TestFunc testFunc = nullptr;
@@ -1329,7 +1331,8 @@ int main(int argc, const char *argv[]) {
13291331
if (allTests) {
13301332
int passes = 0;
13311333
int fails = 0;
1332-
for (auto f : availableTests) {
1334+
for (const auto &f : availableTests) {
1335+
printf("\n**** Running test %s ****\n", f.name);
13331336
if (f.func()) {
13341337
++passes;
13351338
} else {
@@ -1344,7 +1347,7 @@ int main(int argc, const char *argv[]) {
13441347
printf("%d tests failed!\n", fails);
13451348
return 2;
13461349
}
1347-
} else if (testFunc == nullptr) {
1350+
} else if (!testFunc) {
13481351
fprintf(stderr, "You may select a test to run by passing an argument, either \"all\" or one or more of the below.\n");
13491352
fprintf(stderr, "\n");
13501353
fprintf(stderr, "Available tests:\n");

0 commit comments

Comments
 (0)