mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Fix read of 64bit enviroment variables
change atoi to atoll Signed-off-by: Cencelewska, Katarzyna <katarzyna.cencelewska@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
69c9a4e86c
commit
9b19014cf1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -29,7 +29,7 @@ int64_t EnvironmentVariableReader::getSetting(const char *settingName, int64_t d
|
||||
|
||||
envValue = IoFunctions::getenvPtr(settingName);
|
||||
if (envValue) {
|
||||
value = atoi(envValue);
|
||||
value = atoll(envValue);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -82,7 +82,7 @@ int64_t RegistryReader::getSetting(const char *settingName, int64_t defaultValue
|
||||
if (readSettingFromEnv) {
|
||||
const char *envValue = getenv(settingName);
|
||||
if (envValue) {
|
||||
value = atoi(envValue);
|
||||
value = atoll(envValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,20 @@ TEST_F(DebugEnvReaderTests, GivenSetVariableThenSetValueIsReturned) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DebugEnvReaderTests, givenMaxInt64AsEnvWhenGetSettingThenProperValueIsReturned) {
|
||||
const char *testingVariableName = "TestingVariable";
|
||||
const char *testingVariableValue = "9223372036854775807";
|
||||
int64_t expectedValue = 9223372036854775807;
|
||||
int64_t defaultValue = 0;
|
||||
|
||||
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{testingVariableName, testingVariableValue}};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
|
||||
EXPECT_EQ(expectedValue, evr->getSetting(testingVariableName, defaultValue));
|
||||
EXPECT_EQ(1u, IoFunctions::mockGetenvCalled);
|
||||
}
|
||||
|
||||
TEST_F(DebugEnvReaderTests, GivenUnsetVariableThenDefaultValueIsReturned) {
|
||||
int32_t ret;
|
||||
std::string retString;
|
||||
|
||||
Reference in New Issue
Block a user