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 /**