refactor: add debug message about the zero engine info size

Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala 2024-04-25 15:08:27 +00:00 committed by Compute-Runtime-Automation
parent 06faaab5bb
commit a70aaa72ed
2 changed files with 37 additions and 0 deletions

View File

@ -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;
}

View File

@ -92,6 +92,39 @@ TEST(DrmTest, givenMemRegionQueryNotSupportedWhenQueryingMemRegionInfoThenFailGr
EXPECT_EQ(nullptr, drm->engineInfo);
}
class MockIoctlHelperEngineInfoDetection : public IoctlHelperPrelim20 {
public:
using IoctlHelperPrelim20::IoctlHelperPrelim20;
std::unique_ptr<EngineInfo> createEngineInfo(bool isSysmanEnabled) override {
std::vector<NEO::EngineCapabilities> engineInfo(0);
return std::make_unique<EngineInfo>(&drm, engineInfo);
}
};
TEST(DrmTest, givenEngineQueryOnIncorrectSetupWithZeroEnginesThenProperDebugMessageIsPrinted) {
DebugManagerStateRestore dbgState;
debugManager.flags.PrintDebugMessages.set(1);
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
auto drm = std::make_unique<DrmQueryMock>(*executionEnvironment->rootDeviceEnvironments[0]);
auto ioctlHelper = std::make_unique<MockIoctlHelperEngineInfoDetection>(*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<MockExecutionEnvironment>();
executionEnvironment->rootDeviceEnvironments[0]->initGmm();