diff --git a/projects/hip-tests/catch/unit/memory/hipMemGetInfo.cc b/projects/hip-tests/catch/unit/memory/hipMemGetInfo.cc index 24d42bd8b4..80feaeb239 100644 --- a/projects/hip-tests/catch/unit/memory/hipMemGetInfo.cc +++ b/projects/hip-tests/catch/unit/memory/hipMemGetInfo.cc @@ -574,3 +574,18 @@ TEST_CASE("Unit_hipMemGetInfo_Negative") { HIP_CHECK(hipFree(A_mem)); } + +TEST_CASE("Unit_hipMemGetInfo_FreeLessThanTotal") { + unsigned int *A_mem{nullptr}; + size_t freeMemInit, totalMemInit; + size_t freeMem, totalMem; + + HIP_CHECK(hipMemGetInfo(&freeMemInit, &totalMemInit)); + REQUIRE(freeMemInit <= totalMemInit); + HIP_CHECK(hipMalloc(&A_mem, 1024)); + HIP_CHECK(hipMemGetInfo(&freeMem, &totalMem)); + REQUIRE(freeMem < totalMem); + REQUIRE(totalMem == totalMemInit); + + HIP_CHECK(hipFree(A_mem)); +}