Interfaces to register resources

Change-Id: Ic587aaa5a41e4e7648211cfa730a0aa5bbc2985a
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-09-14 13:28:47 +02:00
committed by sys_ocldev
parent 9981cdd9e2
commit d363448515
23 changed files with 392 additions and 4 deletions

View File

@@ -15,7 +15,9 @@ DebugerL0CreateFn mockDebuggerL0HwFactory[IGFX_MAX_CORE];
namespace L0 {
std::unique_ptr<NEO::Debugger> DebuggerL0::create(NEO::Device *device) {
return std::unique_ptr<DebuggerL0>(ult::mockDebuggerL0HwFactory[device->getHardwareInfo().platform.eRenderCoreFamily](device));
auto debugger = ult::mockDebuggerL0HwFactory[device->getHardwareInfo().platform.eRenderCoreFamily](device);
debugger->registerResourceClasses();
return std::unique_ptr<DebuggerL0>(debugger);
}
} // namespace L0

View File

@@ -5,14 +5,54 @@
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
#include "test.h"
#include "level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h"
using namespace NEO;
namespace L0 {
namespace ult {
using L0DebuggerLinuxTest = Test<L0DebuggerFixture>;
struct L0DebuggerLinuxFixture {
void SetUp() {
auto executionEnvironment = new NEO::ExecutionEnvironment();
auto mockBuiltIns = new MockBuiltins();
executionEnvironment->prepareRootDeviceEnvironments(1);
executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
executionEnvironment->initializeMemoryManager();
auto osInterface = new OSInterface();
drmMock = new DrmMockResources(*executionEnvironment->rootDeviceEnvironments[0]);
executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(osInterface);
executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setDrm(static_cast<Drm *>(drmMock));
neoDevice = NEO::MockDevice::create<NEO::MockDevice>(executionEnvironment, 0u);
NEO::DeviceVector devices;
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
driverHandle = std::make_unique<Mock<L0::DriverHandleImp>>();
driverHandle->enableProgramDebugging = true;
driverHandle->initialize(std::move(devices));
device = driverHandle->devices[0];
}
void TearDown() {
}
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
NEO::MockDevice *neoDevice = nullptr;
L0::Device *device = nullptr;
DrmMockResources *drmMock = nullptr;
};
using L0DebuggerLinuxTest = Test<L0DebuggerLinuxFixture>;
TEST_F(L0DebuggerLinuxTest, givenProgramDebuggingEnabledWhenDriverHandleIsCreatedThenItAllocatesL0Debugger) {
EXPECT_NE(nullptr, neoDevice->getDebugger());
@@ -21,5 +61,11 @@ TEST_F(L0DebuggerLinuxTest, givenProgramDebuggingEnabledWhenDriverHandleIsCreate
EXPECT_EQ(nullptr, neoDevice->getSourceLevelDebugger());
}
TEST_F(L0DebuggerLinuxTest, whenDebuggerIsCreatedThenItCallsDrmToRegisterResourceClasses) {
EXPECT_NE(nullptr, neoDevice->getDebugger());
EXPECT_TRUE(drmMock->registerClassesCalled);
}
} // namespace ult
} // namespace L0