From d6a11260f212abb90f3c7deae4b9c8558bf46a2e Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Thu, 31 Mar 2022 14:28:53 +0530 Subject: [PATCH] SWDEV-306122 - [catch2][dtest] Adding Tests for hipGraphAddEmptyNode (#2592) 1. Added Negative Tests for hipGraphAddEmptyNode Change-Id: I31aab3dcff671700d18f9e4537bb1e21076ce375 [ROCm/hip commit: 95a6b9b80148baada47ad41d78885461fc65c0c3] --- .../catch/unit/graph/hipGraphAddEmptyNode.cc | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/projects/hip/tests/catch/unit/graph/hipGraphAddEmptyNode.cc b/projects/hip/tests/catch/unit/graph/hipGraphAddEmptyNode.cc index 5e30c1a07b..b21315dd2a 100644 --- a/projects/hip/tests/catch/unit/graph/hipGraphAddEmptyNode.cc +++ b/projects/hip/tests/catch/unit/graph/hipGraphAddEmptyNode.cc @@ -20,6 +20,7 @@ THE SOFTWARE. /** Testcase Scenarios : 1) Create and add empty node to graph and verify addition is successful. + 2) Negative Scenarios */ #include @@ -55,3 +56,45 @@ TEST_CASE("Unit_hipGraphAddEmptyNode_Functional") { HIP_CHECK(hipFree(pOutBuff_d)); HIP_CHECK(hipGraphDestroy(graph)); } + +/** + * Negative Scenarios hipGraphAddEmptyNode + */ +TEST_CASE("Unit_hipGraphAddEmptyNode_NegTest") { + char *pOutBuff_d{}; + constexpr size_t size = 1024; + hipGraph_t graph; + hipGraphNode_t memsetNode{}, emptyNode{}; + std::vector dependencies; + + HIP_CHECK(hipMalloc(&pOutBuff_d, size)); + hipMemsetParams memsetParams{}; + memsetParams.dst = reinterpret_cast(pOutBuff_d); + memsetParams.value = 0; + memsetParams.pitch = 0; + memsetParams.elementSize = sizeof(char); + memsetParams.width = size * sizeof(char); + memsetParams.height = 1; + HIP_CHECK(hipGraphCreate(&graph, 0)); + HIP_CHECK(hipGraphAddMemsetNode(&memsetNode, graph, nullptr, 0, + &memsetParams)); + dependencies.push_back(memsetNode); + // pGraphNode is nullptr + SECTION("Null Empty Graph Node") { + REQUIRE(hipErrorInvalidValue == hipGraphAddEmptyNode(nullptr, graph, + dependencies.data(), dependencies.size())); + } + // graph is nullptr + SECTION("Null Graph") { + REQUIRE(hipErrorInvalidValue == hipGraphAddEmptyNode(&emptyNode, nullptr, + dependencies.data(), dependencies.size())); + } + // pDependencies is nullptr + SECTION("Null Graph") { + REQUIRE(hipErrorInvalidValue == hipGraphAddEmptyNode(&emptyNode, graph, + nullptr, dependencies.size())); + } + + HIP_CHECK(hipFree(pOutBuff_d)); + HIP_CHECK(hipGraphDestroy(graph)); +}