2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-18 15:11:08 +08:00
|
|
|
* Copyright (C) 2018 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "runtime/command_stream/aub_command_stream_receiver.h"
|
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
|
|
|
#include "runtime/command_stream/device_command_stream.h"
|
|
|
|
#include "runtime/command_stream/linear_stream.h"
|
|
|
|
#include "runtime/os_interface/linux/device_command_stream.inl"
|
|
|
|
#include "runtime/os_interface/linux/drm_command_stream.h"
|
2018-08-30 15:27:47 +08:00
|
|
|
#include "runtime/os_interface/linux/os_interface.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "hw_cmds.h"
|
|
|
|
#include "unit_tests/fixtures/device_fixture.h"
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
#include "unit_tests/os_interface/linux/device_command_stream_fixture.h"
|
|
|
|
|
|
|
|
using namespace OCLRT;
|
|
|
|
|
2018-03-29 06:38:41 +08:00
|
|
|
typedef Test<DeviceFixture> DeviceCommandStreamLeaksTest;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
HWTEST_F(DeviceCommandStreamLeaksTest, Create) {
|
2018-08-30 15:27:47 +08:00
|
|
|
this->executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
2018-08-08 19:49:09 +08:00
|
|
|
std::unique_ptr<CommandStreamReceiver> ptr(DeviceCommandStreamReceiver<FamilyType>::create(*platformDevices[0], false, this->executionEnvironment));
|
2017-12-21 07:45:38 +08:00
|
|
|
DrmMockSuccess mockDrm;
|
|
|
|
EXPECT_NE(nullptr, ptr);
|
|
|
|
}
|
|
|
|
|
2018-01-19 17:00:51 +08:00
|
|
|
HWTEST_F(DeviceCommandStreamLeaksTest, givenDefaultDrmCsrWhenItIsCreatedThenGemCloseWorkerInactiveModeIsSelected) {
|
2018-08-30 15:27:47 +08:00
|
|
|
this->executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
2018-08-08 19:49:09 +08:00
|
|
|
std::unique_ptr<CommandStreamReceiver> ptr(DeviceCommandStreamReceiver<FamilyType>::create(*platformDevices[0], false, this->executionEnvironment));
|
2017-12-21 07:45:38 +08:00
|
|
|
auto drmCsr = (DrmCommandStreamReceiver<FamilyType> *)ptr.get();
|
2018-05-11 15:57:59 +08:00
|
|
|
EXPECT_EQ(drmCsr->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerActive);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2018-01-19 17:00:51 +08:00
|
|
|
|
|
|
|
HWTEST_F(DeviceCommandStreamLeaksTest, givenDefaultDrmCsrWithAubDumWhenItIsCreatedThenGemCloseWorkerInactiveModeIsSelected) {
|
2018-08-30 15:27:47 +08:00
|
|
|
this->executionEnvironment.osInterface = std::make_unique<OSInterface>();
|
2018-08-08 19:49:09 +08:00
|
|
|
std::unique_ptr<CommandStreamReceiver> ptr(DeviceCommandStreamReceiver<FamilyType>::create(*platformDevices[0], true, this->executionEnvironment));
|
2018-01-19 17:00:51 +08:00
|
|
|
auto drmCsrWithAubDump = (CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<FamilyType>> *)ptr.get();
|
2018-05-11 15:57:59 +08:00
|
|
|
EXPECT_EQ(drmCsrWithAubDump->peekGemCloseWorkerOperationMode(), gemCloseWorkerMode::gemCloseWorkerActive);
|
2018-01-19 17:00:51 +08:00
|
|
|
auto aubCSR = static_cast<CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<FamilyType>> *>(ptr.get())->aubCSR;
|
|
|
|
EXPECT_NE(nullptr, aubCSR);
|
|
|
|
}
|
2018-08-30 15:27:47 +08:00
|
|
|
|
|
|
|
HWTEST_F(DeviceCommandStreamLeaksTest, givenDefaultDrmCsrWhenOsInterfaceIsNullptrThenValidateDrm) {
|
|
|
|
std::unique_ptr<CommandStreamReceiver> ptr(DeviceCommandStreamReceiver<FamilyType>::create(*platformDevices[0], false,
|
|
|
|
this->executionEnvironment));
|
|
|
|
auto drmCsr = (DrmCommandStreamReceiver<FamilyType> *)ptr.get();
|
|
|
|
EXPECT_NE(nullptr, executionEnvironment.osInterface);
|
|
|
|
EXPECT_EQ(drmCsr->getOSInterface()->get()->getDrm(), executionEnvironment.osInterface->get()->getDrm());
|
|
|
|
}
|