Support for environment variables

Change-Id: Ie52580703d3db36e3993d9e91cbbeb1fbb8cc1ae
Signed-off-by: Koska <andrzej.koska@intel.com>
Related-To: NEO-3239
Current order of reading debug variables:
- igdrcl.config file
- registry (under Windows)
- Environment variables
This commit is contained in:
Koska
2019-10-09 11:40:50 +02:00
committed by sys_ocldev
parent 4446840de9
commit b9e0411c18
4 changed files with 25 additions and 0 deletions

View File

@@ -47,3 +47,10 @@ TEST_F(RegistryReaderTest, givenRegistryReaderWhenItIsCreatedWithRegKeySpecified
TestedRegistryReader registryReader(regKey);
EXPECT_STREQ(regKey.c_str(), registryReader.getRegKey());
}
TEST_F(RegistryReaderTest, givenRegistryReaderWhenEnvironmentVariableExistsThenReturnCorrectValue) {
char *envVar = "TestedEnvironmentVariable";
std::string value = "defaultValue";
TestedRegistryReader registryReader("");
EXPECT_EQ("TestedEnvironmentVariableValue", registryReader.getSetting(envVar, value));
}

View File

@@ -17,6 +17,13 @@ class TestedRegistryReader : public RegistryReader {
return igdrclHkeyType;
}
using RegistryReader::getSetting;
char *getenv(const char *envVar) override {
if (strcmp(envVar, "TestedEnvironmentVariable") == 0) {
return "TestedEnvironmentVariableValue";
} else {
return nullptr;
}
}
const char *getRegKey() const {
return registryReadRootKey.c_str();
}