Skip to content

Commit 849e5c0

Browse files
Add tests for wait (#511)
1 parent c822d80 commit 849e5c0

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

dpctl-capi/source/dpctl_sycl_event_interface.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,15 @@ __dpctl_give DPCTLSyclEventRef DPCTLEvent_Create()
5252
void DPCTLEvent_Wait(__dpctl_keep DPCTLSyclEventRef ERef)
5353
{
5454
// \todo How to handle errors? E.g. when ERef is null or not a valid event.
55-
auto SyclEvent = unwrap(ERef);
56-
SyclEvent->wait();
55+
if (ERef) {
56+
auto SyclEvent = unwrap(ERef);
57+
if (SyclEvent)
58+
SyclEvent->wait();
59+
}
60+
else {
61+
std::cerr << "Cannot wait for the event. DPCTLSyclEventRef as input is "
62+
"a nullptr\n";
63+
}
5764
}
5865

5966
void DPCTLEvent_Delete(__dpctl_take DPCTLSyclEventRef ERef)

dpctl-capi/tests/test_sycl_event_interface.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ struct TestDPCTLSyclEventInterface : public ::testing::Test
5656
}
5757
};
5858

59+
TEST_F(TestDPCTLSyclEventInterface, CheckEvent_Wait)
60+
{
61+
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Wait(ERef));
62+
}
63+
64+
TEST_F(TestDPCTLSyclEventInterface, CheckWait_Invalid)
65+
{
66+
DPCTLSyclEventRef E = nullptr;
67+
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Wait(E));
68+
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Delete(E));
69+
}
70+
5971
TEST_F(TestDPCTLSyclEventInterface, CheckEvent_Copy)
6072
{
6173
DPCTLSyclEventRef Copied_ERef = nullptr;

0 commit comments

Comments
 (0)