2019-04-01 17:39:55 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
2019-04-08 19:08:08 +08:00
|
|
|
#include "runtime/platform/platform.h"
|
2019-04-01 17:39:55 +08:00
|
|
|
#include "unit_tests/api/cl_api_tests.h"
|
|
|
|
#include "unit_tests/mocks/mock_aub_center.h"
|
|
|
|
#include "unit_tests/mocks/mock_aub_manager.h"
|
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
|
|
|
namespace ULT {
|
|
|
|
|
2019-04-08 19:08:08 +08:00
|
|
|
using clAddCommentToAubTest = api_tests;
|
|
|
|
|
|
|
|
TEST_F(clAddCommentToAubTest, givenProperCommentNullptrAubCenterWhenAddCommentToAubThenSuccessIsReturned) {
|
|
|
|
auto retVal = clAddCommentINTEL(pPlatform, "comment");
|
2019-04-04 23:13:50 +08:00
|
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
2019-04-01 17:39:55 +08:00
|
|
|
}
|
|
|
|
|
2019-04-08 19:08:08 +08:00
|
|
|
TEST_F(clAddCommentToAubTest, givenNullptrCommentWhenAddCommentToAubThenErrorIsReturned) {
|
|
|
|
auto retVal = clAddCommentINTEL(pPlatform, nullptr);
|
2019-04-01 17:39:55 +08:00
|
|
|
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
|
|
|
}
|
|
|
|
|
2019-04-08 19:08:08 +08:00
|
|
|
TEST_F(clAddCommentToAubTest, givenAubCenterAndProperCommentButNullptrAubManagerWhenAddCommentToAubThenErrorIsReturned) {
|
|
|
|
pPlatform->peekExecutionEnvironment()->aubCenter.reset(new MockAubCenter());
|
2019-04-01 17:39:55 +08:00
|
|
|
|
2019-04-08 19:08:08 +08:00
|
|
|
auto retVal = clAddCommentINTEL(pPlatform, "comment");
|
2019-04-01 17:39:55 +08:00
|
|
|
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
|
|
|
}
|
|
|
|
|
2019-04-08 19:08:08 +08:00
|
|
|
TEST_F(clAddCommentToAubTest, givenProperCommentAubCenterAndAubManagerWhenAddCommentToAubThenSuccessIsReturned) {
|
2019-04-01 17:39:55 +08:00
|
|
|
struct AubManagerCommentMock : public MockAubManager {
|
|
|
|
using MockAubManager::MockAubManager;
|
|
|
|
void addComment(const char *message) override {
|
|
|
|
addCommentCalled = true;
|
|
|
|
EXPECT_STREQ("comment", message);
|
|
|
|
}
|
|
|
|
bool addCommentCalled = false;
|
|
|
|
};
|
|
|
|
auto mockAubCenter = new MockAubCenter();
|
|
|
|
auto mockAubManager = new AubManagerCommentMock;
|
|
|
|
mockAubCenter->aubManager.reset(mockAubManager);
|
2019-04-08 19:08:08 +08:00
|
|
|
pPlatform->peekExecutionEnvironment()->aubCenter.reset(mockAubCenter);
|
2019-04-01 17:39:55 +08:00
|
|
|
|
|
|
|
EXPECT_FALSE(mockAubManager->addCommentCalled);
|
|
|
|
|
2019-04-08 19:08:08 +08:00
|
|
|
auto retVal = clAddCommentINTEL(pPlatform, "comment");
|
2019-04-01 17:39:55 +08:00
|
|
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
|
|
EXPECT_TRUE(mockAubManager->addCommentCalled);
|
|
|
|
}
|
|
|
|
} // namespace ULT
|