Skip to content

Commit 1b015f9

Browse files
Extend parameterized test in test_sycl_queue_interface
Test with queues that use different properties, default/non-default error handler to improve coverage.
1 parent 48a5bb1 commit 1b015f9

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

dpctl-capi/tests/test_sycl_queue_interface.cpp

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

44+
void error_handler_fn(int err)
45+
{
46+
(void)err; // quieted unused argument compiler warning
47+
return;
48+
}
49+
4450
struct TestDPCTLQueueMemberFunctions
45-
: public ::testing::TestWithParam<const char *>
51+
: public ::testing::TestWithParam<
52+
std::tuple<const char *, DPCTLQueuePropertyType, bool>>
4653
{
4754
protected:
4855
DPCTLSyclQueueRef QRef = nullptr;
4956

5057
TestDPCTLQueueMemberFunctions()
5158
{
52-
auto DS = DPCTLFilterSelector_Create(GetParam());
59+
auto param_tuple = GetParam();
60+
auto DS = DPCTLFilterSelector_Create(std::get<0>(param_tuple));
5361
DPCTLSyclDeviceRef DRef = nullptr;
5462
if (DS) {
5563
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDevice_CreateFromSelector(DS));
56-
EXPECT_NO_FATAL_FAILURE(QRef = DPCTLQueue_CreateForDevice(
57-
DRef, nullptr, DPCTL_DEFAULT_PROPERTY));
64+
EXPECT_NO_FATAL_FAILURE(
65+
QRef = DPCTLQueue_CreateForDevice(
66+
DRef,
67+
(std::get<2>(param_tuple)) ? &error_handler_fn : nullptr,
68+
std::get<1>(param_tuple)));
5869
}
5970
DPCTLDevice_Delete(DRef);
6071
DPCTLDeviceSelector_Delete(DS);
@@ -63,8 +74,9 @@ struct TestDPCTLQueueMemberFunctions
6374
void SetUp()
6475
{
6576
if (!QRef) {
77+
auto param_tuple = GetParam();
6678
auto message = "Skipping as no device of type " +
67-
std::string(GetParam()) + ".";
79+
std::string(std::get<0>(param_tuple)) + ".";
6880
GTEST_SKIP_(message.c_str());
6981
}
7082
}
@@ -284,8 +296,14 @@ TEST_P(TestDPCTLQueueMemberFunctions, CheckGetDevice)
284296
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(D));
285297
}
286298

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

0 commit comments

Comments
 (0)