Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion test/conformance/usm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
44 changes: 44 additions & 0 deletions test/conformance/usm/urUSMPoolCreate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: MIT

#include <uur/fixtures.h>

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));
}
39 changes: 39 additions & 0 deletions test/conformance/usm/urUSMPoolDestroy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: MIT

#include <uur/fixtures.h>

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