From 051b82b7e9677f8a2433446ed254d3c88085044c Mon Sep 17 00:00:00 2001 From: Grzegorz Wawiorko Date: Fri, 4 Apr 2025 17:52:05 +0200 Subject: [PATCH] SPIR-V tests for scalar printf - fix for Windows OS (#2358) --- .../spirv_new/test_extinst_printf.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test_conformance/spirv_new/test_extinst_printf.cpp b/test_conformance/spirv_new/test_extinst_printf.cpp index d55935e2..117d44c9 100644 --- a/test_conformance/spirv_new/test_extinst_printf.cpp +++ b/test_conformance/spirv_new/test_extinst_printf.cpp @@ -94,7 +94,6 @@ struct StreamGrabber results.clear(); results.resize(filesize); is.read(&results[0], filesize); - return 0; } } @@ -106,6 +105,16 @@ struct StreamGrabber bool acquired = false; }; +void normalize_strings(std::string& input) +{ + // Normalize line endings: replace \r\n with \n + size_t pos = 0; + while ((pos = input.find("\r\n", pos)) != std::string::npos) + { + input.replace(pos, 2, "\n"); + } +} + // printf callback, for cl_arm_printf void CL_CALLBACK printfCallBack(const char* printf_data, size_t len, size_t final, void* user_data) @@ -162,12 +171,15 @@ static int printf_operands_helper(cl_device_id device, test_error(error, "unable to enqueue kernel"); std::string results; + std::string expectedResultsStr(expectedResults); grabber.get_results(results); + normalize_strings(results); + normalize_strings(expectedResultsStr); - if (results != std::string(expectedResults)) + if (results != expectedResultsStr) { log_error("Results do not match.\n"); - log_error("Expected: \n---\n%s---\n", expectedResults); + log_error("Expected: \n---\n%s---\n", expectedResultsStr.c_str()); log_error("Got: \n---\n%s---\n", results.c_str()); return TEST_FAIL; }