Split getDebugSession and createDebugSession logic

Related-To: NEO-4554

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2021-03-18 18:18:25 +00:00
committed by Compute-Runtime-Automation
parent 2a1a63a823
commit 1544c6d001
9 changed files with 57 additions and 8 deletions

View File

@@ -16,8 +16,10 @@ class OsInterfaceWithDebugAttach : public NEO::OSInterface {
public:
OsInterfaceWithDebugAttach() : OSInterface() {}
bool isDebugAttachAvailable() const override {
return true;
return debugAttachAvailable;
}
bool debugAttachAvailable = true;
};
struct DebugSessionMock : public L0::DebugSession {

View File

@@ -56,10 +56,12 @@ TEST_F(DebugApiTest, givenSubdeviceWhenGettingDebugSessionThenNullptrIsReturned)
}
TEST(DebugSessionTest, WhenDebugSessionCreateIsCalledThenNullptrReturned) {
ze_result_t result;
zet_debug_config_t config = {};
config.pid = 0x1234;
L0::DebugSession *session = L0::DebugSession::create(config, nullptr);
L0::DebugSession *session = L0::DebugSession::create(config, nullptr, result);
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
EXPECT_EQ(nullptr, session);
}

View File

@@ -135,5 +135,40 @@ TEST(DebugSessionTest, givenDeviceWithDebugSessionWhenRemoveCalledThenSessionIsN
EXPECT_EQ(nullptr, deviceImp.debugSession.get());
}
TEST(DebugSessionTest, givenSubDeviceWhenCreateingSessionThenNullptrReturned) {
zet_debug_config_t config = {};
config.pid = 0x1234;
NEO::Device *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), 0));
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
deviceImp.isSubdevice = true;
ze_result_t result = ZE_RESULT_ERROR_DEVICE_LOST;
auto session = deviceImp.createDebugSession(config, result);
EXPECT_EQ(nullptr, session);
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
}
TEST(DebugSessionTest, givenRootDeviceWhenCreateingSessionThenResultReturnedIsCorrect) {
zet_debug_config_t config = {};
config.pid = 0x1234;
NEO::Device *neoDevice(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get(), 0));
auto osInterface = new OsInterfaceWithDebugAttach;
osInterface->debugAttachAvailable = false;
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.reset(osInterface);
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
deviceImp.isSubdevice = false;
ze_result_t result = ZE_RESULT_ERROR_DEVICE_LOST;
auto session = deviceImp.createDebugSession(config, result);
EXPECT_EQ(nullptr, session);
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
}
} // namespace ult
} // namespace L0