diff --git a/test/conformance/usm/CMakeLists.txt b/test/conformance/usm/CMakeLists.txt index 4331e5ba9e..1810a86507 100644 --- a/test/conformance/usm/CMakeLists.txt +++ b/test/conformance/usm/CMakeLists.txt @@ -2,8 +2,10 @@ # SPDX-License-Identifier: MIT add_conformance_test_with_devices_environment(usm - urUSMHostAlloc.cpp urUSMDeviceAlloc.cpp urUSMFree.cpp urUSMGetMemAllocInfo.cpp + urUSMHostAlloc.cpp + urUSMPoolCreate.cpp + urUSMPoolDestroy.cpp urUSMSharedAlloc.cpp) diff --git a/test/conformance/usm/urUSMPoolCreate.cpp b/test/conformance/usm/urUSMPoolCreate.cpp new file mode 100644 index 0000000000..81ebf97ac5 --- /dev/null +++ b/test/conformance/usm/urUSMPoolCreate.cpp @@ -0,0 +1,44 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: MIT + +#include + +using urUSMPoolCreateTest = uur::urContextTest; + +TEST_F(urUSMPoolCreateTest, Success) { + ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, + UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK}; + ur_usm_pool_handle_t pool = nullptr; + ASSERT_SUCCESS(urUSMPoolCreate(context, &pool_desc, &pool)); + ASSERT_NE(pool, nullptr); + EXPECT_SUCCESS(urUSMPoolDestroy(context, pool)); +} + +TEST_F(urUSMPoolCreateTest, InvalidNullHandleContext) { + ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, + UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK}; + ur_usm_pool_handle_t pool = nullptr; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urUSMPoolCreate(nullptr, &pool_desc, &pool)); +} + +TEST_F(urUSMPoolCreateTest, InvalidNullPointerPoolDesc) { + ur_usm_pool_handle_t pool = nullptr; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urUSMPoolCreate(context, nullptr, &pool)); +} + +TEST_F(urUSMPoolCreateTest, InvalidNullPointerPool) { + ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, + UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER, + urUSMPoolCreate(context, &pool_desc, nullptr)); +} + +TEST_F(urUSMPoolCreateTest, InvalidEnumerationFlags) { + ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, + UR_USM_POOL_FLAG_FORCE_UINT32}; + ur_usm_pool_handle_t pool = nullptr; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, + urUSMPoolCreate(context, &pool_desc, &pool)); +} diff --git a/test/conformance/usm/urUSMPoolDestroy.cpp b/test/conformance/usm/urUSMPoolDestroy.cpp new file mode 100644 index 0000000000..ee525b38d8 --- /dev/null +++ b/test/conformance/usm/urUSMPoolDestroy.cpp @@ -0,0 +1,39 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: MIT + +#include + +struct urUSMPoolDestroyTest : uur::urQueueTest { + + void SetUp() override { + UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::SetUp()); + ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr, + UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK}; + ASSERT_SUCCESS(urUSMPoolCreate(context, &pool_desc, &pool)); + ASSERT_NE(pool, nullptr); + } + + void TearDown() override { + if (pool) { + ASSERT_SUCCESS(urUSMPoolDestroy(context, pool)); + } + UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::TearDown()); + } + + ur_usm_pool_handle_t pool = nullptr; +}; + +TEST_F(urUSMPoolDestroyTest, Success) { + ASSERT_SUCCESS(urUSMPoolDestroy(context, pool)); + pool = nullptr; // prevent double-delete +} + +TEST_F(urUSMPoolDestroyTest, InvalidNullHandleContext) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urUSMPoolDestroy(nullptr, pool)); +} + +TEST_F(urUSMPoolDestroyTest, InvalidNullHandlePool) { + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urUSMPoolDestroy(context, nullptr)); +}