From 676b326fb79355df7d55cbc14d2452618267228a Mon Sep 17 00:00:00 2001 From: Sebastian Luzynski Date: Wed, 7 Feb 2024 16:08:02 +0000 Subject: [PATCH] SWDEV-441276 - Add tests for hipDrvPointerGetAttributes Signed-off-by: Sebastian Luzynski Change-Id: I45621e39d6ec38401382b6d5d4f435f019207ee9 [ROCm/hip-tests commit: 501b7b5a80af26b5b8bde389ec5fa42642ca60e5] --- .../catch/unit/memory/hipDrvPtrGetAttributes.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/projects/hip-tests/catch/unit/memory/hipDrvPtrGetAttributes.cc b/projects/hip-tests/catch/unit/memory/hipDrvPtrGetAttributes.cc index 8aeb9b37b3..1183e299a6 100644 --- a/projects/hip-tests/catch/unit/memory/hipDrvPtrGetAttributes.cc +++ b/projects/hip-tests/catch/unit/memory/hipDrvPtrGetAttributes.cc @@ -55,7 +55,7 @@ TEST_CASE("Unit_hipDrvPtrGetAttributes_Negative") { hipHostMallocDefault)); HIP_CHECK(hipGetDevice(&deviceId)); unsigned int device_ordinal; - int *dev_ptr; + int *dev_ptr{nullptr}; void *data[2]; data[0] = &dev_ptr; data[1] = &device_ordinal; @@ -63,6 +63,11 @@ TEST_CASE("Unit_hipDrvPtrGetAttributes_Negative") { hipPointer_attribute attributes[] = {HIP_POINTER_ATTRIBUTE_DEVICE_POINTER, HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL}; + SECTION("Passing invalid number to numAttributes") { + REQUIRE(hipDrvPointerGetAttributes(0, attributes, data, + reinterpret_cast(A_d)) == hipErrorInvalidValue); + } + SECTION("Passing nullptr to attributes") { REQUIRE(hipDrvPointerGetAttributes(2, nullptr, data, reinterpret_cast(A_d)) == hipErrorInvalidValue); @@ -70,7 +75,7 @@ TEST_CASE("Unit_hipDrvPtrGetAttributes_Negative") { SECTION("Passing nullptr to data") { REQUIRE(hipDrvPointerGetAttributes(2, attributes, nullptr, - reinterpret_cast(A_d)) == hipErrorInvalidValue); + reinterpret_cast(A_d)) == hipErrorInvalidValue); } #if HT_AMD @@ -124,12 +129,12 @@ TEST_CASE("Unit_hipDrvPtrGetAttributes_Functional") { HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL, HIP_POINTER_ATTRIBUTE_DEVICE_POINTER, HIP_POINTER_ATTRIBUTE_RANGE_SIZE, - HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR}; + HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR}; HIP_CHECK(hipPointerGetAttribute(&dev_ptr1, HIP_POINTER_ATTRIBUTE_DEVICE_POINTER, reinterpret_cast(A_d + 100))); HIP_CHECK(hipPointerGetAttribute(&dev, - HIP_POINTER_ATTRIBUTE_DEVICE_POINTER, + HIP_POINTER_ATTRIBUTE_DEVICE_POINTER, reinterpret_cast(A_d))); HIP_CHECK(hipDrvPointerGetAttributes(5, attributes, data, reinterpret_cast(A_d + 100)));