diff --git a/test/conformance/adapter/urAdapterGetInfo.cpp b/test/conformance/adapter/urAdapterGetInfo.cpp index b8604ccd19..395e55f67f 100644 --- a/test/conformance/adapter/urAdapterGetInfo.cpp +++ b/test/conformance/adapter/urAdapterGetInfo.cpp @@ -11,25 +11,24 @@ using urAdapterGetInfoTest = uur::urAdapterTest; UUR_INSTANTIATE_ADAPTER_TEST_SUITE_P(urAdapterGetInfoTest); -TEST_P(urAdapterGetInfoTest, Backend) { +TEST_P(urAdapterGetInfoTest, SuccessBackend) { auto info_type = UR_ADAPTER_INFO_BACKEND; size_t size = 0; - ASSERT_SUCCESS_OR_OPTIONAL_QUERY( - urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), info_type); - ASSERT_NE(size, 0); - + ASSERT_SUCCESS(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size)); ASSERT_EQ(size, sizeof(ur_adapter_backend_t)); - std::vector info_data(size); + ur_adapter_backend_t backend = UR_ADAPTER_BACKEND_UNKNOWN; ASSERT_SUCCESS( - urAdapterGetInfo(adapter, info_type, size, info_data.data(), nullptr)); + urAdapterGetInfo(adapter, info_type, size, &backend, nullptr)); + + ASSERT_TRUE(backend >= UR_ADAPTER_BACKEND_LEVEL_ZERO && + backend <= UR_ADAPTER_BACKEND_NATIVE_CPU); } -TEST_P(urAdapterGetInfoTest, ReferenceCount) { +TEST_P(urAdapterGetInfoTest, SuccessReferenceCount) { auto info_type = UR_ADAPTER_INFO_REFERENCE_COUNT; size_t size = 0; - ASSERT_SUCCESS_OR_OPTIONAL_QUERY( - urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), info_type); + ASSERT_SUCCESS(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size)); ASSERT_EQ(size, sizeof(uint32_t)); uint32_t reference_count = 0; @@ -38,6 +37,18 @@ TEST_P(urAdapterGetInfoTest, ReferenceCount) { ASSERT_GE(reference_count, 0); } +TEST_P(urAdapterGetInfoTest, SuccessVersion) { + auto info_type = UR_ADAPTER_INFO_VERSION; + size_t size = 0; + ASSERT_SUCCESS(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size)); + ASSERT_EQ(size, sizeof(uint32_t)); + + uint32_t returned_version = 46; + ASSERT_SUCCESS( + urAdapterGetInfo(adapter, info_type, size, &returned_version, nullptr)); + ASSERT_NE(42, returned_version); +} + TEST_P(urAdapterGetInfoTest, InvalidNullHandleAdapter) { size_t size = 0; ASSERT_EQ_RESULT( @@ -53,21 +64,21 @@ TEST_P(urAdapterGetInfoTest, InvalidEnumerationAdapterInfoType) { } TEST_P(urAdapterGetInfoTest, InvalidSizeZero) { - ur_adapter_backend_t backend; + ur_adapter_backend_t backend = UR_ADAPTER_BACKEND_UNKNOWN; ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, 0, &backend, nullptr), UR_RESULT_ERROR_INVALID_SIZE); } TEST_P(urAdapterGetInfoTest, InvalidSizeSmall) { - ur_adapter_backend_t backend; + ur_adapter_backend_t backend = UR_ADAPTER_BACKEND_UNKNOWN; ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, sizeof(backend) - 1, &backend, nullptr), UR_RESULT_ERROR_INVALID_SIZE); } TEST_P(urAdapterGetInfoTest, InvalidNullPointerPropValue) { - ur_adapter_backend_t backend; + ur_adapter_backend_t backend = UR_ADAPTER_BACKEND_UNKNOWN; ASSERT_EQ_RESULT(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, sizeof(backend), nullptr, nullptr), UR_RESULT_ERROR_INVALID_NULL_POINTER); @@ -78,21 +89,3 @@ TEST_P(urAdapterGetInfoTest, InvalidNullPointerPropSizeRet) { urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, 0, nullptr, nullptr), UR_RESULT_ERROR_INVALID_NULL_POINTER); } - -TEST_P(urAdapterGetInfoTest, ReferenceCountNotZero) { - uint32_t referenceCount = 0; - - ASSERT_SUCCESS(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_REFERENCE_COUNT, - sizeof(referenceCount), &referenceCount, - nullptr)); - ASSERT_GT(referenceCount, 0); -} - -TEST_P(urAdapterGetInfoTest, ValidAdapterBackend) { - ur_adapter_backend_t backend; - ASSERT_SUCCESS(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND, - sizeof(backend), &backend, nullptr)); - - ASSERT_TRUE(backend >= UR_ADAPTER_BACKEND_LEVEL_ZERO && - backend <= UR_ADAPTER_BACKEND_NATIVE_CPU); -} diff --git a/test/conformance/event/urEventGetInfo.cpp b/test/conformance/event/urEventGetInfo.cpp index 0057180f60..f4c9fa37ff 100644 --- a/test/conformance/event/urEventGetInfo.cpp +++ b/test/conformance/event/urEventGetInfo.cpp @@ -14,7 +14,7 @@ TEST_P(urEventGetInfoTest, SuccessCommandQueue) { ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size)); ASSERT_EQ(size, sizeof(ur_queue_handle_t)); - ur_queue_handle_t returned_queue; + ur_queue_handle_t returned_queue = nullptr; ASSERT_SUCCESS( urEventGetInfo(event, info_type, size, &returned_queue, nullptr)); @@ -28,7 +28,7 @@ TEST_P(urEventGetInfoTest, SuccessContext) { ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size)); ASSERT_EQ(size, sizeof(ur_context_handle_t)); - ur_context_handle_t returned_context; + ur_context_handle_t returned_context = nullptr; ASSERT_SUCCESS( urEventGetInfo(event, info_type, size, &returned_context, nullptr)); @@ -42,7 +42,7 @@ TEST_P(urEventGetInfoTest, SuccessCommandType) { ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size)); ASSERT_EQ(size, sizeof(ur_command_t)); - ur_command_t returned_command_type; + ur_command_t returned_command_type = UR_COMMAND_FORCE_UINT32; ASSERT_SUCCESS(urEventGetInfo(event, info_type, size, &returned_command_type, nullptr)); @@ -56,7 +56,7 @@ TEST_P(urEventGetInfoTest, SuccessCommandExecutionStatus) { ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size)); ASSERT_EQ(size, sizeof(ur_event_status_t)); - ur_event_status_t returned_status; + ur_event_status_t returned_status = UR_EVENT_STATUS_FORCE_UINT32; ASSERT_SUCCESS( urEventGetInfo(event, info_type, size, &returned_status, nullptr)); @@ -70,7 +70,7 @@ TEST_P(urEventGetInfoTest, SuccessReferenceCount) { ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size)); ASSERT_EQ(size, sizeof(uint32_t)); - uint32_t returned_reference_count; + uint32_t returned_reference_count = 0; ASSERT_SUCCESS(urEventGetInfo(event, info_type, size, &returned_reference_count, nullptr)); @@ -91,7 +91,7 @@ TEST_P(urEventGetInfoTest, InvalidNullHandle) { } TEST_P(urEventGetInfoTest, InvalidEnumeration) { - size_t size; + size_t size = 0; ASSERT_EQ_RESULT( urEventGetInfo(event, UR_EVENT_INFO_FORCE_UINT32, 0, nullptr, &size), UR_RESULT_ERROR_INVALID_ENUMERATION); @@ -111,9 +111,9 @@ TEST_P(urEventGetInfoTest, InvalidSizePropSize) { } TEST_P(urEventGetInfoTest, InvalidSizePropSizeSmall) { - ur_queue_handle_t q; + ur_queue_handle_t queue = nullptr; ASSERT_EQ_RESULT(urEventGetInfo(event, UR_EVENT_INFO_COMMAND_QUEUE, - sizeof(q) - 1, &q, nullptr), + sizeof(queue) - 1, &queue, nullptr), UR_RESULT_ERROR_INVALID_SIZE); } diff --git a/test/conformance/memory/memory_adapter_level_zero.match b/test/conformance/memory/memory_adapter_level_zero.match index d137fc5ac1..f9002d81fd 100644 --- a/test/conformance/memory/memory_adapter_level_zero.match +++ b/test/conformance/memory/memory_adapter_level_zero.match @@ -4,7 +4,7 @@ urMemBufferPartitionWithFlagsTest.Success/*__UR_MEM_FLAG_READ_ONLY urMemBufferPartitionTest.InvalidValueCreateType/* urMemBufferPartitionTest.InvalidValueBufferCreateInfoOutOfBounds/* {{OPT}}urMemImageCreateWithNativeHandleTest.Success/* -{{OPT}}urMemGetInfoImageTest.Success/*__UR_MEM_INFO_SIZE +{{OPT}}urMemGetInfoImageTest.SuccessSize/* {{OPT}}urMemImageCreateTestWithImageFormatParam.Success/*__UR_IMAGE_CHANNEL_ORDER_RGBA__* # These tests fail in the "Multi device testing" job, but pass in the hardware specific test diff --git a/test/conformance/memory/memory_adapter_native_cpu.match b/test/conformance/memory/memory_adapter_native_cpu.match index 4465185bed..0f97c5285d 100644 --- a/test/conformance/memory/memory_adapter_native_cpu.match +++ b/test/conformance/memory/memory_adapter_native_cpu.match @@ -2,7 +2,9 @@ urMemBufferPartitionWithFlagsTest.Success/*__UR_MEM_FLAG_WRITE_ONLY urMemBufferPartitionWithFlagsTest.Success/*__UR_MEM_FLAG_READ_ONLY urMemBufferPartitionTest.InvalidValueCreateType/* urMemBufferPartitionTest.InvalidValueBufferCreateInfoOutOfBounds/* -urMemGetInfoTestWithParam.Success/* +urMemGetInfoTest.SuccessSize/* +urMemGetInfoTest.SuccessContext/* +urMemGetInfoTest.SuccessReferenceCount/* urMemGetInfoTest.InvalidSizeSmall/* urMemReleaseTest.Success/* urMemReleaseTest.CheckReferenceCount/* diff --git a/test/conformance/memory/urMemGetInfo.cpp b/test/conformance/memory/urMemGetInfo.cpp index ddcc2761d0..99bba35a50 100644 --- a/test/conformance/memory/urMemGetInfo.cpp +++ b/test/conformance/memory/urMemGetInfo.cpp @@ -6,61 +6,51 @@ #include #include -using urMemGetInfoTestWithParam = uur::urMemBufferTestWithParam; - -static constexpr std::array mem_info_values{ - UR_MEM_INFO_SIZE, UR_MEM_INFO_CONTEXT, UR_MEM_INFO_REFERENCE_COUNT}; -static std::unordered_map mem_info_size_map = { - {UR_MEM_INFO_SIZE, sizeof(size_t)}, - {UR_MEM_INFO_CONTEXT, sizeof(ur_context_handle_t)}, - {UR_MEM_INFO_REFERENCE_COUNT, sizeof(uint32_t)}, -}; - -UUR_TEST_SUITE_P(urMemGetInfoTestWithParam, - ::testing::ValuesIn(mem_info_values), - uur::deviceTestWithParamPrinter); - -TEST_P(urMemGetInfoTestWithParam, Success) { - ur_mem_info_t info = getParam(); - size_t size; - ASSERT_SUCCESS_OR_OPTIONAL_QUERY( - urMemGetInfo(buffer, info, 0, nullptr, &size), info); - ASSERT_NE(size, 0); - - if (const auto expected_size = mem_info_size_map.find(info); - expected_size != mem_info_size_map.end()) { - ASSERT_EQ(expected_size->second, size); - } - - std::vector info_data(size); - ASSERT_SUCCESS(urMemGetInfo(buffer, info, size, info_data.data(), nullptr)); - - switch (info) { - case UR_MEM_INFO_CONTEXT: { - auto returned_context = - reinterpret_cast(info_data.data()); - ASSERT_EQ(context, *returned_context); - break; - } - case UR_MEM_INFO_SIZE: { - auto returned_size = reinterpret_cast(info_data.data()); - ASSERT_GE(*returned_size, allocation_size); - break; - } - case UR_MEM_INFO_REFERENCE_COUNT: { - const size_t ReferenceCount = - *reinterpret_cast(info_data.data()); - ASSERT_GT(ReferenceCount, 0); - break; - } - default: - break; - } -} - using urMemGetInfoTest = uur::urMemBufferTest; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemGetInfoTest); +TEST_P(urMemGetInfoTest, SuccessSize) { + ur_mem_info_t info_type = UR_MEM_INFO_SIZE; + size_t size = 0; + + ASSERT_SUCCESS(urMemGetInfo(buffer, info_type, 0, nullptr, &size)); + ASSERT_EQ(size, sizeof(size_t)); + + size_t returned_size = 0; + ASSERT_SUCCESS( + urMemGetInfo(buffer, info_type, size, &returned_size, nullptr)); + + ASSERT_GE(returned_size, allocation_size); +} + +TEST_P(urMemGetInfoTest, SuccessContext) { + ur_mem_info_t info_type = UR_MEM_INFO_CONTEXT; + size_t size = 0; + + ASSERT_SUCCESS(urMemGetInfo(buffer, info_type, 0, nullptr, &size)); + ASSERT_EQ(size, sizeof(ur_context_handle_t)); + + ur_context_handle_t returned_context = nullptr; + ASSERT_SUCCESS( + urMemGetInfo(buffer, info_type, size, &returned_context, nullptr)); + + ASSERT_EQ(context, returned_context); +} + +TEST_P(urMemGetInfoTest, SuccessReferenceCount) { + ur_mem_info_t info_type = UR_MEM_INFO_REFERENCE_COUNT; + size_t size = 0; + + ASSERT_SUCCESS(urMemGetInfo(buffer, info_type, 0, nullptr, &size)); + ASSERT_EQ(size, sizeof(uint32_t)); + + uint32_t returned_reference_count = 0; + ASSERT_SUCCESS(urMemGetInfo(buffer, info_type, size, + &returned_reference_count, nullptr)); + + ASSERT_GT(returned_reference_count, 0); +} + TEST_P(urMemGetInfoTest, InvalidNullHandleMemory) { size_t mem_size = 0; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, @@ -102,48 +92,52 @@ TEST_P(urMemGetInfoTest, InvalidNullPointerPropSizeRet) { UR_RESULT_ERROR_INVALID_NULL_POINTER); } -using urMemGetInfoImageTest = uur::urMemImageTestWithParam; -UUR_TEST_SUITE_P(urMemGetInfoImageTest, ::testing::ValuesIn(mem_info_values), - uur::deviceTestWithParamPrinter); - -TEST_P(urMemGetInfoImageTest, Success) { - ur_mem_info_t info = getParam(); - size_t size; - ASSERT_SUCCESS(urMemGetInfo(image, info, 0, nullptr, &size)); - ASSERT_NE(size, 0); - - if (const auto expected_size = mem_info_size_map.find(info); - expected_size != mem_info_size_map.end()) { - ASSERT_EQ(expected_size->second, size); - } - - std::vector info_data(size); - ASSERT_SUCCESS(urMemGetInfo(image, info, size, info_data.data(), nullptr)); - - switch (info) { - case UR_MEM_INFO_SIZE: { - const size_t ExpectedPixelSize = sizeof(float) * 4 /*NumChannels*/; - const size_t ExpectedImageSize = ExpectedPixelSize * desc.arraySize * - desc.width * desc.height * desc.depth; - const size_t ImageSizeBytes = - *reinterpret_cast(info_data.data()); - ASSERT_EQ(ImageSizeBytes, ExpectedImageSize); - break; - } - case UR_MEM_INFO_CONTEXT: { - ur_context_handle_t InfoContext = - *reinterpret_cast(info_data.data()); - ASSERT_EQ(InfoContext, context); - break; - } - case UR_MEM_INFO_REFERENCE_COUNT: { - const size_t ReferenceCount = - *reinterpret_cast(info_data.data()); - ASSERT_GT(ReferenceCount, 0); - break; - } - - default: - break; - } +using urMemGetInfoImageTest = uur::urMemImageTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urMemGetInfoImageTest); + +TEST_P(urMemGetInfoImageTest, SuccessSize) { + ur_mem_info_t info_type = UR_MEM_INFO_SIZE; + size_t size = 0; + + ASSERT_SUCCESS(urMemGetInfo(image, info_type, 0, nullptr, &size)); + ASSERT_EQ(size, sizeof(size_t)); + + size_t image_size_bytes = 0; + ASSERT_SUCCESS( + urMemGetInfo(image, info_type, size, &image_size_bytes, nullptr)); + + const size_t expected_pixel_size = sizeof(uint8_t) * 4; + const size_t expected_image_size = expected_pixel_size * + image_desc.arraySize * image_desc.width * + image_desc.height * image_desc.depth; + + ASSERT_EQ(image_size_bytes, expected_image_size); +} + +TEST_P(urMemGetInfoImageTest, SuccessContext) { + ur_mem_info_t info_type = UR_MEM_INFO_CONTEXT; + size_t size = 0; + + ASSERT_SUCCESS(urMemGetInfo(image, info_type, 0, nullptr, &size)); + ASSERT_EQ(size, sizeof(ur_context_handle_t)); + + ur_context_handle_t returned_context = nullptr; + ASSERT_SUCCESS( + urMemGetInfo(image, info_type, size, &returned_context, nullptr)); + + ASSERT_EQ(context, returned_context); +} + +TEST_P(urMemGetInfoImageTest, SuccessReferenceCount) { + ur_mem_info_t info_type = UR_MEM_INFO_REFERENCE_COUNT; + size_t size = 0; + + ASSERT_SUCCESS(urMemGetInfo(image, info_type, 0, nullptr, &size)); + ASSERT_EQ(size, sizeof(uint32_t)); + + uint32_t returned_reference_count = 0; + ASSERT_SUCCESS(urMemGetInfo(image, info_type, size, + &returned_reference_count, nullptr)); + + ASSERT_GT(returned_reference_count, 0); } diff --git a/test/conformance/queue/urQueueGetInfo.cpp b/test/conformance/queue/urQueueGetInfo.cpp index e513c9af77..e5ae17e9a8 100644 --- a/test/conformance/queue/urQueueGetInfo.cpp +++ b/test/conformance/queue/urQueueGetInfo.cpp @@ -14,12 +14,11 @@ TEST_P(urQueueGetInfoTest, Context) { urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_EQ(sizeof(ur_context_handle_t), size); - std::vector data(size); - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + ur_context_handle_t returned_context = nullptr; + ASSERT_SUCCESS( + urQueueGetInfo(queue, infoType, size, &returned_context, nullptr)); - auto returned_context = - reinterpret_cast(data.data()); - ASSERT_EQ(context, *returned_context); + ASSERT_EQ(context, returned_context); } TEST_P(urQueueGetInfoTest, Device) { @@ -29,11 +28,11 @@ TEST_P(urQueueGetInfoTest, Device) { urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_EQ(sizeof(ur_device_handle_t), size); - std::vector data(size); - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + ur_device_handle_t returned_device = nullptr; + ASSERT_SUCCESS( + urQueueGetInfo(queue, infoType, size, &returned_device, nullptr)); - auto returned_device = reinterpret_cast(data.data()); - ASSERT_EQ(device, *returned_device); + ASSERT_EQ(device, returned_device); } TEST_P(urQueueGetInfoTest, Flags) { @@ -43,11 +42,11 @@ TEST_P(urQueueGetInfoTest, Flags) { urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_EQ(sizeof(ur_queue_flags_t), size); - std::vector data(size); - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + ur_queue_flags_t returned_flags = 0; + ASSERT_SUCCESS( + urQueueGetInfo(queue, infoType, size, &returned_flags, nullptr)); - auto returned_flags = reinterpret_cast(data.data()); - EXPECT_EQ(*returned_flags, queue_properties.flags); + EXPECT_EQ(returned_flags, queue_properties.flags); } TEST_P(urQueueGetInfoTest, ReferenceCount) { @@ -57,11 +56,11 @@ TEST_P(urQueueGetInfoTest, ReferenceCount) { urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_EQ(sizeof(uint32_t), size); - std::vector data(size); - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + uint32_t returned_reference_count = 0; + ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, + &returned_reference_count, nullptr)); - auto returned_reference_count = reinterpret_cast(data.data()); - ASSERT_GT(*returned_reference_count, 0U); + ASSERT_GT(returned_reference_count, 0U); } TEST_P(urQueueGetInfoTest, EmptyQueue) { @@ -70,12 +69,6 @@ TEST_P(urQueueGetInfoTest, EmptyQueue) { ASSERT_SUCCESS_OR_OPTIONAL_QUERY( urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_EQ(sizeof(ur_bool_t), size); - - std::vector data(size); - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); - - auto returned_empty_queue = reinterpret_cast(data.data()); - ASSERT_TRUE(returned_empty_queue); } TEST_P(urQueueGetInfoTest, InvalidNullHandleQueue) { @@ -125,7 +118,7 @@ TEST_P(urQueueGetInfoTest, InvalidNullPointerPropSizeRet) { struct urQueueGetInfoDeviceQueueTestWithInfoParam : public uur::urQueueTest { void SetUp() { urQueueGetInfoTest::SetUp(); - ur_queue_flags_t deviceQueueCapabilities; + ur_queue_flags_t deviceQueueCapabilities = 0; ASSERT_SUCCESS( urDeviceGetInfo(device, UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES, sizeof(deviceQueueCapabilities), @@ -159,14 +152,13 @@ TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, DeviceDefault) { auto infoType = UR_QUEUE_INFO_DEVICE_DEFAULT; ASSERT_SUCCESS_OR_OPTIONAL_QUERY( urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); - ASSERT_NE(size, 0); ASSERT_EQ(sizeof(ur_queue_handle_t), size); - std::vector data(size); - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + ur_queue_handle_t returned_queue = nullptr; + ASSERT_SUCCESS( + urQueueGetInfo(queue, infoType, size, &returned_queue, nullptr)); - auto returned_queue = reinterpret_cast(data.data()); - ASSERT_EQ(queue, *returned_queue); + ASSERT_EQ(queue, returned_queue); } TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, Size) { @@ -175,12 +167,11 @@ TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, Size) { auto infoType = UR_QUEUE_INFO_SIZE; ASSERT_SUCCESS_OR_OPTIONAL_QUERY( urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); - ASSERT_NE(size, 0); ASSERT_EQ(sizeof(uint32_t), size); - std::vector data(size); - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, size, data.data(), nullptr)); + uint32_t returned_size = 0; + ASSERT_SUCCESS( + urQueueGetInfo(queue, infoType, size, &returned_size, nullptr)); - auto returned_size = reinterpret_cast(data.data()); - ASSERT_GT(*returned_size, 0); + ASSERT_GT(returned_size, 0); } diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 42896314cc..39f240789d 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -222,8 +222,8 @@ struct urSamplerTest : urContextTest { struct urMemBufferTest : urContextTest { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTest::SetUp()); - ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, 4096, - nullptr, &buffer)); + ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, + allocation_size, nullptr, &buffer)); ASSERT_NE(nullptr, buffer); } @@ -235,6 +235,7 @@ struct urMemBufferTest : urContextTest { } ur_mem_handle_t buffer = nullptr; + size_t allocation_size = 4096; }; struct urMemImageTest : urContextTest { @@ -333,24 +334,6 @@ template struct urSamplerTestWithParam : urContextTestWithParam { ur_sampler_desc_t sampler_desc; }; -template struct urMemBufferTestWithParam : urContextTestWithParam { - void SetUp() override { - UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); - ASSERT_SUCCESS(urMemBufferCreate(this->context, UR_MEM_FLAG_READ_WRITE, - allocation_size, nullptr, &buffer)); - ASSERT_NE(nullptr, buffer); - } - - void TearDown() override { - if (buffer) { - EXPECT_SUCCESS(urMemRelease(buffer)); - } - UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::TearDown()); - } - ur_mem_handle_t buffer = nullptr; - size_t allocation_size = 4096; -}; - template struct urMemImageTestWithParam : urContextTestWithParam { void SetUp() override { UUR_RETURN_ON_FATAL_FAILURE(urContextTestWithParam::SetUp()); diff --git a/test/conformance/virtual_memory/urPhysicalMemGetInfo.cpp b/test/conformance/virtual_memory/urPhysicalMemGetInfo.cpp index ca2595d0fa..d6a075a0de 100644 --- a/test/conformance/virtual_memory/urPhysicalMemGetInfo.cpp +++ b/test/conformance/virtual_memory/urPhysicalMemGetInfo.cpp @@ -14,14 +14,12 @@ TEST_P(urPhysicalMemGetInfoTest, Context) { physical_mem, UR_PHYSICAL_MEM_INFO_CONTEXT, 0, nullptr, &info_size)); ASSERT_NE(info_size, 0); - std::vector data(info_size); + ur_context_handle_t returned_context = nullptr; ASSERT_SUCCESS(urPhysicalMemGetInfo(physical_mem, - UR_PHYSICAL_MEM_INFO_CONTEXT, - data.size(), data.data(), nullptr)); + UR_PHYSICAL_MEM_INFO_CONTEXT, info_size, + &returned_context, nullptr)); - auto returned_context = - reinterpret_cast(data.data()); - ASSERT_EQ(context, *returned_context); + ASSERT_EQ(context, returned_context); } TEST_P(urPhysicalMemGetInfoTest, Device) { @@ -31,13 +29,12 @@ TEST_P(urPhysicalMemGetInfoTest, Device) { physical_mem, UR_PHYSICAL_MEM_INFO_DEVICE, 0, nullptr, &info_size)); ASSERT_NE(info_size, 0); - std::vector data(info_size); + ur_device_handle_t returned_device = nullptr; ASSERT_SUCCESS(urPhysicalMemGetInfo(physical_mem, - UR_PHYSICAL_MEM_INFO_DEVICE, - data.size(), data.data(), nullptr)); + UR_PHYSICAL_MEM_INFO_DEVICE, info_size, + &returned_device, nullptr)); - auto returned_device = reinterpret_cast(data.data()); - ASSERT_EQ(device, *returned_device); + ASSERT_EQ(device, returned_device); } TEST_P(urPhysicalMemGetInfoTest, Size) { @@ -47,12 +44,11 @@ TEST_P(urPhysicalMemGetInfoTest, Size) { 0, nullptr, &info_size)); ASSERT_NE(info_size, 0); - std::vector data(info_size); + size_t returned_size = 0; ASSERT_SUCCESS(urPhysicalMemGetInfo(physical_mem, UR_PHYSICAL_MEM_INFO_SIZE, - data.size(), data.data(), nullptr)); + info_size, &returned_size, nullptr)); - auto returned_size = reinterpret_cast(data.data()); - ASSERT_EQ(size, *returned_size); + ASSERT_EQ(size, returned_size); } TEST_P(urPhysicalMemGetInfoTest, Properties) { @@ -62,16 +58,14 @@ TEST_P(urPhysicalMemGetInfoTest, Properties) { physical_mem, UR_PHYSICAL_MEM_INFO_PROPERTIES, 0, nullptr, &info_size)); ASSERT_NE(info_size, 0); - std::vector data(info_size); - ASSERT_SUCCESS(urPhysicalMemGetInfo(physical_mem, - UR_PHYSICAL_MEM_INFO_PROPERTIES, - data.size(), data.data(), nullptr)); - - auto returned_properties = - reinterpret_cast(data.data()); - ASSERT_EQ(properties.stype, returned_properties->stype); - ASSERT_EQ(properties.pNext, returned_properties->pNext); - ASSERT_EQ(properties.flags, returned_properties->flags); + ur_physical_mem_properties_t returned_properties = {}; + ASSERT_SUCCESS( + urPhysicalMemGetInfo(physical_mem, UR_PHYSICAL_MEM_INFO_PROPERTIES, + info_size, &returned_properties, nullptr)); + + ASSERT_EQ(properties.stype, returned_properties.stype); + ASSERT_EQ(properties.pNext, returned_properties.pNext); + ASSERT_EQ(properties.flags, returned_properties.flags); } TEST_P(urPhysicalMemGetInfoTest, ReferenceCount) { @@ -82,12 +76,10 @@ TEST_P(urPhysicalMemGetInfoTest, ReferenceCount) { nullptr, &info_size)); ASSERT_NE(info_size, 0); - std::vector data(info_size); - ASSERT_SUCCESS(urPhysicalMemGetInfo(physical_mem, - UR_PHYSICAL_MEM_INFO_REFERENCE_COUNT, - data.size(), data.data(), nullptr)); + uint32_t returned_reference_count = 0; + ASSERT_SUCCESS( + urPhysicalMemGetInfo(physical_mem, UR_PHYSICAL_MEM_INFO_REFERENCE_COUNT, + info_size, &returned_reference_count, nullptr)); - const size_t ReferenceCount = - *reinterpret_cast(data.data()); - ASSERT_EQ(ReferenceCount, 1); + ASSERT_EQ(returned_reference_count, 1); }