55
66#include < uur/fixtures.h>
77
8- struct urUSMDeviceAllocTest : uur::urQueueTest {
8+ struct urUSMDeviceAllocTest : uur::urQueueTestWithParam<uur::BoolTestParam> {
99 void SetUp () override {
10- UUR_RETURN_ON_FATAL_FAILURE (uur::urQueueTest::SetUp ());
10+ UUR_RETURN_ON_FATAL_FAILURE (
11+ uur::urQueueTestWithParam<uur::BoolTestParam>::SetUp ());
1112 ur_device_usm_access_capability_flags_t deviceUSMSupport = 0 ;
1213 ASSERT_SUCCESS (
1314 uur::GetDeviceUSMDeviceSupport (device, deviceUSMSupport));
1415 if (!deviceUSMSupport) {
1516 GTEST_SKIP () << " Device USM is not supported." ;
1617 }
18+
19+ if (getParam ().value ) {
20+ ur_usm_pool_desc_t pool_desc = {};
21+ ASSERT_SUCCESS (urUSMPoolCreate (context, &pool_desc, &pool));
22+ }
23+ }
24+
25+ void TearDown () override {
26+ if (pool) {
27+ ASSERT_SUCCESS (urUSMPoolRelease (pool));
28+ }
29+ UUR_RETURN_ON_FATAL_FAILURE (
30+ uur::urQueueTestWithParam<uur::BoolTestParam>::TearDown ());
1731 }
32+
33+ ur_usm_pool_handle_t pool = nullptr ;
1834};
19- UUR_INSTANTIATE_DEVICE_TEST_SUITE_P (urUSMDeviceAllocTest);
35+
36+ UUR_TEST_SUITE_P (
37+ urUSMDeviceAllocTest,
38+ testing::ValuesIn (uur::BoolTestParam::makeBoolParam(" UsePool" )),
39+ uur::deviceTestWithParamPrinter<uur::BoolTestParam>);
2040
2141TEST_P (urUSMDeviceAllocTest, Success) {
2242 void *ptr = nullptr ;
2343 size_t allocation_size = sizeof (int );
24- ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , nullptr ,
44+ ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, nullptr , pool ,
2545 allocation_size, &ptr));
2646 ASSERT_NE (ptr, nullptr );
2747
@@ -47,7 +67,7 @@ TEST_P(urUSMDeviceAllocTest, SuccessWithDescriptors) {
4767 /* alignment */ 0 };
4868 void *ptr = nullptr ;
4969 size_t allocation_size = sizeof (int );
50- ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, &usm_desc, nullptr ,
70+ ASSERT_SUCCESS (urUSMDeviceAlloc (context, device, &usm_desc, pool ,
5171 allocation_size, &ptr));
5272
5373 ur_event_handle_t event = nullptr ;
@@ -64,27 +84,27 @@ TEST_P(urUSMDeviceAllocTest, InvalidNullHandleContext) {
6484 void *ptr = nullptr ;
6585 ASSERT_EQ_RESULT (
6686 UR_RESULT_ERROR_INVALID_NULL_HANDLE,
67- urUSMDeviceAlloc (nullptr , device, nullptr , nullptr , sizeof (int ), &ptr));
87+ urUSMDeviceAlloc (nullptr , device, nullptr , pool , sizeof (int ), &ptr));
6888}
6989
7090TEST_P (urUSMDeviceAllocTest, InvalidNullHandleDevice) {
7191 void *ptr = nullptr ;
72- ASSERT_EQ_RESULT (UR_RESULT_ERROR_INVALID_NULL_HANDLE,
73- urUSMDeviceAlloc (context, nullptr , nullptr , nullptr ,
74- sizeof (int ), &ptr));
92+ ASSERT_EQ_RESULT (
93+ UR_RESULT_ERROR_INVALID_NULL_HANDLE ,
94+ urUSMDeviceAlloc (context, nullptr , nullptr , pool, sizeof (int ), &ptr));
7595}
7696
7797TEST_P (urUSMDeviceAllocTest, InvalidNullPtrResult) {
78- ASSERT_EQ_RESULT (UR_RESULT_ERROR_INVALID_NULL_POINTER,
79- urUSMDeviceAlloc (context, device, nullptr , nullptr ,
80- sizeof (int ), nullptr ));
98+ ASSERT_EQ_RESULT (
99+ UR_RESULT_ERROR_INVALID_NULL_POINTER ,
100+ urUSMDeviceAlloc (context, device, nullptr , pool, sizeof (int ), nullptr ));
81101}
82102
83103TEST_P (urUSMDeviceAllocTest, InvalidUSMSize) {
84104 void *ptr = nullptr ;
85105 ASSERT_EQ_RESULT (
86106 UR_RESULT_ERROR_INVALID_USM_SIZE,
87- urUSMDeviceAlloc (context, device, nullptr , nullptr , -1 , &ptr));
107+ urUSMDeviceAlloc (context, device, nullptr , pool , -1 , &ptr));
88108}
89109
90110TEST_P (urUSMDeviceAllocTest, InvalidValueAlignPowerOfTwo) {
@@ -94,5 +114,5 @@ TEST_P(urUSMDeviceAllocTest, InvalidValueAlignPowerOfTwo) {
94114 desc.align = 5 ;
95115 ASSERT_EQ_RESULT (
96116 UR_RESULT_ERROR_INVALID_VALUE,
97- urUSMDeviceAlloc (context, device, &desc, nullptr , sizeof (int ), &ptr));
117+ urUSMDeviceAlloc (context, device, &desc, pool , sizeof (int ), &ptr));
98118}
0 commit comments