Skip to content

Commit bca7045

Browse files
author
Petr Vesely
committed
[CTS] Adds CTS tests for urUSMPoolCreate/Destroy
1 parent d6af758 commit bca7045

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

test/conformance/usm/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
# SPDX-License-Identifier: MIT
33

44
add_conformance_test_with_devices_environment(usm
5-
urUSMHostAlloc.cpp
65
urUSMDeviceAlloc.cpp
76
urUSMFree.cpp
87
urUSMGetMemAllocInfo.cpp
8+
urUSMHostAlloc.cpp
9+
urUSMPoolCreate.cpp
10+
urUSMPoolDestroy.cpp
911
urUSMSharedAlloc.cpp)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (C) 2023 Intel Corporation
2+
// SPDX-License-Identifier: MIT
3+
4+
#include <uur/fixtures.h>
5+
6+
using urUSMPoolCreateTest = uur::urContextTest;
7+
8+
TEST_F(urUSMPoolCreateTest, Success) {
9+
ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr,
10+
UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK};
11+
ur_usm_pool_handle_t pool = nullptr;
12+
ASSERT_SUCCESS(urUSMPoolCreate(context, &pool_desc, &pool));
13+
ASSERT_NE(pool, nullptr);
14+
EXPECT_SUCCESS(urUSMPoolDestroy(context, pool));
15+
}
16+
17+
TEST_F(urUSMPoolCreateTest, InvalidNullHandleContext) {
18+
ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr,
19+
UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK};
20+
ur_usm_pool_handle_t pool = nullptr;
21+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
22+
urUSMPoolCreate(nullptr, &pool_desc, &pool));
23+
}
24+
25+
TEST_F(urUSMPoolCreateTest, InvalidNullPointerPoolDesc) {
26+
ur_usm_pool_handle_t pool = nullptr;
27+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
28+
urUSMPoolCreate(context, nullptr, &pool));
29+
}
30+
31+
TEST_F(urUSMPoolCreateTest, InvalidNullPointerPool) {
32+
ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr,
33+
UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK};
34+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
35+
urUSMPoolCreate(context, &pool_desc, nullptr));
36+
}
37+
38+
TEST_F(urUSMPoolCreateTest, InvalidEnumerationFlags) {
39+
ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr,
40+
UR_USM_POOL_FLAG_FORCE_UINT32};
41+
ur_usm_pool_handle_t pool = nullptr;
42+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION,
43+
urUSMPoolCreate(context, &pool_desc, &pool));
44+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (C) 2023 Intel Corporation
2+
// SPDX-License-Identifier: MIT
3+
4+
#include <uur/fixtures.h>
5+
6+
struct urUSMPoolDestroyTest : uur::urQueueTest {
7+
8+
void SetUp() override {
9+
UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::SetUp());
10+
ur_usm_pool_desc_t pool_desc{UR_STRUCTURE_TYPE_USM_POOL_DESC, nullptr,
11+
UR_USM_POOL_FLAG_ZERO_INITIALIZE_BLOCK};
12+
ASSERT_SUCCESS(urUSMPoolCreate(context, &pool_desc, &pool));
13+
ASSERT_NE(pool, nullptr);
14+
}
15+
16+
void TearDown() override {
17+
if (pool) {
18+
ASSERT_SUCCESS(urUSMPoolDestroy(context, pool));
19+
}
20+
UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTest::TearDown());
21+
}
22+
23+
ur_usm_pool_handle_t pool = nullptr;
24+
};
25+
26+
TEST_F(urUSMPoolDestroyTest, Success) {
27+
ASSERT_SUCCESS(urUSMPoolDestroy(context, pool));
28+
pool = nullptr; // prevent double-delete
29+
}
30+
31+
TEST_F(urUSMPoolDestroyTest, InvalidNullHandleContext) {
32+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
33+
urUSMPoolDestroy(nullptr, pool));
34+
}
35+
36+
TEST_F(urUSMPoolDestroyTest, InvalidNullHandlePool) {
37+
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
38+
urUSMPoolDestroy(context, nullptr));
39+
}

0 commit comments

Comments
 (0)