From 428a6078840a25277cd841b30e595af417014718 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Thu, 29 Jun 2023 08:59:50 +0530 Subject: [PATCH] SWDEV-400119 - Added Unit_hipMemGetInfo_FreeLessThanTotal (#329) Change-Id: Ia023d41ce4f941a03bccb8bf7dd59021e19d83b8 [ROCm/hip-tests commit: 839f3f5f02a5f6dc3ac93df5997993f90e343349] --- .../hip-tests/catch/unit/memory/hipMemGetInfo.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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)); +}