Skip to content

Commit 35064c3

Browse files
Allow for hex input in file with debug keys
Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 583a57c commit 35064c3

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
DECLARE_DEBUG_VARIABLE(std::string, StringTestKey, "DefaultTestValue", "TestDescription")
9-
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKey, 1, "TestDescription")
9+
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKey, 1234, "TestDescription")
10+
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKeyHex, 0xDEADBEEF, "TestDescription")
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
StringTestKey = TestValue
2-
IntTestKey = 1
2+
IntTestKey = 123
3+
IntTestKeyHex = 0xABCD

opencl/test/unit_test/utilities/debug_file_reader_tests.inl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ TEST(SettingsFileReader, givenDebugFileSettingInWhichStringIsFollowedByIntegerWh
8989
int32_t retValue = 0;
9090
int32_t returnedIntValue = reader->getSetting("IntTestKey", retValue);
9191

92-
EXPECT_EQ(1, returnedIntValue);
92+
EXPECT_EQ(123, returnedIntValue);
93+
94+
int32_t returnedIntValueHex = reader->getSetting("IntTestKeyHex", 0);
95+
96+
EXPECT_EQ(0xABCD, returnedIntValueHex);
9397

9498
std::string retValueString;
9599
std::string returnedStringValue = reader->getSetting("StringTestKey", retValueString);

shared/source/utilities/debug_file_reader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -36,7 +36,7 @@ int64_t SettingsFileReader::getSetting(const char *settingName, int64_t defaultV
3636

3737
std::map<std::string, std::string>::iterator it = settingStringMap.find(std::string(settingName));
3838
if (it != settingStringMap.end()) {
39-
value = atoll(it->second.c_str());
39+
value = strtoll(it->second.c_str(), nullptr, 0);
4040
}
4141

4242
return value;

0 commit comments

Comments
 (0)