From 94f8b620e4e9cca51f5f47acfa9f705ae4e45b61 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Fri, 5 Aug 2022 12:19:24 +0530 Subject: [PATCH] SWDEV-348686 - Add extension on windows platform for executable path. (#2845) Change-Id: Id7a9b6ec49e8f210b0a74b5f5fd68d584f005b4e [ROCm/hip commit: 768f186d69a7a0c3fef8a2aff0244d3ab16b70f6] --- projects/hip/tests/catch/include/hip_test_process.hh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/hip/tests/catch/include/hip_test_process.hh b/projects/hip/tests/catch/include/hip_test_process.hh index 335e6c7bba..2113dc85e1 100644 --- a/projects/hip/tests/catch/include/hip_test_process.hh +++ b/projects/hip/tests/catch/include/hip_test_process.hh @@ -66,7 +66,12 @@ class SpawnProc { auto dir = fs::path(TestContext::get().currentPath()); dir /= exeName; exeName = dir.string(); - + // On Windows, fs::exists returns false without extension. + if (TestContext::get().isWindows()) { + if(fs::path(exeName).extension().empty()) { + exeName += ".exe"; + } + } INFO("Testing that exe exists: " << exeName); REQUIRE(fs::exists(exeName)); @@ -92,13 +97,13 @@ class SpawnProc { execCmd += " > "; execCmd += tmpFileName; } - auto res = std::system(execCmd.c_str()); if (captureOutput) { std::ifstream t(tmpFileName.c_str()); resultStr = std::string((std::istreambuf_iterator(t)), std::istreambuf_iterator()); + t.close(); } #if HT_LINUX return WEXITSTATUS(res);