From 78cf74fe189d742cdf1890c928722bfcf9f3d425 Mon Sep 17 00:00:00 2001 From: Jaydeep Patel Date: Thu, 30 Jan 2025 14:12:33 +0000 Subject: [PATCH] SWDEV-512585 - Don't use catch2's REQUIRE macro in child/worker thread which might fail. Change-Id: I513176259eb87879ea2bf557e923b2c2cd6166a2 [ROCm/hip-tests commit: 2356da049cd9857652a71a06de17f8315d834125] --- .../catch/unit/device/hipDeviceGetUuid.cc | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/projects/hip-tests/catch/unit/device/hipDeviceGetUuid.cc b/projects/hip-tests/catch/unit/device/hipDeviceGetUuid.cc index c42a2ae749..6094ffcc36 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceGetUuid.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceGetUuid.cc @@ -39,6 +39,9 @@ THE SOFTWARE. #endif #define COMMAND_LEN 256 #define BUFFER_LEN 512 + +std::atomic tState { 1 }; // 0:fail, 1:pass, 2:skip + /** * @addtogroup hipDeviceGetUuid hipDeviceGetUuid * @{ @@ -445,9 +448,15 @@ TEST_CASE("Unit_Uuid_FntlTstsFor_SetEnv_HIP_VISIBLE_DEVICES") { } void ChkUUID() { + if (tState == 2) { + return; + } int devCount = 0; HIP_CHECK(hipGetDeviceCount(&devCount)); - REQUIRE(devCount == 1); + if (devCount != 1) { + tState = 0; + return; + } hipDevice_t device; HIP_CHECK(hipSetDevice(0)); HIP_CHECK(hipDeviceGet(&device, 0)); @@ -463,7 +472,7 @@ void ChkUUID() { std::string uuid = uuid_map[0].data(); std::string t_uuid = uuid.substr(4, 19); if (memcmp(d_uuid.bytes, t_uuid.c_str(), 16) == 0) { - REQUIRE(true); + tState = 1; } } } @@ -481,7 +490,8 @@ void setEnv() { unsetenv("HIP_VISIBLE_DEVICES"); setenv("HIP_VISIBLE_DEVICES", uuidEnv.c_str(), 1); } else { - HipTest::HIP_SKIP_TEST("Skipping because this machine has total GPUs < 2"); // NOLINT + tState = 2; + HipTest::HIP_SKIP_TEST("Skipping because this machine has total GPUs < 2"); // NOLINT } } @@ -500,7 +510,8 @@ void setEnvLock() { unsetenv("HIP_VISIBLE_DEVICES"); setenv("HIP_VISIBLE_DEVICES", uuidEnv.c_str(), 1); } else { - HipTest::HIP_SKIP_TEST("Skipping because this machine has total GPUs < 2"); // NOLINT + tState = 2; + HipTest::HIP_SKIP_TEST("Skipping because this machine has total GPUs < 2"); // NOLINT } setLock.unlock(); } @@ -525,6 +536,7 @@ TEST_CASE("Unit_UUID_setEnv_Thread") { // Create Thread two std::thread t2(ChkUUID); t2.join(); + REQUIRE(tState != 0); } /** * Test Description @@ -553,6 +565,7 @@ TEST_CASE("Unit_UUID_setEnv_Thread_Lock") { std::thread t2(ChkUUID); t2.join(); t1.join(); + REQUIRE(tState != 0); } #endif /**