Skip to content

Commit

Permalink
Merge pull request #1394 from omarahmed1111/Add-missing-coverage-in-t…
Browse files Browse the repository at this point in the history
…he-CTS-tests

Add some missing validations in CTS
  • Loading branch information
omarahmed1111 authored Mar 12, 2024
2 parents 93e8469 + b4e3503 commit 252a3cc
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 7 deletions.
36 changes: 36 additions & 0 deletions test/conformance/device/urDeviceGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,42 @@ TEST_F(urDeviceGetTest, SuccessSubsetOfDevices) {
}
}

struct urDeviceGetTestWithDeviceTypeParam
: uur::urAllDevicesTest,
::testing::WithParamInterface<ur_device_type_t> {

void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(uur::urAllDevicesTest::SetUp());
}
};

INSTANTIATE_TEST_SUITE_P(
, urDeviceGetTestWithDeviceTypeParam,
::testing::Values(UR_DEVICE_TYPE_DEFAULT, UR_DEVICE_TYPE_GPU,
UR_DEVICE_TYPE_CPU, UR_DEVICE_TYPE_FPGA,
UR_DEVICE_TYPE_MCA, UR_DEVICE_TYPE_VPU),
[](const ::testing::TestParamInfo<ur_device_type_t> &info) {
std::stringstream ss;
ss << info.param;
return ss.str();
});

TEST_P(urDeviceGetTestWithDeviceTypeParam, Success) {
ur_device_type_t device_type = GetParam();
uint32_t count = 0;
ASSERT_SUCCESS(urDeviceGet(platform, device_type, 0, nullptr, &count));
ASSERT_GE(devices.size(), count);

if (count > 0) {
std::vector<ur_device_handle_t> devices(count);
ASSERT_SUCCESS(
urDeviceGet(platform, device_type, count, devices.data(), nullptr));
for (auto device : devices) {
ASSERT_NE(nullptr, device);
}
}
}

TEST_F(urDeviceGetTest, InvalidNullHandlePlatform) {
uint32_t count;
ASSERT_EQ_RESULT(
Expand Down
13 changes: 10 additions & 3 deletions test/conformance/enqueue/urEnqueueMemBufferMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ TEST_P(urEnqueueMemBufferMapTest, SuccessRead) {
}
}

TEST_P(urEnqueueMemBufferMapTest, SuccessWrite) {
using urEnqueueMemBufferMapTestWithWriteFlagParam =
uur::urMemBufferQueueTestWithParam<ur_map_flag_t>;
UUR_TEST_SUITE_P(urEnqueueMemBufferMapTestWithWriteFlagParam,
::testing::Values(UR_MAP_FLAG_WRITE,
UR_MAP_FLAG_WRITE_INVALIDATE_REGION),
uur::deviceTestWithParamPrinter<ur_map_flag_t>);

TEST_P(urEnqueueMemBufferMapTestWithWriteFlagParam, SuccessWrite) {
const std::vector<uint32_t> input(count, 0);
ASSERT_SUCCESS(urEnqueueMemBufferWrite(queue, buffer, true, 0, size,
input.data(), 0, nullptr, nullptr));

uint32_t *map = nullptr;
ASSERT_SUCCESS(urEnqueueMemBufferMap(queue, buffer, true, UR_MAP_FLAG_WRITE,
0, size, 0, nullptr, nullptr,
ASSERT_SUCCESS(urEnqueueMemBufferMap(queue, buffer, true, getParam(), 0,
size, 0, nullptr, nullptr,
(void **)&map));
for (unsigned i = 0; i < count; ++i) {
map[i] = 42;
Expand Down
12 changes: 12 additions & 0 deletions test/conformance/memory/urMemBufferCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ UUR_TEST_SUITE_P(urMemBufferCreateWithHostPtrFlagsTest,
UR_MEM_FLAG_USE_HOST_POINTER),
uur::deviceTestWithParamPrinter<ur_mem_flag_t>);

TEST_P(urMemBufferCreateWithHostPtrFlagsTest, SUCCESS) {
uur::raii::Mem host_ptr_buffer = nullptr;
ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_ALLOC_HOST_POINTER,
4096, nullptr, host_ptr_buffer.ptr()));

ur_buffer_properties_t properties{UR_STRUCTURE_TYPE_BUFFER_PROPERTIES,
nullptr, host_ptr_buffer.ptr()};
uur::raii::Mem buffer = nullptr;
ASSERT_SUCCESS(urMemBufferCreate(context, getParam(), 4096, &properties,
buffer.ptr()));
}

TEST_P(urMemBufferCreateWithHostPtrFlagsTest, InvalidHostPtr) {
uur::raii::Mem buffer = nullptr;
ASSERT_EQ_RESULT(
Expand Down
12 changes: 9 additions & 3 deletions test/conformance/platform/urPlatformGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ INSTANTIATE_TEST_SUITE_P(
urPlatformGetInfo, urPlatformGetInfoTest,
::testing::Values(UR_PLATFORM_INFO_NAME, UR_PLATFORM_INFO_VENDOR_NAME,
UR_PLATFORM_INFO_VERSION, UR_PLATFORM_INFO_EXTENSIONS,
UR_PLATFORM_INFO_PROFILE),
UR_PLATFORM_INFO_PROFILE, UR_PLATFORM_INFO_BACKEND),
[](const ::testing::TestParamInfo<ur_platform_info_t> &info) {
std::stringstream ss;
ss << info.param;
Expand All @@ -30,11 +30,17 @@ TEST_P(urPlatformGetInfoTest, Success) {
size_t size = 0;
ur_platform_info_t info_type = GetParam();
ASSERT_SUCCESS(urPlatformGetInfo(platform, info_type, 0, nullptr, &size));
ASSERT_NE(size, 0);
if (info_type == UR_PLATFORM_INFO_BACKEND) {
ASSERT_EQ(size, sizeof(ur_platform_backend_t));
} else {
ASSERT_NE(size, 0);
}
std::vector<char> name(size);
ASSERT_SUCCESS(
urPlatformGetInfo(platform, info_type, size, name.data(), nullptr));
ASSERT_EQ(size, std::strlen(name.data()) + 1);
if (info_type != UR_PLATFORM_INFO_BACKEND) {
ASSERT_EQ(size, std::strlen(name.data()) + 1);
}
}

TEST_P(urPlatformGetInfoTest, InvalidNullHandlePlatform) {
Expand Down
5 changes: 5 additions & 0 deletions test/conformance/program/urProgramBuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ TEST_P(urProgramBuildTest, Success) {
ASSERT_SUCCESS(urProgramBuild(context, program, nullptr));
}

TEST_P(urProgramBuildTest, SuccessWithOptions) {
const char *pOptions = "";
ASSERT_SUCCESS(urProgramBuild(context, program, pOptions));
}

TEST_P(urProgramBuildTest, InvalidNullHandleContext) {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
urProgramBuild(nullptr, program, nullptr));
Expand Down
9 changes: 9 additions & 0 deletions test/conformance/program/urProgramCreateWithIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ TEST_P(urProgramCreateWithILTest, Success) {
ASSERT_SUCCESS(urProgramRelease(program));
}

TEST_P(urProgramCreateWithILTest, SuccessWithProperties) {
ur_program_properties_t properties{UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES};
ur_program_handle_t program = nullptr;
ASSERT_SUCCESS(urProgramCreateWithIL(
context, il_binary->data(), il_binary->size(), &properties, &program));
ASSERT_NE(nullptr, program);
ASSERT_SUCCESS(urProgramRelease(program));
}

TEST_P(urProgramCreateWithILTest, InvalidNullHandle) {
ur_program_handle_t program = nullptr;
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
Expand Down
9 changes: 9 additions & 0 deletions test/conformance/queue/queue_adapter_native_cpu.match
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_PROFILING_ENABLE
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_ON_DEVICE
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_ON_DEVICE_DEFAULT
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_DISCARD_EVENTS
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_PRIORITY_LOW
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_PRIORITY_HIGH
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_SUBMISSION_BATCHED
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_USE_DEFAULT_STREAM
urQueueCreateWithParamTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM
urQueueFinishTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_
urQueueFlushTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_
urQueueGetInfoTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_CONTEXT
Expand Down
11 changes: 10 additions & 1 deletion test/conformance/queue/urQueueCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ TEST_P(urQueueCreateTest, Success) {
using urQueueCreateWithParamTest = uur::urContextTestWithParam<ur_queue_flag_t>;
UUR_TEST_SUITE_P(urQueueCreateWithParamTest,
testing::Values(UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE,
UR_QUEUE_FLAG_PROFILING_ENABLE),
UR_QUEUE_FLAG_PROFILING_ENABLE,
UR_QUEUE_FLAG_ON_DEVICE,
UR_QUEUE_FLAG_ON_DEVICE_DEFAULT,
UR_QUEUE_FLAG_DISCARD_EVENTS,
UR_QUEUE_FLAG_PRIORITY_LOW,
UR_QUEUE_FLAG_PRIORITY_HIGH,
UR_QUEUE_FLAG_SUBMISSION_BATCHED,
UR_QUEUE_FLAG_SUBMISSION_IMMEDIATE,
UR_QUEUE_FLAG_USE_DEFAULT_STREAM,
UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM),
uur::deviceTestWithParamPrinter<ur_queue_flag_t>);

TEST_P(urQueueCreateWithParamTest, SuccessWithProperties) {
Expand Down
20 changes: 20 additions & 0 deletions test/conformance/testing/include/uur/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,26 @@ struct urMemBufferQueueTest : urQueueTest {
ur_mem_handle_t buffer = nullptr;
};

template <class T>
struct urMemBufferQueueTestWithParam : urQueueTestWithParam<T> {
void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTestWithParam<T>::SetUp());
ASSERT_SUCCESS(urMemBufferCreate(this->context, UR_MEM_FLAG_READ_WRITE,
size, nullptr, &buffer));
}

void TearDown() override {
if (buffer) {
EXPECT_SUCCESS(urMemRelease(buffer));
}
UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTestWithParam<T>::TearDown());
}

const size_t count = 8;
const size_t size = sizeof(uint32_t) * count;
ur_mem_handle_t buffer = nullptr;
};

struct urMemImageQueueTest : urQueueTest {
void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(urQueueTest::SetUp());
Expand Down

0 comments on commit 252a3cc

Please sign in to comment.