mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
fix: setup correct non-release key name in getStringWithFlags
unify function for getting env Related-To: NEO-8347 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
cbbcbc94b1
commit
46288b8efd
@@ -9,45 +9,41 @@
|
||||
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#include "shared/source/os_interface/windows/debug_registry_reader.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
|
||||
namespace NEO {
|
||||
class TestedRegistryReader : public RegistryReader {
|
||||
public:
|
||||
TestedRegistryReader(bool userScope) : RegistryReader(userScope, ApiSpecificConfig::getRegistryPath()){};
|
||||
TestedRegistryReader(std::string regKey) : RegistryReader(false, regKey){};
|
||||
TestedRegistryReader(bool userScope) : RegistryReader(userScope, ApiSpecificConfig::getRegistryPath()) {
|
||||
initEnv();
|
||||
};
|
||||
TestedRegistryReader(std::string regKey) : RegistryReader(false, regKey) {
|
||||
initEnv();
|
||||
};
|
||||
HKEY getHkeyType() const {
|
||||
return hkeyType;
|
||||
}
|
||||
using RegistryReader::getSetting;
|
||||
using RegistryReader::processName;
|
||||
|
||||
char *getenv(const char *envVar) override {
|
||||
if (strcmp(envVar, "TestedEnvironmentVariable") == 0) {
|
||||
return "TestedEnvironmentVariableValue";
|
||||
} else if (strcmp(envVar, "NEO_TestedEnvironmentVariableWithPrefix") == 0) {
|
||||
return "TestedEnvironmentVariableValueWithPrefix";
|
||||
} else if (strcmp(envVar, "TestedEnvironmentIntVariable") == 0) {
|
||||
return "1234";
|
||||
} else if (strcmp(envVar, "NEO_TestedEnvironmentIntVariableWithPrefix") == 0) {
|
||||
return "5678";
|
||||
} else if (strcmp(envVar, "TestedEnvironmentInt64Variable") == 0) {
|
||||
return "9223372036854775807";
|
||||
} else if (strcmp(envVar, "NEO_TestedEnvironmentInt64VariableWithPrefix") == 0) {
|
||||
return "9223372036854775806";
|
||||
} else if (strcmp(envVar, "settingSourceString") == 0) {
|
||||
return "environment";
|
||||
} else if (strcmp(envVar, "settingSourceInt") == 0) {
|
||||
return "2";
|
||||
} else if (strcmp(envVar, "processName") == 0) {
|
||||
return "processName";
|
||||
} else if (strcmp(envVar, "cl_cache_dir") == 0) {
|
||||
return "./tested_cl_cache_dir";
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
void initEnv() {
|
||||
|
||||
IoFunctions::mockableEnvValues->insert({"TestedEnvironmentVariable", "TestedEnvironmentVariableValue"});
|
||||
IoFunctions::mockableEnvValues->insert({"NEO_TestedEnvironmentVariableWithPrefix", "TestedEnvironmentVariableValueWithPrefix"});
|
||||
IoFunctions::mockableEnvValues->insert({"TestedEnvironmentIntVariable", "1234"});
|
||||
IoFunctions::mockableEnvValues->insert({"NEO_TestedEnvironmentIntVariableWithPrefix", "5678"});
|
||||
IoFunctions::mockableEnvValues->insert({"TestedEnvironmentInt64Variable", "9223372036854775807"});
|
||||
IoFunctions::mockableEnvValues->insert({"NEO_TestedEnvironmentInt64VariableWithPrefix", "9223372036854775806"});
|
||||
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();
|
||||
}
|
||||
std::unordered_map<std::string, std::string> mockEnvironment{};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup{&IoFunctions::mockableEnvValues, &mockEnvironment};
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user