fix: remove compiler cache legacy implementation

Related-To: NEO-10679

Signed-off-by: Weronika Kapusta <weronika.kapusta@intel.com>
This commit is contained in:
Weronika Kapusta
2024-05-06 16:20:13 +00:00
committed by Compute-Runtime-Automation
parent e2a3c21e1c
commit d6c16c1640
20 changed files with 26 additions and 154 deletions

View File

@@ -445,6 +445,7 @@ TEST(CompilerInterfaceCachedTests, givenKernelWithoutIncludesAndBinaryInCacheWhe
std::unique_ptr<CompilerCacheMock> cache(new CompilerCacheMock());
cache->loadResult = true;
cache->config.enabled = true;
auto compilerInterface = std::unique_ptr<CompilerInterface>(CompilerInterface::createInstance(std::move(cache), true));
TranslationOutput translationOutput;
inputArgs.allowCaching = true;

View File

@@ -21,47 +21,6 @@ namespace SysCalls {
extern bool pathExistsMock;
}
namespace LegacyPathWorksIfNewEnvIsSetToDisabled {
bool pathExistsMock(const std::string &path) {
if (path.find(ApiSpecificConfig::compilerCacheLocation().c_str()) != path.npos)
return true;
return false;
}
} // namespace LegacyPathWorksIfNewEnvIsSetToDisabled
TEST(ClCacheDefaultConfigLinuxTest, GivenDefaultClCacheConfigWithPathExistsAndNewEnvSetToDisabledThenValuesAreProperlyPopulated) {
std::unordered_map<std::string, std::string> mockableEnvs;
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&NEO::IoFunctions::mockableEnvValues, &mockableEnvs);
VariableBackup<decltype(NEO::SysCalls::sysCallsPathExists)> pathExistsBackup(&NEO::SysCalls::sysCallsPathExists, LegacyPathWorksIfNewEnvIsSetToDisabled::pathExistsMock);
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
EXPECT_STREQ(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str());
EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str());
EXPECT_TRUE(cacheConfig.enabled);
}
namespace NewEnvIsDisabledAndLegacyPathDoesNotExist {
bool pathExistsMock(const std::string &path) {
return false;
}
} // namespace NewEnvIsDisabledAndLegacyPathDoesNotExist
TEST(ClCacheDefaultConfigLinuxTest, GivenDefaultClCacheConfigWithNotExistingPathAndNewEnvSetToDisabledThenValuesAreProperlyPopulated) {
std::unordered_map<std::string, std::string> mockableEnvs;
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&NEO::IoFunctions::mockableEnvValues, &mockableEnvs);
VariableBackup<decltype(NEO::SysCalls::sysCallsPathExists)> pathExistsBackup(&NEO::SysCalls::sysCallsPathExists, NewEnvIsDisabledAndLegacyPathDoesNotExist::pathExistsMock);
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
EXPECT_STREQ(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str());
EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str());
EXPECT_FALSE(cacheConfig.enabled);
}
namespace AllVariablesCorrectlySet {
bool pathExistsMock(const std::string &path) {
if (path.find("ult/directory/") != path.npos)
@@ -365,4 +324,13 @@ TEST(ClCacheDefaultConfigLinuxTest, GivenXdgEnvWhenOtherProcessCreatesNeoCompile
EXPECT_EQ(cacheConfig.cacheDir, "xdg/directory/neo_compiler_cache");
EXPECT_TRUE(XdgPathIsSetAndOtherProcessCreatesPath::mkdirCalled);
}
TEST(ClCacheDefaultConfigLinuxTest, GivenNeoCachePersistentSetToZeroWhenGetDefaultCompilerCacheConfigThenCacheIsDisabled) {
std::unordered_map<std::string, std::string> mockableEnvs;
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
EXPECT_FALSE(cacheConfig.enabled);
}
} // namespace NEO

View File

@@ -62,30 +62,6 @@ struct ClCacheDefaultConfigWindowsTest : public ::testing::Test {
VariableBackup<BOOL> createDirectoryAResultBackup;
};
TEST_F(ClCacheDefaultConfigWindowsTest, GivenDefaultClCacheConfigWithPathExistsThenValuesAreProperlyPopulated) {
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
bool pathExistsMock = true;
VariableBackup<bool> pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock);
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
EXPECT_STREQ(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str());
EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str());
EXPECT_TRUE(cacheConfig.enabled);
}
TEST_F(ClCacheDefaultConfigWindowsTest, GivenDefaultClCacheConfigWithNonExistingPathThenValuesAreProperlyPopulated) {
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
bool pathExistsMock = false;
VariableBackup<bool> pathExistsMockBackup(&NEO::SysCalls::pathExistsMock, pathExistsMock);
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
EXPECT_STREQ(ApiSpecificConfig::compilerCacheLocation().c_str(), cacheConfig.cacheDir.c_str());
EXPECT_STREQ(ApiSpecificConfig::compilerCacheFileExtension().c_str(), cacheConfig.cacheFileExtension.c_str());
EXPECT_FALSE(cacheConfig.enabled);
}
TEST_F(ClCacheDefaultConfigWindowsTest, GivenAllEnvVarWhenProperlySetThenCorrectConfigIsReturned) {
mockableEnvs["NEO_CACHE_PERSISTENT"] = "1";
mockableEnvs["NEO_CACHE_MAX_SIZE"] = "22";
@@ -289,4 +265,12 @@ TEST_F(ClCacheDefaultConfigWindowsTest, GivenCachePathExistsAndNoEnvVarsSetWhenG
EXPECT_EQ(cacheConfig.cacheDir, expectedCacheDirPath);
}
TEST_F(ClCacheDefaultConfigWindowsTest, GivenNeoCachePersistentSetToZeroWhenGetDefaultCompilerCacheConfigThenCacheIsDisabled) {
mockableEnvs["NEO_CACHE_PERSISTENT"] = "0";
auto cacheConfig = NEO::getDefaultCompilerCacheConfig();
EXPECT_FALSE(cacheConfig.enabled);
}
} // namespace NEO

View File

@@ -483,12 +483,6 @@ TEST_F(DebugEnvReaderTests, GivenBoolEnvVariableWhenGettingThenCorrectValueIsRet
}
}
TEST_F(DebugEnvReaderTests, WhenSettingAppSpecificLocationThenLocationIsReturned) {
std::string appSpecific;
appSpecific = "cl_cache_dir";
EXPECT_EQ(appSpecific, environmentVariableReader->appSpecificLocation(appSpecific));
}
TEST_F(DebugEnvReaderTests, givenEnvironmentVariableReaderWhenCreateOsReaderWithStringThenNotNullPointer) {
std::unique_ptr<SettingsReader> settingsReader(SettingsReader::createOsReader(false, ""));
EXPECT_NE(nullptr, settingsReader);

View File

@@ -507,24 +507,4 @@ TEST_F(RegistryReaderTest, givenRegistryKeyPresentWhenValueIsNonZeroInBothDwords
EXPECT_TRUE(value);
EXPECT_EQ(DebugVarPrefix::none, type);
}
TEST_F(DebugReaderWithRegistryAndEnvTest, givenSetProcessNameWhenReadFromEnvironmentVariableThenReturnClCacheDir) {
SysCalls::regOpenKeySuccessCount = 0u;
SysCalls::regQueryValueSuccessCount = 0u;
registryReader.processName = "processName";
std::string defaultCacheDir = "";
std::string cacheDir = registryReader.getSetting("processName", defaultCacheDir);
EXPECT_STREQ("./tested_cl_cache_dir", cacheDir.c_str());
}
TEST_F(DebugReaderWithRegistryAndEnvTest, givenSetProcessNameWhenReadFromEnvironmentVariableThenReturnClCacheDirPrefix) {
SysCalls::regOpenKeySuccessCount = 0u;
SysCalls::regQueryValueSuccessCount = 0u;
registryReader.processName = "processName";
std::string defaultCacheDir = "";
DebugVarPrefix type = DebugVarPrefix::none;
std::string cacheDir2 = registryReader.getSetting("processName", defaultCacheDir, type);
EXPECT_STREQ("./tested_cl_cache_dir", cacheDir2.c_str());
EXPECT_EQ(DebugVarPrefix::none, type);
}
} // namespace NEO

View File

@@ -38,7 +38,6 @@ class TestedRegistryReader : public RegistryReader {
IoFunctions::mockableEnvValues->insert({"settingSourceString", "environment"});
IoFunctions::mockableEnvValues->insert({"settingSourceInt", "2"});
IoFunctions::mockableEnvValues->insert({"processName", "processName"});
IoFunctions::mockableEnvValues->insert({"cl_cache_dir", "./tested_cl_cache_dir"});
}
const char *getRegKey() const {
return registryReadRootKey.c_str();