mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Add support for dumping cl_cache to specified directory
Change-Id: I782ff17d0d4b17d3d26db543eb7ae222f75ff8a1
This commit is contained in:
committed by
sys_ocldev
parent
7dbd0ea4f3
commit
3e800d55e6
@@ -49,7 +49,11 @@ class RegistryReaderMock : public SettingsReader {
|
||||
bool getSetting(const char *settingName, bool defaultValue) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string getSetting(const char *settingName, const std::string &value) override {
|
||||
return "";
|
||||
}
|
||||
const char *appSpecificLocation(const std::string &name) override {
|
||||
return name.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "test.h"
|
||||
#include <memory>
|
||||
#include "runtime/utilities/linux/debug_env_reader.h"
|
||||
|
||||
namespace OCLRT {
|
||||
@@ -68,4 +69,15 @@ TEST_F(DebugEnvReaderTests, CheckBoolEnvVariable) {
|
||||
ret = evr->getSetting("TestingVariable", defaultValue);
|
||||
EXPECT_EQ(defaultValue, ret);
|
||||
}
|
||||
|
||||
TEST_F(DebugEnvReaderTests, appSpecificLacationReturnClCacheLocation) {
|
||||
std::string appSpecific;
|
||||
appSpecific = "cl_cache_dir";
|
||||
EXPECT_EQ(appSpecific, evr->appSpecificLocation(appSpecific));
|
||||
}
|
||||
|
||||
TEST_F(DebugEnvReaderTests, givenEnvironmentVariableReaderWhenCreateOsReaderWithStringThenNotNullPointer) {
|
||||
std::unique_ptr<SettingsReader> evr(SettingsReader::createOsReader(""));
|
||||
EXPECT_NE(nullptr, evr);
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -38,6 +38,7 @@ set(IGDRCL_SRCS_tests_os_interface_windows
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager_allocate_in_device_pool_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_preemption_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_residency_controller_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_registry_reader.cpp
|
||||
)
|
||||
if(WIN32)
|
||||
file(GLOB IGDRCL_SRC_tests_wddm_interface "${CMAKE_CURRENT_SOURCE_DIR}/wddm2[0-9]_tests\.cpp")
|
||||
|
||||
@@ -69,7 +69,6 @@ class RegistryReaderMock : public SettingsReader {
|
||||
public:
|
||||
std::string nameString;
|
||||
std::string versionString;
|
||||
|
||||
std::string getSetting(const char *settingName, const std::string &value) {
|
||||
std::string key(settingName);
|
||||
if (key == "HardwareInformation.AdapterString") {
|
||||
@@ -82,6 +81,7 @@ class RegistryReaderMock : public SettingsReader {
|
||||
|
||||
bool getSetting(const char *settingName, bool defaultValue) { return defaultValue; };
|
||||
int32_t getSetting(const char *settingName, int32_t defaultValue) { return defaultValue; };
|
||||
const char *appSpecificLocation(const std::string &name) { return name.c_str(); };
|
||||
|
||||
bool properNameKey = false;
|
||||
bool properVersionKey = false;
|
||||
|
||||
27
unit_tests/os_interface/windows/mock_registry_reader.cpp
Normal file
27
unit_tests/os_interface/windows/mock_registry_reader.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "windows_wrapper.h"
|
||||
|
||||
LSTATUS APIENTRY RegOpenKeyExA(
|
||||
HKEY hKey,
|
||||
LPCSTR lpSubKey,
|
||||
DWORD ulOptions,
|
||||
REGSAM samDesired,
|
||||
PHKEY phkResult) {
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
};
|
||||
|
||||
LSTATUS APIENTRY RegQueryValueExA(
|
||||
HKEY hKey,
|
||||
LPCSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData) {
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
};
|
||||
@@ -14,12 +14,12 @@ class TestedRegistryReader : public RegistryReader {
|
||||
public:
|
||||
TestedRegistryReader(bool userScope) : RegistryReader(userScope){};
|
||||
TestedRegistryReader(std::string regKey) : RegistryReader(regKey){};
|
||||
|
||||
HKEY getHkeyType() const {
|
||||
return igdrclHkeyType;
|
||||
}
|
||||
using RegistryReader::getSetting;
|
||||
const char *getRegKey() const {
|
||||
return igdrclRegKey.c_str();
|
||||
return registryReadRootKey.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -37,8 +37,26 @@ TEST_F(RegistryReaderTest, givenRegistryReaderWhenItIsCreatedWithUserScopeSetToT
|
||||
EXPECT_EQ(HKEY_CURRENT_USER, registryReader.getHkeyType());
|
||||
}
|
||||
|
||||
TEST_F(RegistryReaderTest, givenRegistryReaderWhenItIsCreatedWithRegKeySpecifiedThenItsRegKeyIsInitializedAccordingly) {
|
||||
std::string regKey = "Software\\Intel\\OpenCL";
|
||||
TestedRegistryReader registryReader(regKey);
|
||||
EXPECT_STREQ("Software\\Intel\\OpenCL", registryReader.getRegKey());
|
||||
TEST_F(RegistryReaderTest, givenRegistryReaderWhenCallAppSpecificLocationThenReturnCurrentProcessName) {
|
||||
char buff[MAX_PATH];
|
||||
GetModuleFileNameA(nullptr, buff, MAX_PATH);
|
||||
|
||||
TestedRegistryReader registryReader(false);
|
||||
const char *ret = registryReader.appSpecificLocation("cl_cache_dir");
|
||||
EXPECT_STREQ(buff, ret);
|
||||
}
|
||||
|
||||
TEST_F(RegistryReaderTest, givenRegistryReaderWhenRegKeyNotExistThenReturnDefaultValue) {
|
||||
std::string regKey = "notExistPath";
|
||||
std::string value = "defaultValue";
|
||||
TestedRegistryReader registryReader(regKey);
|
||||
|
||||
EXPECT_EQ(value, registryReader.getSetting("", value));
|
||||
}
|
||||
|
||||
TEST_F(RegistryReaderTest, givenRegistryReaderWhenItIsCreatedWithRegKeySpecifiedThenRegKeyIsInitializedAccordingly) {
|
||||
std::string regKey = "regKey";
|
||||
std::string defaultKey = "Software\\Intel\\IGFX\\OCL";
|
||||
TestedRegistryReader registryReader(regKey);
|
||||
EXPECT_STREQ((defaultKey + "\\" + regKey).c_str(), registryReader.getRegKey());
|
||||
}
|
||||
|
||||
@@ -116,3 +116,9 @@ TEST(SettingsFileReader, GetSettingWhenNotInFile) {
|
||||
|
||||
EXPECT_EQ(defaultStringValue, returnedStringValue);
|
||||
}
|
||||
|
||||
TEST(SettingsFileReader, appSpecificLocation) {
|
||||
std::unique_ptr<TestSettingsFileReader> reader(new TestSettingsFileReader(TestSettingsFileReader::testPath));
|
||||
std::string appSpecific = "cl_cache_dir";
|
||||
EXPECT_EQ(appSpecific, reader->appSpecificLocation(appSpecific));
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@ TEST(SettingsReader, CreateOsReader) {
|
||||
delete reader;
|
||||
}
|
||||
|
||||
TEST(SettingsReader, CreateOsReaderWithRegKey) {
|
||||
std::string regKey = "Software\\Intel\\OpenCL";
|
||||
unique_ptr<SettingsReader> reader(SettingsReader::createOsReader(regKey));
|
||||
EXPECT_NE(nullptr, reader);
|
||||
}
|
||||
|
||||
TEST(SettingsReader, givenPrintDebugStringWhenCalledWithTrueItPrintsToOutput) {
|
||||
int i = 4;
|
||||
testing::internal::CaptureStdout();
|
||||
|
||||
Reference in New Issue
Block a user