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)));