File: registry_reader_tests.h

package info (click to toggle)
intel-compute-runtime 26.05.37020.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,596 kB
  • sloc: cpp: 976,037; lisp: 2,096; sh: 704; makefile: 162
file content (48 lines) | stat: -rw-r--r-- 2,064 bytes parent folder | download | duplicates (2)
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