From 839bc1fc8753e5df9bcca35d1411b735e79568da Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 31 Mar 2023 23:51:04 -0700 Subject: [PATCH] headless: Fix screenshot failure. Needs to output to the collected output for it to actually show as a failure. --- headless/HeadlessHost.cpp | 12 +++++++++--- headless/HeadlessHost.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/headless/HeadlessHost.cpp b/headless/HeadlessHost.cpp index 7a88ca5bb3..b68f4ce094 100644 --- a/headless/HeadlessHost.cpp +++ b/headless/HeadlessHost.cpp @@ -42,14 +42,20 @@ void HeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) { ScreenshotComparer comparer(pixels, FRAME_STRIDE, FRAME_WIDTH, FRAME_HEIGHT); double errors = comparer.Compare(comparisonScreenshot_); if (errors < 0) - SendDebugOutput(comparer.GetError() + "\n"); + SendAndCollectOutput(comparer.GetError() + "\n"); if (errors > maxScreenshotError_) - SendDebugOutput(StringFromFormat("Screenshot MSE: %f\n", errors)); + SendAndCollectOutput(StringFromFormat("Screenshot MSE: %f\n", errors)); if (errors > maxScreenshotError_ && writeFailureScreenshot_) { if (comparer.SaveActualBitmap(Path("__testfailure.bmp"))) - SendDebugOutput("Actual output written to: __testfailure.bmp\n"); + SendAndCollectOutput("Actual output written to: __testfailure.bmp\n"); comparer.SaveVisualComparisonPNG(Path("__testcompare.png")); } } + +void HeadlessHost::SendAndCollectOutput(const std::string &output) { + SendDebugOutput(output); + if (PSP_CoreParameter().collectDebugOutput) + *PSP_CoreParameter().collectDebugOutput += output; +} diff --git a/headless/HeadlessHost.h b/headless/HeadlessHost.h index a40c8ff191..9f61bf08b3 100644 --- a/headless/HeadlessHost.h +++ b/headless/HeadlessHost.h @@ -62,6 +62,8 @@ public: virtual void SwapBuffers() {} protected: + void SendAndCollectOutput(const std::string &output); + Path comparisonScreenshot_; double maxScreenshotError_ = 0.0; std::string debugOutputBuffer_;