diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index ebd494380e..131a0f05e2 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -4237,11 +4237,11 @@ cl_int CL_API_CALL clAddCommentINTEL(const char *comment) { auto executionEnvironment = platform()->peekExecutionEnvironment(); auto aubCenter = executionEnvironment->aubCenter.get(); - if (!comment || !aubCenter || !aubCenter->getAubManager()) { + if (!comment || (aubCenter && !aubCenter->getAubManager())) { retVal = CL_INVALID_VALUE; } - if (retVal == CL_SUCCESS) { + if (retVal == CL_SUCCESS && aubCenter) { aubCenter->getAubManager()->addComment(comment); } return retVal; diff --git a/unit_tests/api/cl_add_comment_to_aub_tests.inl b/unit_tests/api/cl_add_comment_to_aub_tests.inl index 1d494ed040..6352d3d9c2 100644 --- a/unit_tests/api/cl_add_comment_to_aub_tests.inl +++ b/unit_tests/api/cl_add_comment_to_aub_tests.inl @@ -14,17 +14,17 @@ using namespace NEO; namespace ULT { +TEST(clAddCommentToAubTest, givenProperCommentNullptrAubCenterWhenAddCommentToAubThenSuccessIsReturned) { + auto retVal = clAddCommentINTEL("comment"); + EXPECT_EQ(CL_SUCCESS, retVal); +} + TEST(clAddCommentToAubTest, givenNullptrCommentWhenAddCommentToAubThenErrorIsReturned) { auto retVal = clAddCommentINTEL(nullptr); EXPECT_EQ(CL_INVALID_VALUE, retVal); } -TEST(clAddCommentToAubTest, givenProperCommentAndNullptrAubCenterWhenAddCommentToAubThenErrorIsReturned) { - auto retVal = clAddCommentINTEL("comment"); - EXPECT_EQ(CL_INVALID_VALUE, retVal); -} - -TEST(clAddCommentToAubTest, givenProperCommentAndAubCenterButNullptrAubManagerWhenAddCommentToAubThenErrorIsReturned) { +TEST(clAddCommentToAubTest, givenAubCenterAndProperCommentButNullptrAubManagerWhenAddCommentToAubThenErrorIsReturned) { auto executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->aubCenter.reset(new MockAubCenter());