mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Refactoring HwDeviceId
Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
b2fae343ec
commit
67aa1ad7ec
@ -27,7 +27,7 @@
|
||||
|
||||
using NEO::constructPlatform;
|
||||
using NEO::Drm;
|
||||
using NEO::HwDeviceId;
|
||||
using NEO::HwDeviceIdDrm;
|
||||
using NEO::RootDeviceEnvironment;
|
||||
|
||||
static const int mockFd = 33;
|
||||
@ -36,7 +36,7 @@ static const char *mockPciPath = "";
|
||||
class DrmMockImpl : public Drm {
|
||||
public:
|
||||
DrmMockImpl(int fd) : DrmMockImpl(fd, *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]){};
|
||||
DrmMockImpl(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceId>(fd, mockPciPath), rootDeviceEnvironment){};
|
||||
DrmMockImpl(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(fd, mockPciPath), rootDeviceEnvironment){};
|
||||
|
||||
MOCK_METHOD2(ioctl, int(unsigned long request, void *arg));
|
||||
};
|
||||
@ -44,14 +44,14 @@ class DrmMockImpl : public Drm {
|
||||
class DrmMockSuccess : public Drm {
|
||||
public:
|
||||
DrmMockSuccess() : DrmMockSuccess(mockFd, *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {}
|
||||
DrmMockSuccess(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceId>(fd, mockPciPath), rootDeviceEnvironment) {}
|
||||
DrmMockSuccess(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(fd, mockPciPath), rootDeviceEnvironment) {}
|
||||
|
||||
int ioctl(unsigned long request, void *arg) override { return 0; };
|
||||
};
|
||||
|
||||
class DrmMockFail : public Drm {
|
||||
public:
|
||||
DrmMockFail() : Drm(std::make_unique<HwDeviceId>(mockFd, mockPciPath), *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {}
|
||||
DrmMockFail() : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, mockPciPath), *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {}
|
||||
|
||||
int ioctl(unsigned long request, void *arg) override { return -1; };
|
||||
};
|
||||
@ -334,7 +334,7 @@ class DrmMockCustom : public Drm {
|
||||
ioctl_res_ext = &NONE;
|
||||
}
|
||||
|
||||
DrmMockCustom() : Drm(std::make_unique<HwDeviceId>(mockFd, mockPciPath), *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {
|
||||
DrmMockCustom() : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, mockPciPath), *constructPlatform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {
|
||||
reset();
|
||||
ioctl_expected.contextCreate = static_cast<int>(NEO::HwHelper::get(NEO::defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*NEO::defaultHwInfo).size());
|
||||
ioctl_expected.contextDestroy = ioctl_expected.contextCreate.load();
|
||||
|
@ -37,7 +37,7 @@ class DrmMockForWorker : public Drm {
|
||||
std::atomic<int> gem_close_cnt;
|
||||
std::atomic<int> gem_close_expected;
|
||||
std::atomic<std::thread::id> ioctl_caller_thread_id;
|
||||
DrmMockForWorker() : Drm(std::make_unique<HwDeviceId>(mockFd, mockPciPath), *platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {
|
||||
DrmMockForWorker() : Drm(std::make_unique<HwDeviceIdDrm>(mockFd, mockPciPath), *platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]) {
|
||||
}
|
||||
int ioctl(unsigned long request, void *arg) override {
|
||||
if (_IOC_TYPE(request) == DRM_IOCTL_BASE) {
|
||||
|
@ -48,7 +48,7 @@ class DrmMock : public Drm {
|
||||
using Drm::translateTopologyInfo;
|
||||
using Drm::virtualMemoryIds;
|
||||
|
||||
DrmMock(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceId>(fd, ""), rootDeviceEnvironment) {
|
||||
DrmMock(int fd, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::make_unique<HwDeviceIdDrm>(fd, ""), rootDeviceEnvironment) {
|
||||
sliceCountChangeSupported = true;
|
||||
|
||||
if (rootDeviceEnvironment.executionEnvironment.isDebuggingEnabled()) {
|
||||
@ -88,11 +88,11 @@ class DrmMock : public Drm {
|
||||
}
|
||||
|
||||
void setFileDescriptor(int fd) {
|
||||
hwDeviceId = std::make_unique<HwDeviceId>(fd, "");
|
||||
hwDeviceId = std::make_unique<HwDeviceIdDrm>(fd, "");
|
||||
}
|
||||
|
||||
void setPciPath(const char *pciPath) {
|
||||
hwDeviceId = std::make_unique<HwDeviceId>(getFileDescriptor(), pciPath);
|
||||
hwDeviceId = std::make_unique<HwDeviceIdDrm>(getFileDescriptor(), pciPath);
|
||||
}
|
||||
|
||||
void setDeviceID(int deviceId) { this->deviceId = deviceId; }
|
||||
|
@ -31,7 +31,7 @@ class DrmMockDefault : public DrmMock {
|
||||
Drm **pDrmToReturnFromCreateFunc = nullptr;
|
||||
bool disableBindDefaultInTests = true;
|
||||
|
||||
Drm *Drm::create(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
rootDeviceEnvironment.setHwInfo(defaultHwInfo.get());
|
||||
if (pDrmToReturnFromCreateFunc) {
|
||||
return *pDrmToReturnFromCreateFunc;
|
||||
|
@ -440,7 +440,7 @@ TEST(HwDeviceId, whenHwDeviceIdIsDestroyedThenFileDescriptorIsClosed) {
|
||||
SysCalls::closeFuncCalled = 0;
|
||||
int fileDescriptor = 0x1234;
|
||||
{
|
||||
HwDeviceId hwDeviceId(fileDescriptor, "");
|
||||
HwDeviceIdDrm hwDeviceId(fileDescriptor, "");
|
||||
}
|
||||
EXPECT_EQ(1u, SysCalls::closeFuncCalled);
|
||||
EXPECT_EQ(fileDescriptor, SysCalls::closeFuncArgPassed);
|
||||
|
Reference in New Issue
Block a user