1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
/*
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#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()) {
initEnv();
};
TestedRegistryReader(std::string regKey) : RegistryReader(false, regKey) {
initEnv();
};
HKEY getHkeyType() const {
return hkeyType;
}
using RegistryReader::getSetting;
using RegistryReader::processName;
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"});
}
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
|