EXSWHTEC-171 - Hip graph creation and destruction tests (#35)

* EXSWHTEC-171 - Implement positive and negative unit tests for the following API's:
 - hipGraphCreate
 - hipGraphDestroy

[ROCm/hip-tests commit: 42ebc6cd10]
This commit is contained in:
Marko Veniger
2023-03-06 12:26:24 +01:00
committed by GitHub
parent f80f85f252
commit 9d19cc9a57
3 changed files with 85 additions and 71 deletions
@@ -20,25 +20,53 @@ THE SOFTWARE.
#include <hip_test_common.hh>
/**
Negative Testcase Scenarios :
1) Creating HipGraph with nullptr.
2) Creating hipGraph with non-zero mode.
*/
* @addtogroup hipGraphCreate hipGraphCreate
* @{
* @ingroup GraphTest
* `hipGraphCreate(hipGraph_t *pGraph, unsigned int flags)` -
* creates a graph
*/
TEST_CASE("Unit_hipGraphCreate_Negative") {
hipError_t ret;
SECTION("Creating HipGraph with nullptr") {
ret = hipGraphCreate(nullptr, 0);
REQUIRE(hipErrorInvalidValue == ret);
/**
* Test Description
* ------------------------
* - Negative parameter test for hipGraphCreate:
* -# Expected hipErrorInvalidValue when pGraph is null
* -# Expected hipErrorInvalidValue when flags is not 0
* Test source
* ------------------------
* - unit/graph/hipGraphCreate.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipGraphCreate_Negative_Parameters") {
hipGraph_t graph = nullptr;
SECTION("pGraph is nullptr") {
HIP_CHECK_ERROR(hipGraphCreate(nullptr, 0), hipErrorInvalidValue);
}
SECTION("Creating hipGraph with non-zero mode") {
hipGraph_t graph{};
ret = hipGraphCreate(&graph, -1);
REQUIRE(hipErrorInvalidValue == ret);
ret = hipGraphCreate(nullptr, -1);
REQUIRE(hipErrorInvalidValue == ret);
}
SECTION("flags is not 0") { HIP_CHECK_ERROR(hipGraphCreate(&graph, 1), hipErrorInvalidValue); }
}
/**
* Test Description
* ------------------------
* - Basic positive test for hipGraphCreate
* - Create an emtpy graph
* Test source
* ------------------------
* - unit/graph/hipGraphCreate.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipGraphCreate_Positive_Basic") {
hipGraph_t graph = nullptr;
HIP_CHECK(hipGraphCreate(&graph, 0));
REQUIRE(nullptr != graph);
HIP_CHECK(hipGraphDestroy(graph));
}