Allow for hex input in file with debug keys

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2021-02-26 13:44:43 +00:00 committed by Compute-Runtime-Automation
parent 583a57c159
commit 35064c3dea
4 changed files with 12 additions and 6 deletions

View File

@ -1,9 +1,10 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
DECLARE_DEBUG_VARIABLE(std::string, StringTestKey, "DefaultTestValue", "TestDescription")
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKey, 1, "TestDescription")
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKey, 1234, "TestDescription")
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKeyHex, 0xDEADBEEF, "TestDescription")

View File

@ -1,2 +1,3 @@
StringTestKey = TestValue
IntTestKey = 1
IntTestKey = 123
IntTestKeyHex = 0xABCD

View File

@ -89,7 +89,11 @@ TEST(SettingsFileReader, givenDebugFileSettingInWhichStringIsFollowedByIntegerWh
int32_t retValue = 0;
int32_t returnedIntValue = reader->getSetting("IntTestKey", retValue);
EXPECT_EQ(1, returnedIntValue);
EXPECT_EQ(123, returnedIntValue);
int32_t returnedIntValueHex = reader->getSetting("IntTestKeyHex", 0);
EXPECT_EQ(0xABCD, returnedIntValueHex);
std::string retValueString;
std::string returnedStringValue = reader->getSetting("StringTestKey", retValueString);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -36,7 +36,7 @@ int64_t SettingsFileReader::getSetting(const char *settingName, int64_t defaultV
std::map<std::string, std::string>::iterator it = settingStringMap.find(std::string(settingName));
if (it != settingStringMap.end()) {
value = atoll(it->second.c_str());
value = strtoll(it->second.c_str(), nullptr, 0);
}
return value;