SWDEV-512585 - Don't use catch2's REQUIRE macro in child/worker thread which might fail.

Change-Id: I513176259eb87879ea2bf557e923b2c2cd6166a2


[ROCm/hip-tests commit: 2356da049c]
Tento commit je obsažen v:
Jaydeep Patel
2025-01-30 14:12:33 +00:00
odevzdal Jaydeepkumar Patel
rodič 6d77b4b783
revize 78cf74fe18
+17 -4
Zobrazit soubor
@@ -39,6 +39,9 @@ THE SOFTWARE.
#endif
#define COMMAND_LEN 256
#define BUFFER_LEN 512
std::atomic<int> 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
/**