Skip to content

Commit 521d277

Browse files
author
Diptorup Deb
authored
Merge pull request #497 from IntelPython/improve-coverage-test-sycl-queue-interface
Extend parameterized test in test_sycl_queue_interface
2 parents 48a5bb1 + 2f38551 commit 521d277

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

dpctl-capi/tests/test_sycl_queue_interface.cpp

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,30 @@ namespace
4141
{
4242
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(queue, DPCTLSyclQueueRef);
4343

44+
void error_handler_fn(int /*err*/)
45+
{
46+
return;
47+
}
48+
4449
struct TestDPCTLQueueMemberFunctions
45-
: public ::testing::TestWithParam<const char *>
50+
: public ::testing::TestWithParam<
51+
std::tuple<const char *, DPCTLQueuePropertyType, bool>>
4652
{
4753
protected:
4854
DPCTLSyclQueueRef QRef = nullptr;
4955

5056
TestDPCTLQueueMemberFunctions()
5157
{
52-
auto DS = DPCTLFilterSelector_Create(GetParam());
58+
auto param_tuple = GetParam();
59+
auto DS = DPCTLFilterSelector_Create(std::get<0>(param_tuple));
5360
DPCTLSyclDeviceRef DRef = nullptr;
5461
if (DS) {
5562
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDevice_CreateFromSelector(DS));
56-
EXPECT_NO_FATAL_FAILURE(QRef = DPCTLQueue_CreateForDevice(
57-
DRef, nullptr, DPCTL_DEFAULT_PROPERTY));
63+
EXPECT_NO_FATAL_FAILURE(
64+
QRef = DPCTLQueue_CreateForDevice(
65+
DRef,
66+
(std::get<2>(param_tuple)) ? &error_handler_fn : nullptr,
67+
std::get<1>(param_tuple)));
5868
}
5969
DPCTLDevice_Delete(DRef);
6070
DPCTLDeviceSelector_Delete(DS);
@@ -63,8 +73,9 @@ struct TestDPCTLQueueMemberFunctions
6373
void SetUp()
6474
{
6575
if (!QRef) {
76+
auto param_tuple = GetParam();
6677
auto message = "Skipping as no device of type " +
67-
std::string(GetParam()) + ".";
78+
std::string(std::get<0>(param_tuple)) + ".";
6879
GTEST_SKIP_(message.c_str());
6980
}
7081
}
@@ -284,8 +295,14 @@ TEST_P(TestDPCTLQueueMemberFunctions, CheckGetDevice)
284295
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(D));
285296
}
286297

287-
INSTANTIATE_TEST_SUITE_P(DPCTLQueueMemberFuncTests,
288-
TestDPCTLQueueMemberFunctions,
289-
::testing::Values("opencl:gpu:0",
290-
"opencl:cpu:0",
291-
"level_zero:gpu:0"));
298+
INSTANTIATE_TEST_SUITE_P(
299+
DPCTLQueueMemberFuncTests,
300+
TestDPCTLQueueMemberFunctions,
301+
::testing::Combine(
302+
::testing::Values("opencl:gpu", "opencl:cpu", "level_zero:gpu"),
303+
::testing::Values(DPCTL_DEFAULT_PROPERTY,
304+
DPCTL_ENABLE_PROFILING,
305+
DPCTL_IN_ORDER,
306+
static_cast<DPCTLQueuePropertyType>(
307+
DPCTL_ENABLE_PROFILING | DPCTL_IN_ORDER)),
308+
::testing::Bool()));

dpctl-capi/tests/test_sycl_usm_interface.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ void common_test_body(size_t nbytes,
5757
EXPECT_TRUE(DPCTLDevice_AreEq(Dev, QueueDev));
5858

5959
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Prefetch(Q, Ptr, nbytes));
60+
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_MemAdvise(Q, Ptr, nbytes, 0));
61+
62+
try {
63+
unsigned short *host_ptr = new unsigned short[nbytes];
64+
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Memcpy(Q, host_ptr, Ptr, nbytes));
65+
delete[] host_ptr;
66+
} catch (std::bad_alloc const &ba) {
67+
// pass
68+
}
6069

6170
DPCTLDevice_Delete(QueueDev);
6271
DPCTLDevice_Delete(Dev);

0 commit comments

Comments
 (0)