mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Improve code coverage of OfflineCompiler class
This change introduces unit tests related to member functions of OfflineCompiler class. OfflineCompiler::initialize() is not covered and it will be added in a separate commit. Related-To: NEO-6834 Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
db9c0d1103
commit
76349b8030
@@ -1143,10 +1143,10 @@ void OfflineCompiler::writeOutAllFiles() {
|
||||
dirList.push_back(tmp);
|
||||
pos = tmp.find_last_of("/\\", pos);
|
||||
tmp = tmp.substr(0, pos);
|
||||
} while (pos != std::string::npos);
|
||||
} while (pos != std::string::npos && !tmp.empty());
|
||||
|
||||
while (!dirList.empty()) {
|
||||
MakeDirectory(dirList.back().c_str());
|
||||
createDir(dirList.back());
|
||||
dirList.pop_back();
|
||||
}
|
||||
}
|
||||
@@ -1192,6 +1192,10 @@ void OfflineCompiler::writeOutAllFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineCompiler::createDir(const std::string &path) {
|
||||
MakeDirectory(path.c_str());
|
||||
}
|
||||
|
||||
bool OfflineCompiler::readOptionsFromFile(std::string &options, const std::string &file, OclocArgHelper *helper) {
|
||||
if (!helper->fileExists(file)) {
|
||||
return false;
|
||||
|
||||
@@ -114,6 +114,7 @@ class OfflineCompiler {
|
||||
return suffix;
|
||||
}
|
||||
MOCKABLE_VIRTUAL void writeOutAllFiles();
|
||||
MOCKABLE_VIRTUAL void createDir(const std::string &path);
|
||||
void unifyExcludeIrFlags();
|
||||
HardwareInfo hwInfo;
|
||||
|
||||
@@ -167,4 +168,5 @@ class OfflineCompiler {
|
||||
|
||||
OclocArgHelper *argHelper = nullptr;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -493,6 +493,10 @@ CIF::ICIF *MockIgcOclDeviceCtx::Create(CIF::InterfaceId_t intId, CIF::Version_t
|
||||
IGC::IgcOclTranslationCtxBase *MockIgcOclDeviceCtx::CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) {
|
||||
if (igcDebugVars->shouldFailCreationOfTranslationContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
requestedTranslationCtxs.emplace_back(inType, outType);
|
||||
return new MockIgcOclTranslationCtx;
|
||||
}
|
||||
@@ -662,6 +666,11 @@ CIF::ICIF *MockFclOclDeviceCtx::Create(CIF::InterfaceId_t intId, CIF::Version_t
|
||||
IGC::FclOclTranslationCtxBase *MockFclOclDeviceCtx::CreateTranslationCtxImpl(CIF::Version_t ver,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) {
|
||||
if (fclDebugVars->shouldFailCreationOfTranslationContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
requestedTranslationCtxs.emplace_back(inType, outType);
|
||||
return new MockFclOclTranslationCtx;
|
||||
}
|
||||
|
||||
@@ -669,6 +678,15 @@ IGC::FclOclTranslationCtxBase *MockFclOclDeviceCtx::CreateTranslationCtxImpl(CIF
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType,
|
||||
CIF::Builtins::BufferSimple *err) {
|
||||
if (!fclDebugVars->translationContextCreationError.empty() && err) {
|
||||
err->PushBackRawBytes(fclDebugVars->translationContextCreationError.c_str(), fclDebugVars->translationContextCreationError.size());
|
||||
}
|
||||
|
||||
if (fclDebugVars->shouldFailCreationOfTranslationContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
requestedTranslationCtxs.emplace_back(inType, outType);
|
||||
return new MockFclOclTranslationCtx;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ struct MockCompilerDebugVars {
|
||||
bindless
|
||||
};
|
||||
bool shouldReturnInvalidTranslationOutput = false;
|
||||
bool shouldFailCreationOfTranslationContext = false;
|
||||
bool forceBuildFailure = false;
|
||||
bool forceCreateFailure = false;
|
||||
bool forceRegisterFail = false;
|
||||
@@ -45,6 +46,7 @@ struct MockCompilerDebugVars {
|
||||
std::string *receivedInput = nullptr;
|
||||
|
||||
std::string fileName;
|
||||
std::string translationContextCreationError;
|
||||
};
|
||||
|
||||
struct MockCompilerEnableGuard {
|
||||
@@ -287,6 +289,9 @@ struct MockFclOclDeviceCtx : MockCIF<IGC::FclOclDeviceCtxTagOCL> {
|
||||
|
||||
uint32_t oclApiVersion = 120;
|
||||
MockCIFPlatform *platform = nullptr;
|
||||
|
||||
using TranslationOpT = std::pair<IGC::CodeType::CodeType_t, IGC::CodeType::CodeType_t>;
|
||||
std::vector<TranslationOpT> requestedTranslationCtxs;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user