diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 9d9771cb4b..33a81bd859 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -976,6 +976,10 @@ bool Drm::queryMemoryInfo() { bool Drm::queryEngineInfo(bool isSysmanEnabled) { this->engineInfo = ioctlHelper->createEngineInfo(isSysmanEnabled); + if (this->engineInfo && this->engineInfo.get()->engines.size() == 0) { + printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Engine info size is equal to 0.\n"); + } + return this->engineInfo != nullptr; } diff --git a/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp index 8154ba4258..7cb759bdf7 100644 --- a/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_engine_info_prelim_tests.cpp @@ -92,6 +92,39 @@ TEST(DrmTest, givenMemRegionQueryNotSupportedWhenQueryingMemRegionInfoThenFailGr EXPECT_EQ(nullptr, drm->engineInfo); } +class MockIoctlHelperEngineInfoDetection : public IoctlHelperPrelim20 { + public: + using IoctlHelperPrelim20::IoctlHelperPrelim20; + + std::unique_ptr createEngineInfo(bool isSysmanEnabled) override { + std::vector engineInfo(0); + + return std::make_unique(&drm, engineInfo); + } +}; + +TEST(DrmTest, givenEngineQueryOnIncorrectSetupWithZeroEnginesThenProperDebugMessageIsPrinted) { + DebugManagerStateRestore dbgState; + debugManager.flags.PrintDebugMessages.set(1); + + auto executionEnvironment = std::make_unique(); + executionEnvironment->rootDeviceEnvironments[0]->initGmm(); + + auto drm = std::make_unique(*executionEnvironment->rootDeviceEnvironments[0]); + auto ioctlHelper = std::make_unique(*drm); + drm->ioctlHelper.reset(ioctlHelper.release()); + + testing::internal::CaptureStderr(); + + drm->queryEngineInfo(); + EXPECT_EQ(0u, drm->engineInfo.get()->engines.size()); + + std::string output = testing::internal::GetCapturedStderr(); + std::string expectedError = "FATAL: Engine info size is equal to 0.\n"; + + EXPECT_EQ(output, expectedError); +} + TEST(DrmTest, givenDistanceQueryNotSupportedWhenQueryingDistanceInfoThenFailGracefully) { auto executionEnvironment = std::make_unique(); executionEnvironment->rootDeviceEnvironments[0]->initGmm();