From 30d579a81b2f6cccd58f554f6cec54cd36bf0a7d Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Tue, 1 Oct 2024 15:59:05 +0000 Subject: [PATCH] SWDEV-487649 - SWDEV-487639 - SWDEV-487636 - Fix memory leaks in catch tests Change-Id: I7943ecffec6d470789aabde07e6c52d6b871cc13 [ROCm/hip-tests commit: 9cf127697e8f1a163a610437a6d54688a3b67603] --- .../catch/unit/device/hipDeviceSynchronize.cc | 8 ++++++++ projects/hip-tests/catch/unit/g++/hipMalloc.cpp | 13 ++++++++++--- projects/hip-tests/catch/unit/gcc/hipMalloc.c | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/projects/hip-tests/catch/unit/device/hipDeviceSynchronize.cc b/projects/hip-tests/catch/unit/device/hipDeviceSynchronize.cc index 06f36922e7..221df92f7f 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceSynchronize.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceSynchronize.cc @@ -104,6 +104,8 @@ TEST_CASE("Unit_hipDeviceSynchronize_Positive_Nullstream") { b_context.unblock_stream(); HIP_CHECK(hipDeviceSynchronize()); REQUIRE(1 << 30 == A_h[0] - 1); + HIP_CHECK(hipHostFree(A_h)); + HIP_CHECK(hipFree(A_d)); } /** @@ -157,8 +159,14 @@ TEST_CASE("Unit_hipDeviceSynchronize_Functional") { } HIP_CHECK(hipDeviceSynchronize()); REQUIRE(NUM_ITERS == A[NUM_STREAMS - 1][0] - 1); + for (int i = 0; i < NUM_STREAMS; i++) { + HIP_CHECK(hipHostFree(A[i])); + HIP_CHECK(hipFree(Ad[i])); + HIP_CHECK(hipStreamDestroy(stream[i])); + } } + /** * End doxygen group DeviceTest. * @} diff --git a/projects/hip-tests/catch/unit/g++/hipMalloc.cpp b/projects/hip-tests/catch/unit/g++/hipMalloc.cpp index d954dc5e33..8a7b25b8f0 100644 --- a/projects/hip-tests/catch/unit/g++/hipMalloc.cpp +++ b/projects/hip-tests/catch/unit/g++/hipMalloc.cpp @@ -26,10 +26,17 @@ int MallocFunc() { hipError_t err; err = hipMalloc(reinterpret_cast(&Ad), 1024); if (err == hipSuccess) { - std::cout <<"PASSED!" <