Skip to content

Commit

Permalink
Add tests for wait (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-perevezentsev authored Jul 20, 2021
1 parent c822d80 commit 849e5c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 9 additions & 2 deletions dpctl-capi/source/dpctl_sycl_event_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ __dpctl_give DPCTLSyclEventRef DPCTLEvent_Create()
void DPCTLEvent_Wait(__dpctl_keep DPCTLSyclEventRef ERef)
{
// \todo How to handle errors? E.g. when ERef is null or not a valid event.
auto SyclEvent = unwrap(ERef);
SyclEvent->wait();
if (ERef) {
auto SyclEvent = unwrap(ERef);
if (SyclEvent)
SyclEvent->wait();
}
else {
std::cerr << "Cannot wait for the event. DPCTLSyclEventRef as input is "
"a nullptr\n";
}
}

void DPCTLEvent_Delete(__dpctl_take DPCTLSyclEventRef ERef)
Expand Down
12 changes: 12 additions & 0 deletions dpctl-capi/tests/test_sycl_event_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ struct TestDPCTLSyclEventInterface : public ::testing::Test
}
};

TEST_F(TestDPCTLSyclEventInterface, CheckEvent_Wait)
{
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Wait(ERef));
}

TEST_F(TestDPCTLSyclEventInterface, CheckWait_Invalid)
{
DPCTLSyclEventRef E = nullptr;
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Wait(E));
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Delete(E));
}

TEST_F(TestDPCTLSyclEventInterface, CheckEvent_Copy)
{
DPCTLSyclEventRef Copied_ERef = nullptr;
Expand Down

0 comments on commit 849e5c0

Please sign in to comment.